Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrolling Inserter Sections #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/editor.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'e7de7d86bd0f8dab8726');
<?php return array('dependencies' => array(), 'version' => '8dddfed167cfdaa65ee8');
489 changes: 488 additions & 1 deletion build/editor.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/editor.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-primitives'), 'version' => 'b9039859ee148bccd2ce');
<?php return array('dependencies' => array('lodash', 'react', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-primitives'), 'version' => 'fd232d1601671eb78211');
17,750 changes: 17,746 additions & 4 deletions build/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/style.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'ca9dfa13a90bf7f4013a');
<?php return array('dependencies' => array(), 'version' => 'b44d74af8873e6c88566');
65 changes: 64 additions & 1 deletion build/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions src/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,65 @@ import { flattenIconsArray, getIconTypes } from './../../utils';
import ContentHeader from './content-header';
import IconGrid from './icon-grid';
import Sidebar from './sidebar';



function resizeScrollers() {

const getEl = (theSelector) => {
return window.document.querySelector(theSelector);
}

var tmpModal = getEl('.components-modal__content')
var tmpHeader = getEl('.components-modal__header');
var tmpSB = getEl('.icon-inserter__sidebar__search')

var tmpBuffer = 4;

var tmpMH = tmpModal.clientHeight;
var tmpHH = tmpHeader.clientHeight;
var tmpSH = tmpSB.clientHeight;

var tmpCBH = tmpMH - tmpSH - tmpBuffer;

var tmpCatBox = getEl('.icon-inserter__sidebar__category-type.components-menu-group');
var tmpIconsBox = getEl('.icon-inserter__content');
tmpCatBox.style.height = tmpCBH + 'px';
tmpIconsBox.style.height = (tmpCBH + tmpSH ) + 'px';

}

export default function InserterModal( props ) {
const { isInserterOpen, setInserterOpen, attributes, setAttributes } =
props;
const iconsByType = getIcons();
const iconTypes = getIconTypes( iconsByType );

//---- NEW CODE TO RESIZE SCROLLERS TO MODAL SIZE - WJF

//--- Resize scrollable elements when dialog is openned
useEffect(() => {
if( isInserterOpen ){
//--- Trigger looking for it
resizeScrollers();
}
}, [isInserterOpen]);


//--- Resize scrollable on window change
useEffect(() => {
//--- Handle window resize
const handleResize = () => {
resizeScrollers();
};
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
}
}, []);

//--- END WJF CODE

// Get the default type, and if there is none, get the first type.
const defaultType = useMemo( () => {
const defaultTypes = iconTypes.filter( ( type ) => type.isDefault );
Expand Down
18 changes: 11 additions & 7 deletions src/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
.wp-block-outermost-icon-inserter__modal {
.components-modal__content {
flex: 1 1 0%;
overflow: auto;
overflow: hidden;
padding: 0px;

&:before {
Expand All @@ -112,23 +112,23 @@
.icon-inserter {
align-items: stretch;
display: flex;
height: 100%;
height: 100%;
}

.icon-inserter__sidebar {
display: none;
flex-direction: column;
flex-shrink: 0;
overflow-y: scroll;
overflow: hidden;
width: 280px;
padding: 24px 32px 32px;
padding: 0px;

@media ( min-width: 900px ) {
display: flex;
}

&__search {
margin-bottom: 16px;
margin-bottom: 2px;

.components-base-control__field {
margin-bottom: 0;
Expand All @@ -138,6 +138,8 @@
&__category-type {
// Override core component styles.
border: none;
height:400px; //-- changes via code
overflow:auto;

.components-menu-group__label {
margin: 0;
Expand Down Expand Up @@ -165,9 +167,11 @@
flex-direction: column;
flex-shrink: 0;
overflow: auto;
padding-top: 24px;
padding-right: 32px;
padding-top: 10px;
padding-right: 10px;
width: 100%;
height:300px;


@media ( min-width: 900px ) {
width: calc(100% - 281px);
Expand Down