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

TextControl: remove margin overrides and add new opt-in prop (pt 1/2) #47157

Merged
merged 4 commits into from
Jan 17, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ function LinkControl( {
>
{ showTextControl && (
<TextControl
__nextHasNoMarginBottom
ref={ textInputRef }
className="block-editor-link-control__field block-editor-link-control__text-content"
label="Text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ $preview-image-height: 140px;
> .components-base-control__field {
display: flex;
align-items: center;
margin: 0;
}

.components-base-control__label {
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const withInspectorControl = createHigherOrderComponent(
const isWeb = Platform.OS === 'web';
const textControl = (
<TextControl
__nextHasNoMarginBottom
className="html-anchor-control"
label={ __( 'HTML anchor' ) }
help={
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/custom-class-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const withInspectorControl = createHigherOrderComponent(
<BlockEdit { ...props } />
<InspectorControls __experimentalGroup="advanced">
<TextControl
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Additional CSS class(es)' ) }
value={ props.attributes.className || '' }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export default function ReusableBlockEdit( { attributes: { ref }, clientId } ) {
<InspectorControls>
<PanelBody>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
onChange={ setTitle }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ function ButtonEdit( props ) {
</InspectorControls>
<InspectorControls __experimentalGroup="advanced">
<TextControl
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel || '' }
onChange={ ( newRel ) => setAttributes( { rel: newRel } ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ export default function Image( {
</InspectorControls>
<InspectorControls __experimentalGroup="advanced">
<TextControl
__nextHasNoMarginBottom
label={ __( 'Title attribute' ) }
value={ title || '' }
onChange={ onSetTitle }
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 @@ -9,6 +9,7 @@ const OrderedListSettings = ( { setAttributes, reversed, start } ) => (
<InspectorControls>
<PanelBody title={ __( 'Ordered list settings' ) }>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Start value' ) }
type="number"
onChange={ ( value ) => {
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ export default function NavigationLinkEdit( {
<InspectorControls>
<PanelBody title={ __( 'Link settings' ) }>
<TextControl
__nextHasNoMarginBottom
value={ label ? stripHTML( label ) : '' }
onChange={ ( labelValue ) => {
setAttributes( { label: labelValue } );
Expand All @@ -440,6 +441,7 @@ export default function NavigationLinkEdit( {
autoComplete="off"
/>
<TextControl
__nextHasNoMarginBottom
value={ url || '' }
onChange={ ( urlValue ) => {
updateAttributes(
Expand All @@ -463,6 +465,7 @@ export default function NavigationLinkEdit( {
) }
/>
<TextControl
__nextHasNoMarginBottom
value={ title || '' }
onChange={ ( titleValue ) => {
setAttributes( { title: titleValue } );
Expand All @@ -471,6 +474,7 @@ export default function NavigationLinkEdit( {
autoComplete="off"
/>
<TextControl
__nextHasNoMarginBottom
value={ rel || '' }
onChange={ ( relValue ) => {
setAttributes( { rel: relValue } );
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/navigation-submenu/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ export default function NavigationSubmenuEdit( {
<InspectorControls>
<PanelBody title={ __( 'Link settings' ) }>
<TextControl
__nextHasNoMarginBottom
value={ label || '' }
onChange={ ( labelValue ) => {
setAttributes( { label: labelValue } );
Expand All @@ -401,6 +402,7 @@ export default function NavigationSubmenuEdit( {
autoComplete="off"
/>
<TextControl
__nextHasNoMarginBottom
value={ url || '' }
onChange={ ( urlValue ) => {
setAttributes( { url: urlValue } );
Expand All @@ -422,6 +424,7 @@ export default function NavigationSubmenuEdit( {
) }
/>
<TextControl
__nextHasNoMarginBottom
value={ title || '' }
onChange={ ( titleValue ) => {
setAttributes( { title: titleValue } );
Expand All @@ -430,6 +433,7 @@ export default function NavigationSubmenuEdit( {
autoComplete="off"
/>
<TextControl
__nextHasNoMarginBottom
value={ rel || '' }
onChange={ ( relValue ) => {
setAttributes( { rel: relValue } );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function NavigationMenuNameControl() {

return (
<TextControl
__nextHasNoMarginBottom
label={ __( 'Menu name' ) }
value={ title }
onChange={ updateTitle }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function PostFeaturedImageDisplay( {
checked={ linkTarget === '_blank' }
/>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel }
onChange={ ( newRel ) =>
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-terms/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default function PostTermsEdit( {
</BlockControls>
<InspectorControls __experimentalGroup="advanced">
<TextControl
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Separator' ) }
value={ separator || '' }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default function PostTitleEdit( {
checked={ linkTarget === '_blank' }
/>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel }
onChange={ ( newRel ) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export default function QueryInspectorControls( {
onDeselect={ () => setQuerySearch( '' ) }
>
<TextControl
__nextHasNoMarginBottom
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To note, there is an additional margin override, but it appears to be coming from ToolsPanel:

label={ __( 'Keyword' ) }
value={ querySearch }
onChange={ setQuerySearch }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/table/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ function TableEdit( {
onSubmit={ onCreateTable }
>
<TextControl
__nextHasNoMarginBottom
type="number"
label={ __( 'Column count' ) }
value={ initialColumnCount }
Expand All @@ -547,6 +548,7 @@ function TableEdit( {
className="blocks-table__placeholder-input"
/>
<TextControl
__nextHasNoMarginBottom
type="number"
label={ __( 'Row count' ) }
value={ initialRowCount }
Expand Down
6 changes: 0 additions & 6 deletions packages/block-library/src/table/editor.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.wp-block-table {

// Remove default <figure> style.
margin: 0;

Expand Down Expand Up @@ -82,9 +81,4 @@
input {
height: $button-size;
}


.components-base-control__field {
margin-bottom: 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function TemplatePartAdvancedControls( {
{ isEntityAvailable && (
<>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Title' ) }
value={ title }
onChange={ ( value ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function EditTemplateTitle() {
return (
<div className="edit-site-template-details__group">
<TextControl
__nextHasNoMarginBottom
label={ __( 'Title' ) }
value={ forceEmpty ? '' : templateTitle }
help={ __(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@
.edit-post-template-top-area__popover {
.components-popover__content {
min-width: 280px;

> div {
padding: 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't affecting the popover so it appeared to be broken (shared screenshots in testing steps).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Unrelated to this PR, but just to note some clean ways to resolve these common .components-popover__content hacks in Dropdown:

  • padding: 0 — We recently introduced a <DropdownContentWrapper> that can be used to remove the default padding.
  • min-width — This style can easily be moved to the element in renderContent, thus avoiding a CSS hack.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for sharing!

}
padding: 0;
}

.edit-site-template-details__group {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { useState } from '@wordpress/element';
import { serialize, createBlock } from '@wordpress/blocks';
import {
Modal,
Flex,
FlexItem,
TextControl,
Button,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { cleanForSlug } from '@wordpress/url';
Expand Down Expand Up @@ -108,28 +108,23 @@ export default function PostTemplateCreateModal( { onClose } ) {
className="edit-post-post-template__create-form"
onSubmit={ submit }
>
<Flex align="flex-start" gap={ 8 }>
<FlexItem>
<TextControl
label={ __( 'Name' ) }
value={ title }
onChange={ setTitle }
placeholder={ DEFAULT_TITLE }
disabled={ isBusy }
help={ __(
'Describe the template, e.g. "Post with sidebar". Custom templates can be applied to any post or page.'
) }
/>
</FlexItem>
</Flex>

<Flex justify="flex-end" expanded={ false }>
<FlexItem>
<VStack spacing="3">
<TextControl
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
onChange={ setTitle }
placeholder={ DEFAULT_TITLE }
disabled={ isBusy }
help={ __(
'Describe the template, e.g. "Post with sidebar". Custom templates can be applied to any post or page.'
) }
/>
<HStack justify="right">
<Button variant="tertiary" onClick={ cancel }>
{ __( 'Cancel' ) }
</Button>
</FlexItem>
<FlexItem>

<Button
variant="primary"
type="submit"
Expand All @@ -138,8 +133,8 @@ export default function PostTemplateCreateModal( { onClose } ) {
>
{ __( 'Create' ) }
</Button>
</FlexItem>
</Flex>
</HStack>
</VStack>
</form>
</Modal>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import {
Button,
Flex,
FlexItem,
Modal,
TextControl,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
} from '@wordpress/components';

/**
Expand Down Expand Up @@ -60,27 +60,22 @@ function AddCustomGenericTemplateModal( {
>
{ isCreatingTemplate && <TemplateActionsLoadingScreen /> }
<form onSubmit={ onCreateTemplate }>
<Flex align="flex-start" gap={ 8 }>
<FlexItem>
<TextControl
label={ __( 'Name' ) }
value={ title }
onChange={ setTitle }
placeholder={ defaultTitle }
disabled={ isBusy }
help={ __(
'Describe the template, e.g. "Post with sidebar".'
) }
/>
</FlexItem>
</Flex>

<Flex
className="edit-site-custom-generic-template__modal-actions"
justify="flex-end"
expanded={ false }
>
<FlexItem>
<VStack spacing={ 6 }>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
onChange={ setTitle }
placeholder={ defaultTitle }
disabled={ isBusy }
help={ __(
'Describe the template, e.g. "Post with sidebar".'
) }
/>
<HStack
className="edit-site-custom-generic-template__modal-actions"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to remove the margin-top on .edit-site-custom-generic-template__modal-actions and merge that extra whitespace into the VStack spacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely! Nice catch. :)

justify="right"
>
<Button
variant="tertiary"
onClick={ () => {
Expand All @@ -89,8 +84,6 @@ function AddCustomGenericTemplateModal( {
>
{ __( 'Cancel' ) }
</Button>
</FlexItem>
<FlexItem>
<Button
variant="primary"
type="submit"
Expand All @@ -99,8 +92,8 @@ function AddCustomGenericTemplateModal( {
>
{ __( 'Create' ) }
</Button>
</FlexItem>
</Flex>
</HStack>
</VStack>
</form>
</Modal>
);
Expand Down
4 changes: 0 additions & 4 deletions packages/edit-site/src/components/add-new-template/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@
}
}

.edit-site-custom-generic-template__modal-actions {
margin-top: $grid-unit-15;
}

.edit-site-template-actions-loading-screen-modal {
backdrop-filter: none;
background-color: transparent;
Expand Down
Loading