Skip to content

Commit

Permalink
ToggleControl: remove margin overrides and add opt-in prop
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Feb 8, 2023
1 parent 6b75d2e commit c47da73
Show file tree
Hide file tree
Showing 48 changed files with 89 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/components/block-lock/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
</ul>
{ hasTemplateLock && (
<ToggleControl
__nextHasNoMarginBottom
className="block-editor-block-lock-modal__template-lock"
label={ __( 'Apply to all blocks inside' ) }
checked={ applyTemplateLock }
Expand Down
9 changes: 0 additions & 9 deletions packages/block-editor/src/components/block-lock/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
.components-checkbox-control__label {
font-weight: 600;
}

.components-base-control__field {
align-items: center;
display: flex;
}
}
.block-editor-block-lock-modal__checklist-item {
display: flex;
Expand All @@ -48,10 +43,6 @@
border-top: $border-width solid $gray-300;
margin-top: $grid-unit-20;
padding: $grid-unit-15 0;

.components-base-control__field {
margin: 0;
}
}

.block-editor-block-lock-modal__actions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const LinkControlSettings = ( { value, onChange = noop, settings } ) => {

const theSettings = settings.map( ( setting ) => (
<ToggleControl
__nextHasNoMarginBottom
className="block-editor-link-control__setting"
key={ setting.id }
label={ setting.title }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function ResponsiveBlockControl( props ) {

<div className="block-editor-responsive-block-control__inner">
<ToggleControl
__nextHasNoMarginBottom
className="block-editor-responsive-block-control__toggle"
label={ toggleControlLabel }
checked={ ! isResponsive }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const TestURLPopover = () => {
onClose={ close }
renderSettings={ () => (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
onChange={ setTarget }
/>
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
{ showInheritToggle && (
<>
<ToggleControl
__nextHasNoMarginBottom
className="block-editor-hooks__toggle-control"
label={ __( 'Inner blocks use content width' ) }
checked={
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/layouts/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ function FlexWrapControl( { layout, onChange } ) {
const { flexWrap = 'wrap' } = layout;
return (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Allow to wrap to multiple lines' ) }
onChange={ ( value ) => {
onChange( {
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/archives/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display as dropdown' ) }
checked={ displayAsDropdown }
onChange={ () =>
Expand All @@ -29,6 +30,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
/>
{ displayAsDropdown && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show label' ) }
checked={ showLabel }
onChange={ () =>
Expand All @@ -39,6 +41,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
/>
) }
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show post counts' ) }
checked={ showPostCounts }
onChange={ () =>
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/audio/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,14 @@ function AudioEdit( {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Autoplay' ) }
onChange={ toggleAttribute( 'autoplay' ) }
checked={ autoplay }
help={ getAutoplayHelp }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Loop' ) }
onChange={ toggleAttribute( 'loop' ) }
checked={ loop }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/avatar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const AvatarInspectorControls = ( {
value={ attributes?.size }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Link to user profile' ) }
onChange={ () =>
setAttributes( { isLink: ! attributes.isLink } )
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/categories/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,32 @@ export default function CategoriesEdit( {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display as dropdown' ) }
checked={ displayAsDropdown }
onChange={ toggleAttribute( 'displayAsDropdown' ) }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show post counts' ) }
checked={ showPostCounts }
onChange={ toggleAttribute( 'showPostCounts' ) }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show only top level categories' ) }
checked={ showOnlyTopLevel }
onChange={ toggleAttribute( 'showOnlyTopLevel' ) }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show empty categories' ) }
checked={ showEmpty }
onChange={ toggleAttribute( 'showEmpty' ) }
/>
{ ! showOnlyTopLevel && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show hierarchy' ) }
checked={ showHierarchy }
onChange={ toggleAttribute( 'showHierarchy' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function ColumnsEditContainer( {
</Notice>
) }
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Stack on mobile' ) }
checked={ isStackedOnMobile }
onChange={ () =>
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/comment-author-name/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ export default function Edit( {
<InspectorControls>
<PanelBody title={ __( 'Link settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Link to authors URL' ) }
onChange={ () => setAttributes( { isLink: ! isLink } ) }
checked={ isLink }
/>
{ isLink && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
onChange={ ( value ) =>
setAttributes( {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/comment-date/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default function Edit( {
}
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Link to comment' ) }
onChange={ () => setAttributes( { isLink: ! isLink } ) }
checked={ isLink }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/comment-edit-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function Edit( {
<InspectorControls>
<PanelBody title={ __( 'Link settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
onChange={ ( value ) =>
setAttributes( {
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/comments-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ export default function Edit( {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show post title' ) }
checked={ showPostTitle }
onChange={ ( value ) =>
setAttributes( { showPostTitle: value } )
}
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show comments count' ) }
checked={ showCommentsCount }
onChange={ ( value ) =>
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/cover/edit/inspector-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ export default function CoverInspectorControls( {
{ isImageBackground && (
<>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Fixed background' ) }
checked={ hasParallax }
onChange={ toggleParallax }
/>

<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Repeated background' ) }
checked={ isRepeated }
onChange={ toggleIsRepeated }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/embed/embed-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const EmbedControls = ( {
className="blocks-responsive"
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Resize for smaller devices' ) }
checked={ allowResponsive }
help={ getResponsiveHelp }
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/file/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function FileBlockInspector( {
{ href.endsWith( '.pdf' ) && (
<PanelBody title={ __( 'PDF settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show inline embed' ) }
help={
displayPreview
Expand Down Expand Up @@ -78,11 +79,13 @@ export default function FileBlockInspector( {
onChange={ changeLinkDestinationOption }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
checked={ openInNewWindow }
onChange={ changeOpenInNewWindow }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show download button' ) }
checked={ showDownloadButton }
onChange={ changeShowDownloadButton }
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 @@ -565,6 +565,7 @@ function GalleryEdit( props ) {
/>
) }
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Crop images' ) }
checked={ !! imageCrop }
onChange={ toggleImageCrop }
Expand All @@ -580,6 +581,7 @@ function GalleryEdit( props ) {
/>
{ hasLinkTo && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
checked={ linkTarget === '_blank' }
onChange={ toggleOpenInNewTab }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/gallery/v1/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ function GalleryEdit( props ) {
/>
) }
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Crop images' ) }
checked={ !! imageCrop }
onChange={ toggleImageCrop }
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/latest-comments/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ export default function LatestComments( { attributes, setAttributes } ) {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display avatar' ) }
checked={ displayAvatar }
onChange={ () =>
setAttributes( { displayAvatar: ! displayAvatar } )
}
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display date' ) }
checked={ displayDate }
onChange={ () =>
setAttributes( { displayDate: ! displayDate } )
}
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display excerpt' ) }
checked={ displayExcerpt }
onChange={ () =>
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,15 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {

<PanelBody title={ __( 'Post meta settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display author name' ) }
checked={ displayAuthor }
onChange={ ( value ) =>
setAttributes( { displayAuthor: value } )
}
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display post date' ) }
checked={ displayPostDate }
onChange={ ( value ) =>
Expand All @@ -264,6 +266,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {

<PanelBody title={ __( 'Featured image settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display featured image' ) }
checked={ displayFeaturedImage }
onChange={ ( value ) =>
Expand Down Expand Up @@ -315,6 +318,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
/>
</BaseControl>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Add link to featured image' ) }
checked={ addLinkToFeaturedImage }
onChange={ ( value ) =>
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/list/ordered-list-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const OrderedListSettings = ( { setAttributes, reversed, start } ) => (
step="1"
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Reverse list numbering' ) }
checked={ reversed || false }
onChange={ ( value ) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/loginout/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function LoginOutEdit( { attributes, setAttributes } ) {
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Display login as form' ) }
checked={ displayLoginAsForm }
onChange={ () =>
Expand All @@ -22,6 +23,7 @@ export default function LoginOutEdit( { attributes, setAttributes } ) {
}
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Redirect to current URL' ) }
checked={ redirectToCurrent }
onChange={ () =>
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/media-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes, clientId } ) {
const mediaTextGeneralSettings = (
<PanelBody title={ __( 'Settings' ) }>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Stack on mobile' ) }
checked={ isStackedOnMobile }
onChange={ () =>
Expand All @@ -253,6 +254,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes, clientId } ) {
/>
{ mediaType === 'image' && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Crop image to fill entire column' ) }
checked={ imageFill }
onChange={ () =>
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/more/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function MoreEdit( {
<InspectorControls>
<PanelBody>
<ToggleControl
__nextHasNoMarginBottom
label={ __(
'Hide the excerpt on the full content page'
) }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ function Navigation( {
<>
<h3>{ __( 'Submenus' ) }</h3>
<ToggleControl
__nextHasNoMarginBottom
checked={ openSubmenusOnClick }
onChange={ ( value ) => {
setAttributes( {
Expand All @@ -611,6 +612,7 @@ function Navigation( {
/>

<ToggleControl
__nextHasNoMarginBottom
checked={ showSubmenuIcon }
onChange={ ( value ) => {
setAttributes( {
Expand Down
Loading

0 comments on commit c47da73

Please sign in to comment.