Skip to content
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ module.exports = {
'FocalPointPicker',
'RangeControl',
'SearchControl',
'TextControl',
'TextareaControl',
'ToggleGroupControl',
'TreeSelect',
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/form-input/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
) }
<InspectorControls group="advanced">
<TextControl
__nextHasNoMarginBottom

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Testing instructions

In Gutenberg experiments (wp-admin/admin.php?page=gutenberg-experiments), enable the "Form and input blocks" experiment. In the editor, add a Form block. In the block inspector, expand the "Advanced" section at the bottom.

Advanced section with TextControl

autoComplete="off"
label={ __( 'Name' ) }
value={ name }
Expand Down
25 changes: 15 additions & 10 deletions packages/dataviews/src/components/dataform/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Dispatch, SetStateAction } from 'react';
/**
* WordPress dependencies
*/
import { __experimentalVStack as VStack } from '@wordpress/components';
import { useMemo } from '@wordpress/element';

/**
Expand Down Expand Up @@ -37,14 +38,18 @@ export default function DataForm< Item >( {
[ fields, form.visibleFields ]
);

return visibleFields.map( ( field ) => {
return (
<field.Edit
key={ field.id }
data={ data }
field={ field }
onChange={ onChange }
/>
);
} );
return (
<VStack spacing={ 4 }>
{ visibleFields.map( ( field ) => {
return (
<field.Edit
key={ field.id }
data={ data }
field={ field }
onChange={ onChange }
/>
);
} ) }
</VStack>
Comment on lines +41 to +53

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Testing instructions

In Gutenberg experiments (wp-admin/admin.php?page=gutenberg-experiments), enable the "Quick Edit in DataViews" experiment. In the Site Editor, go to Pages (wp-admin/site-editor.php?postType=page) and switch to Table view.

Layout dropdown

Select a page row. Click the "Show quick edit sidebar" button.

Quick Edit button
Before After
Quick Edit, before Quick Edit, after

These changes can also be seen in the Storybook for DataForm.

);
}
2 changes: 2 additions & 0 deletions packages/dataviews/src/field-types/integer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function Edit< Item >( {
value={ value }
options={ elements }
onChange={ onChangeControl }
__next40pxDefaultSize
__nextHasNoMarginBottom
Comment on lines +79 to +80

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the SelectControl in the Data Views Quick Edit.

/>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/dataviews/src/field-types/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function Edit< Item >( {
value={ value ?? '' }
onChange={ onChangeControl }
__next40pxDefaultSize
__nextHasNoMarginBottom

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the TextControl in the Data Views Quick Edit.

/>
);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/add-new-post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ export default function AddNewPostModal( { postType, onSave, onClose } ) {
size="small"
>
<form onSubmit={ createPost }>
<VStack spacing={ 3 }>
<VStack spacing={ 4 }>
<TextControl
__next40pxDefaultSize
__nextHasNoMarginBottom
Comment on lines +98 to +101

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Testing instructions

Go to the Pages view in Site Editor (wp-admin/site-editor.php?postType=page), and click the Add New Page button.

Before After
Add new page modal, before Add new page modal, after

@WordPress/gutenberg-design I'm seeing some inconsistency in the spacing before the CTA button in contexts like this. The Figma specs it as 24px — should I follow that everywhere? Also, would the spacing be different in a non-Modal context like Data Views Quick Edit, or a small block toolbar popover like the Language formatter?

Data Views Quick Edit Language format popover

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jameskoster @mattrwalker this would be a great opportunity to fix up the modal component, bring it in sync. What's the right value?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there could be a case for a dedicated ModalFooter (or similar) component that handles this. It should:

  • Align the buttons (right)
  • Set spacing
  • Set the button order (primary always right-most)
  • Limit to two buttons
  • Handle small-screen behavior (make buttons full width and/or stack)

But that's probably part of a much broader update to Modal. Until we have a clear design for that I don't suppose the spacing matters too much – I'd probably just aim for what exists on trunk.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, if we don't have spec'ed values yet, I'm going to go with the path of least resistance as long as it's in the general vicinity of what's correct. In a lot of cases, that's going to be a space equidistant between all the control gaps (i.e. throw them all in a single VStack). This is going to be easier to deal with later once we decide on an official value.

label={ __( 'Title' ) }
onChange={ setTitle }
placeholder={ __( 'No title' ) }
Expand Down
29 changes: 18 additions & 11 deletions packages/edit-site/src/components/post-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { __ } from '@wordpress/i18n';
import { DataForm, isItemValid } from '@wordpress/dataviews';
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
import { store as coreDataStore } from '@wordpress/core-data';
import { Button } from '@wordpress/components';
import {
Button,
FlexItem,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { useState, useMemo } from '@wordpress/element';

/**
Expand Down Expand Up @@ -71,22 +75,25 @@ function PostEditForm( { postType, postId } ) {

const isUpdateDisabled = ! isItemValid( itemWithEdits, fields, form );
return (
<form onSubmit={ onSubmit }>
<VStack as="form" onSubmit={ onSubmit } spacing={ 4 }>
<DataForm
data={ itemWithEdits }
fields={ fields }
form={ form }
onChange={ setEdits }
/>
<Button
variant="primary"
type="submit"
accessibleWhenDisabled
disabled={ isUpdateDisabled }
>
{ __( 'Update' ) }
</Button>
</form>
<FlexItem>
<Button
variant="primary"
type="submit"
accessibleWhenDisabled
disabled={ isUpdateDisabled }
__next40pxDefaultSize
>
{ __( 'Update' ) }
</Button>
</FlexItem>
</VStack>
Comment on lines +78 to +96

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the form wrapping the Data Views Quick Edit.

);
}

Expand Down
12 changes: 10 additions & 2 deletions packages/format-library/src/language/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Button,
Popover,
__experimentalHStack as HStack,
__experimentalVStack as VStack,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Testing instructions

In the editor, add a Paragraph block and select some of the text. Select "Language" from the block toolbar.

Screenshot 2024-08-03 at 4 09 04
Before After
Language popover, before Language popover, after

} from '@wordpress/components';
import { useState } from '@wordpress/element';
import { applyFormat, removeFormat, useAnchor } from '@wordpress/rich-text';
Expand Down Expand Up @@ -78,7 +79,9 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
anchor={ popoverAnchor }
onClose={ onClose }
>
<form
<VStack
as="form"
spacing={ 4 }
className="block-editor-format-toolbar__language-container-content"
onSubmit={ ( event ) => {
event.preventDefault();
Expand All @@ -95,6 +98,8 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
} }
>
<TextControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ title }
value={ lang }
onChange={ ( val ) => setLang( val ) }
Expand All @@ -103,6 +108,8 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
) }
/>
<SelectControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Text direction' ) }
value={ dir }
options={ [
Expand All @@ -119,12 +126,13 @@ function InlineLanguageUI( { value, contentRef, onChange, onClose } ) {
/>
<HStack alignment="right">
<Button
__next40pxDefaultSize
variant="primary"
type="submit"
text={ __( 'Apply' ) }
/>
</HStack>
</form>
</VStack>
</Popover>
);
}