Skip to content

Commit

Permalink
TextControl: Fix remaining 40px size violations (#64594)
Browse files Browse the repository at this point in the history
* Fix in DateFormatPicker

* Fix in ImageURLInputUI

* Fix in Button block

* Fix in Form block InputFieldBlock

* Fix in Form block

* Fix in Image block content only mode

* Fix in Navigation block

* Fix in Post Comment block (deprecated)

* Fix in Featured Image block

* Fix in Categories block

* Fix in Title block

* Fix in Social Icons block

* Fix in Template Part block

* Fix in Video block track editor

* Fix in Dataviews Add new view modal

* Fix in Dataviews Rename view modal

* Fix in PostPublishPanel

* Fix in PostSlug component (unused in app)

* Fix in HierarchicalTermSelector

* Fix in ReusableBlockConvertButton (unused in app)

* Move to stricter lint rule

* Update snapshot

Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
  • Loading branch information
3 people authored Aug 19, 2024
1 parent 515d0d9 commit 2ad366b
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 71 deletions.
17 changes: 8 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ module.exports = {
'FormTokenField',
'NumberControl',
'RangeControl',
'TextControl',
'ToggleGroupControl',
].map( ( componentName ) => ( {
// Falsy `__next40pxDefaultSize` without a non-default `size` prop.
Expand All @@ -336,15 +337,13 @@ module.exports = {
'FormFileUpload should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',
},
// Temporary rules until all existing components have the `__next40pxDefaultSize` prop.
...[ 'SelectControl', 'TextControl' ].map(
( componentName ) => ( {
// Not strict. Allows pre-existing __next40pxDefaultSize={ false } usage until they are all manually updated.
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"])):not(:has(JSXAttribute[name.name="size"]))`,
message:
componentName +
' should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',
} )
),
...[ 'SelectControl' ].map( ( componentName ) => ( {
// Not strict. Allows pre-existing __next40pxDefaultSize={ false } usage until they are all manually updated.
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"])):not(:has(JSXAttribute[name.name="size"]))`,
message:
componentName +
' should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',
} ) ),
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ function NonDefaultControls( { format, onChange } ) {
/>
{ isCustom && (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Custom format' ) }
hideLabelFromVision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,14 @@ const ImageURLInputUI = ( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel ?? '' }
onChange={ onSetLinkRel }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link CSS class' ) }
value={ linkClass || '' }
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ function ButtonEdit( props ) {
<InspectorControls group="advanced">
{ isLinkTag && (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel || '' }
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/form-input/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
) }
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Name' ) }
Expand Down
6 changes: 2 additions & 4 deletions packages/block-library/src/form/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
{ submissionMethod !== 'email' && (
<InspectorControls group="advanced">
<SelectControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Method' ) }
options={ [
Expand All @@ -147,8 +146,7 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
) }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Form action' ) }
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,7 @@ export default function Image( {
) }
renderContent={ () => (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
className="wp-block-image__toolbar_content_textarea"
__nextHasNoMarginBottom
label={ __( 'Title attribute' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export default function NavigationMenuNameControl() {

return (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Menu name' ) }
value={ title }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/post-comment/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export default function Edit( { attributes: { commentId }, setAttributes } ) {
) }
>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
value={ commentId }
onChange={ ( val ) =>
Expand All @@ -44,6 +43,7 @@ export default function Edit( { attributes: { commentId }, setAttributes } ) {
/>

<Button
__next40pxDefaultSize
variant="primary"
onClick={ () => {
setAttributes( { commentId: commentIdInput } );
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ export default function PostFeaturedImageEdit( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel }
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/post-terms/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ export default function PostTermsEdit( {
</BlockControls>
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
autoComplete="off"
label={ __( 'Separator' ) }
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/post-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ export default function PostTitleEdit( {
checked={ linkTarget === '_blank' }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel }
Expand Down
6 changes: 2 additions & 4 deletions packages/block-library/src/social-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ const SocialLinkEdit = ( {
<PanelBody title={ __( 'Settings' ) }>
<PanelRow>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Text' ) }
help={ __(
Expand All @@ -157,8 +156,7 @@ const SocialLinkEdit = ( {
</InspectorControls>
<InspectorControls group="advanced">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Link rel' ) }
value={ rel || '' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ export function TemplatePartAdvancedControls( {
{ isEntityAvailable && (
<>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Title' ) }
value={ title }
Expand All @@ -85,8 +84,7 @@ export function TemplatePartAdvancedControls( {
/>

<SelectControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Area' ) }
labelPosition="top"
Expand Down
9 changes: 3 additions & 6 deletions packages/block-library/src/video/tracks-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
</span>
<Grid columns={ 2 } gap={ 4 }>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
/* eslint-disable jsx-a11y/no-autofocus */
autoFocus
Expand All @@ -116,8 +115,7 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
help={ __( 'Title of track' ) }
/>
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
onChange={ ( newSrcLang ) =>
onChange( {
Expand All @@ -132,8 +130,7 @@ function SingleTrackEditor( { track, onChange, onClose, onRemove } ) {
</Grid>
<VStack spacing="8">
<SelectControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
className="block-library-video-tracks-editor__single-track-editor-kind-select"
options={ KIND_OPTIONS }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ function AddNewItemModalContent( { type, setIsAdding } ) {
>
<VStack spacing="5">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ function RenameItemModalContent( { dataviewId, currentTitle, setIsRenaming } ) {
>
<VStack spacing="5">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
Expand Down
12 changes: 8 additions & 4 deletions packages/editor/src/components/post-publish-panel/postpublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const getFuturePostUrl = ( post ) => {
function CopyButton( { text, onCopy, children } ) {
const ref = useCopyToClipboard( text, onCopy );
return (
<Button variant="secondary" ref={ ref }>
<Button __next40pxDefaultSize variant="secondary" ref={ ref }>
{ children }
</Button>
);
Expand Down Expand Up @@ -122,8 +122,7 @@ class PostPublishPanelPostpublish extends Component {
</p>
<div className="post-publish-panel__postpublish-post-address-container">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
className="post-publish-panel__postpublish-post-address"
readOnly
Expand All @@ -147,12 +146,17 @@ class PostPublishPanelPostpublish extends Component {

<div className="post-publish-panel__postpublish-buttons">
{ ! isScheduled && (
<Button variant="primary" href={ link }>
<Button
variant="primary"
href={ link }
__next40pxDefaultSize
>
{ viewPostLabel }
</Button>
) }
<Button
variant={ isScheduled ? 'primary' : 'secondary' }
__next40pxDefaultSize
href={ addLink }
>
{ addNewPostLabel }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is pu
post address
</label>
<input
class="components-text-control__input"
class="components-text-control__input is-next-40px-default-size"
id="inspector-text-control-0"
readonly=""
type="text"
Expand All @@ -132,7 +132,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is pu
class="post-publish-panel__postpublish-post-address__copy-button-wrap"
>
<button
class="components-button is-secondary"
class="components-button is-next-40px-default-size is-secondary"
type="button"
>
Copy
Expand All @@ -143,11 +143,11 @@ exports[`PostPublishPanel should render the post-publish panel if the post is pu
class="post-publish-panel__postpublish-buttons"
>
<a
class="components-button is-primary"
class="components-button is-next-40px-default-size is-primary"
href="https://wordpress.local/sample-page/"
/>
<a
class="components-button is-secondary"
class="components-button is-next-40px-default-size is-secondary"
href="post-new.php?"
/>
</div>
Expand Down Expand Up @@ -312,7 +312,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is sc
post address
</label>
<input
class="components-text-control__input"
class="components-text-control__input is-next-40px-default-size"
id="inspector-text-control-1"
readonly=""
type="text"
Expand All @@ -324,7 +324,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is sc
class="post-publish-panel__postpublish-post-address__copy-button-wrap"
>
<button
class="components-button is-secondary"
class="components-button is-next-40px-default-size is-secondary"
type="button"
>
Copy
Expand All @@ -335,11 +335,11 @@ exports[`PostPublishPanel should render the post-publish panel if the post is sc
class="post-publish-panel__postpublish-buttons"
>
<a
class="components-button is-primary"
class="components-button is-next-40px-default-size is-primary"
href="https://wordpress.local/sample-page/"
/>
<a
class="components-button is-secondary"
class="components-button is-next-40px-default-size is-secondary"
href="post-new.php?"
/>
</div>
Expand Down
3 changes: 1 addition & 2 deletions packages/editor/src/components/post-slug/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ function PostSlugControl() {

return (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Slug' ) }
autoComplete="off"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ export function HierarchicalTermSelector( { slug } ) {
<Flex direction="column" gap="4">
{ showFilter && (
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ filterLabel }
value={ filterValue }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ export default function ReusableBlockConvertButton( {
>
<VStack spacing="5">
<TextControl
// TODO: Switch to `true` (40px size) if possible
__next40pxDefaultSize={ false }
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Name' ) }
value={ title }
Expand Down

0 comments on commit 2ad366b

Please sign in to comment.