Skip to content

Commit

Permalink
SelectControl: remove margin overrides and add new opt-in prop
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Dec 10, 2022
1 parent b333d1d commit ac7db75
Show file tree
Hide file tree
Showing 30 changed files with 74 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function DefaultStylePicker( { blockName } ) {
onUpdatePreferredStyleVariations && (
<div className="default-style-picker__default-switcher">
<SelectControl
__nextHasNoMarginBottom
options={ selectOptions }
value={ preferredStyle || '' }
label={ __( 'Default Style' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/font-family/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function FontFamilyControl( {
];
return (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Font' ) }
options={ options }
value={ value }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function ImageSizeControl( {
<>
{ ! isEmpty( imageSizeOptions ) && (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Image size' ) }
value={ slug }
options={ imageSizeOptions }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/archives/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
}
/>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Group by:' ) }
options={ [
{ label: __( 'Year' ), value: 'yearly' },
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/audio/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function AudioEdit( {
checked={ loop }
/>
<SelectControl
__nextHasNoMarginBottom
label={ _x( 'Preload', 'noun; Audio block parameter' ) }
value={ preload || '' }
// `undefined` is required for the preload attribute to be unset.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function CommentsInspectorControls( {
<InspectorControls>
<InspectorControls __experimentalGroup="advanced">
<SelectControl
__nextHasNoMarginBottom
label={ __( 'HTML element' ) }
options={ [
{ label: __( 'Default (<div>)' ), value: 'div' },
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/file/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default function FileBlockInspector( {
) }
<PanelBody title={ __( 'Settings' ) }>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Link to' ) }
value={ textLinkHref }
options={ linkDestinationOptions }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ function GalleryEdit( props ) {
help={ getImageCropHelp }
/>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Link to' ) }
value={ linkTo }
onChange={ setLinkTo }
Expand All @@ -532,6 +533,7 @@ function GalleryEdit( props ) {
) }
{ imageSizeOptions?.length > 0 && (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Image size' ) }
value={ sizeSlug }
options={ imageSizeOptions }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/gallery/v1/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ function GalleryEdit( props ) {
help={ getImageCropHelp }
/>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Link to' ) }
value={ linkTo }
onChange={ setLinkTo }
Expand All @@ -428,6 +429,7 @@ function GalleryEdit( props ) {
/>
{ shouldShowSizeOptions && (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Image size' ) }
value={ sizeSlug }
options={ imageSizeOptions }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function GroupEditControls( { tagName, onSelectTagName } ) {
return (
<InspectorControls __experimentalGroup="advanced">
<SelectControl
__nextHasNoMarginBottom
label={ __( 'HTML element' ) }
options={ [
{ label: __( 'Default (<div>)' ), value: 'div' },
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-author/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function PostAuthorEdit( {
/>
) ) || (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Author' ) }
value={ authorId }
options={ authorOptions }
Expand All @@ -127,6 +128,7 @@ function PostAuthorEdit( {
/>
{ showAvatar && (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Avatar size' ) }
value={ attributes.avatarSize }
options={ avatarSizes }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const DimensionControls = ( {
panelId={ clientId }
>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Image size' ) }
value={ sizeSlug || DEFAULT_SIZE }
options={ imageSizeOptions }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export default function QueryInspectorControls( {
) }
{ showPostTypeControl && (
<SelectControl
__nextHasNoMarginBottom
options={ postTypesSelectOptions }
value={ postType }
label={ __( 'Post type' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const orderOptions = [
function OrderControl( { order, orderBy, onChange } ) {
return (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Order by' ) }
value={ `${ orderBy }/${ order }` }
options={ orderOptions }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const stickyOptions = [
export default function StickyControl( { value, onChange } ) {
return (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Sticky posts' ) }
options={ stickyOptions }
value={ value }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/query/edit/query-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default function QueryContent( {
</BlockControls>
<InspectorControls __experimentalGroup="advanced">
<SelectControl
__nextHasNoMarginBottom
label={ __( 'HTML element' ) }
options={ [
{ label: __( 'Default (<div>)' ), value: 'div' },
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/tag-cloud/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function TagCloudEdit( { attributes, setAttributes, taxonomies } ) {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Taxonomy' ) }
options={ getTaxonomyOptions() }
value={ taxonomy }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function TemplatePartAdvancedControls( {
/>

<SelectControl
__nextHasNoMarginBottom
label={ __( 'Area' ) }
labelPosition="top"
options={ areaOptions }
Expand All @@ -66,6 +67,7 @@ export function TemplatePartAdvancedControls( {
</>
) }
<SelectControl
__nextHasNoMarginBottom
label={ __( 'HTML element' ) }
options={ [
{
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/video/edit-common-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const VideoSettings = ( { setAttributes, attributes } ) => {
checked={ playsInline }
/>
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Preload' ) }
value={ preload }
onChange={ onChangePreload }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/video/tracks-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
/>
</div>
<SelectControl
__nextHasNoMarginBottom
className="block-library-video-tracks-editor__single-track-editor-kind-select"
options={ KIND_OPTIONS }
value={ kind }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default function PostTemplateForm( { onClose } ) {
</Notice>
) : (
<SelectControl
__nextHasNoMarginBottom
hideLabelFromVision
label={ __( 'Template' ) }
value={ selectedOption?.value ?? '' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
*/
import { useSelect } from '@wordpress/data';
import { useState, useEffect } from '@wordpress/element';
import { SelectControl } from '@wordpress/components';
import {
SelectControl,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
import {
store as blockEditorStore,
Expand Down Expand Up @@ -168,7 +171,7 @@ export default function NavigationInspector() {
}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );

return (
<div className="edit-site-navigation-inspector">
<VStack>
{ hasResolvedNavigationMenus && ! hasNavigationMenus && (
<p className="edit-site-navigation-inspector__empty-msg">
{ __( 'There are no Navigation Menus.' ) }
Expand All @@ -180,6 +183,7 @@ export default function NavigationInspector() {
) }
{ hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (
<SelectControl
__nextHasNoMarginBottom
aria-controls={
// aria-controls should only apply when referenced element is in DOM
hasLoadedInnerBlocks ? navMenuListId : undefined
Expand Down Expand Up @@ -216,6 +220,6 @@ export default function NavigationInspector() {
{ __( 'Navigation Menu is empty.' ) }
</p>
) }
</div>
</VStack>
);
}
4 changes: 4 additions & 0 deletions packages/edit-site/src/components/template-details/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
.edit-site-template-details__group {
margin: 0;
padding: $grid-unit-20;

.edit-site-template-details__area-select {
margin-bottom: $grid-unit-10;
}
}

.edit-site-template-details__group + .edit-site-template-details__group {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default function TemplatePartAreaSelector( { id } ) {

return (
<SelectControl
__nextHasNoMarginBottom
className="edit-site-template-details__area-select"
label={ __( 'Area' ) }
labelPosition="top"
options={ areaOptions }
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/post-author/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function PostAuthorSelect() {

return (
<SelectControl
__nextHasNoMarginBottom
className="post-author-selector"
label={ __( 'Author' ) }
options={ authorOptions }
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/post-format/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default function PostFormat() {
<PostFormatCheck>
<div className="editor-post-format">
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Post Format' ) }
value={ postFormat }
onChange={ ( format ) => onUpdatePostFormat( format ) }
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/post-template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function PostTemplate() {

return (
<SelectControl
__nextHasNoMarginBottom
label={ __( 'Template:' ) }
value={ selectedTemplate }
onChange={ ( templateSlug ) => {
Expand Down
50 changes: 26 additions & 24 deletions packages/widgets/src/blocks/legacy-widget/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,32 @@ function Empty( { attributes: { id, idBase }, setAttributes } ) {
icon={ <BlockIcon icon={ brushIcon } /> }
label={ __( 'Legacy Widget' ) }
>
<WidgetTypeSelector
selectedId={ id ?? idBase }
onSelect={ ( { selectedId, isMulti } ) => {
if ( ! selectedId ) {
setAttributes( {
id: null,
idBase: null,
instance: null,
} );
} else if ( isMulti ) {
setAttributes( {
id: null,
idBase: selectedId,
instance: {},
} );
} else {
setAttributes( {
id: selectedId,
idBase: null,
instance: null,
} );
}
} }
/>
<div className="wp-block-legacy-widget__selector-container">
<WidgetTypeSelector
selectedId={ id ?? idBase }
onSelect={ ( { selectedId, isMulti } ) => {
if ( ! selectedId ) {
setAttributes( {
id: null,
idBase: null,
instance: null,
} );
} else if ( isMulti ) {
setAttributes( {
id: null,
idBase: selectedId,
instance: {},
} );
} else {
setAttributes( {
id: selectedId,
idBase: null,
instance: null,
} );
}
} }
/>
</div>
</Placeholder>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default function WidgetTypeSelector( { selectedId, onSelect } ) {

return (
<SelectControl
__nextHasNoMarginBottom
className="wp-block-legacy-widget__select-widget"
label={ __( 'Select a legacy widget to display:' ) }
value={ selectedId ?? '' }
options={ [
Expand Down
9 changes: 5 additions & 4 deletions packages/widgets/src/blocks/legacy-widget/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,12 @@
}

.wp-block-legacy-widget {
.components-base-control {
.wp-block-legacy-widget__selector-container {
width: 100%;
}
.components-select-control__input {
padding: 0;
font-family: system-ui;

// Replaces margin on BaseControl
.wp-block-legacy-widget__select-widget {
margin-bottom: $grid-unit-10;
}
}

0 comments on commit ac7db75

Please sign in to comment.