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 2/2) #47158

Merged
merged 5 commits into from
Jan 27, 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
47 changes: 23 additions & 24 deletions packages/block-editor/src/components/date-format-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
ExternalLink,
VisuallyHidden,
CustomSelectControl,
BaseControl,
ToggleControl,
__experimentalVStack as VStack,
} from '@wordpress/components';

// So that we can illustrate the different formats in the dropdown properly,
Expand Down Expand Up @@ -110,31 +110,30 @@ function NonDefaultControls( { format, onChange } ) {
);

return (
<>
<BaseControl className="block-editor-date-format-picker__custom-format-select-control">
<CustomSelectControl
__nextUnconstrainedWidth
label={ __( 'Choose a format' ) }
options={ [ ...suggestedOptions, customOption ] }
value={
isCustom
? customOption
: suggestedOptions.find(
( option ) => option.format === format
) ?? customOption
<VStack>
<CustomSelectControl
__nextUnconstrainedWidth
label={ __( 'Choose a format' ) }
options={ [ ...suggestedOptions, customOption ] }
value={
isCustom
? customOption
: suggestedOptions.find(
( option ) => option.format === format
) ?? customOption
}
onChange={ ( { selectedItem } ) => {
if ( selectedItem === customOption ) {
setIsCustom( true );
} else {
setIsCustom( false );
onChange( selectedItem.format );
}
onChange={ ( { selectedItem } ) => {
if ( selectedItem === customOption ) {
setIsCustom( true );
} else {
setIsCustom( false );
onChange( selectedItem.format );
}
} }
/>
</BaseControl>
} }
/>
{ isCustom && (
<TextControl
__nextHasNoMarginBottom
label={ __( 'Custom format' ) }
hideLabelFromVision
help={ createInterpolateElement(
Expand All @@ -155,6 +154,6 @@ function NonDefaultControls( { format, onChange } ) {
onChange={ ( value ) => onChange( value ) }
/>
) }
</>
</VStack>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
display: block;
}

.block-editor-date-format-picker__custom-format-select-control {
&.components-base-control {
margin-bottom: 0;
}
}
Comment on lines -10 to -14
Copy link
Member

Choose a reason for hiding this comment

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

It looks the BaseControl here is used merely for its implicit 8px margin-bottom properties (which is exactly the thing we're deprecating 😄). I think we can remove the BaseControl altogether and just wrap the CustomSelectControl and TextControl in a VStack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great find! I'll keep an eye out for stuff like this in the future


.block-editor-date-format-picker__custom-format-select-control__custom-option {
border-top: 1px solid $gray-300;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TextControl,
SVG,
Path,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { link as linkIcon, close } from '@wordpress/icons';

Expand Down Expand Up @@ -209,23 +210,26 @@ const ImageURLInputUI = ( {
};

const advancedOptions = (
<>
<VStack spacing="3">
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Open in new tab' ) }
onChange={ onSetNewTab }
checked={ linkTarget === '_blank' }
/>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel ?? '' }
onChange={ onSetLinkRel }
/>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Link CSS Class' ) }
value={ linkClass || '' }
onChange={ onSetLinkClass }
/>
</>
</VStack>
);

const linkEditorValue = urlInput !== null ? urlInput : url;
Expand Down
10 changes: 0 additions & 10 deletions packages/block-editor/src/components/url-popover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
transform: rotate(180deg);
}
}
.block-editor-url-popover__input-container {
.components-base-control:last-child,
.components-base-control:last-child .components-base-control__field {
margin-bottom: 0;
}
}

.block-editor-url-popover__settings {
display: block;
Expand All @@ -68,10 +62,6 @@
.block-editor-url-popover__link-editor,
.block-editor-url-popover__link-viewer {
display: flex;

.block-editor-url-input .components-base-control__field {
margin-bottom: 0;
}
}

.block-editor-url-popover__link-viewer-url {
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/post-comment/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function Edit( { attributes: { commentId }, setAttributes } ) {
) }
>
<TextControl
__nextHasNoMarginBottom
value={ commentId }
onChange={ ( val ) =>
setCommentIdInput( parseInt( val ) )
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/social-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const SocialLinkEdit = ( {
>
<PanelRow>
<TextControl
__nextHasNoMarginBottom
label={ __( 'Link label' ) }
help={ __(
'Briefly describe the link to help screen reader users.'
Expand All @@ -116,6 +117,7 @@ const SocialLinkEdit = ( {
</InspectorControls>
<InspectorControls __experimentalGroup="advanced">
<TextControl
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel || '' }
onChange={ ( value ) => setAttributes( { rel: value } ) }
Expand Down
26 changes: 12 additions & 14 deletions packages/block-library/src/template-part/edit/title-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { useState } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import {
TextControl,
Flex,
FlexItem,
Button,
Modal,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
} from '@wordpress/components';

export default function TitleModal( { areaLabel, onClose, onSubmit } ) {
Expand All @@ -33,16 +33,14 @@ export default function TitleModal( { areaLabel, onClose, onSubmit } ) {
onRequestClose={ onClose }
>
<form onSubmit={ submitForCreation }>
<TextControl
label={ __( 'Name' ) }
value={ title }
onChange={ setTitle }
/>
<Flex
className="wp-block-template-part__placeholder-create-new__title-form-actions"
justify="flex-end"
>
<FlexItem>
<VStack spacing="5">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added VStack with spacing to be consistent with other modals, as the spacing between the input and button wasn't the same as other modals in the site editor.

<TextControl
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
onChange={ setTitle }
/>
<HStack justify="right">
<Button
variant="primary"
type="submit"
Expand All @@ -51,8 +49,8 @@ export default function TitleModal( { areaLabel, onClose, onSubmit } ) {
>
{ __( 'Create' ) }
</Button>
</FlexItem>
</Flex>
</HStack>
</VStack>
</form>
</Modal>
);
Expand Down
35 changes: 0 additions & 35 deletions packages/block-library/src/video/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,36 +71,15 @@
}

.block-library-video-tracks-editor__track-list-track {
display: flex;
place-content: space-between;
align-items: baseline;
padding-left: $grid-unit-15;
}

.block-library-video-tracks-editor__single-track-editor-label-language {
display: flex;
margin-top: $grid-unit-15;
& > .components-base-control {
width: 50%;
}
& > .components-base-control:first-child {
margin-right: $grid-unit-20;
}
}

.block-library-video-tracks-editor__single-track-editor-kind-select {
max-width: 240px;
}

.block-library-video-tracks-editor__single-track-editor-buttons-container {
display: flex;
place-content: space-between;
margin-top: $grid-unit-40;
}

.block-library-video-tracks-editor__single-track-editor-edit-track-label {
margin-top: $grid-unit-05;
margin-bottom: $grid-unit-15;
color: $gray-700;
text-transform: uppercase;
font-size: 11px;
Expand All @@ -126,17 +105,3 @@
padding: $grid-unit-15;
}

.block-library-video-tracks-editor__single-track-editor .components-base-control {
.components-base-control__label {
margin-bottom: $grid-unit-05;
}
.components-base-control__field {
margin-bottom: $grid-unit-15;
}
.components-text-control__input {
margin-left: 0;
}
.components-input-control__label {
margin-bottom: $grid-unit-05;
}
}
Loading