Repository navigation
Design System: Add guidelines for save and submit UX #74811
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c148470
Adding the markdown file
fcoveram 0bec358
make the file work on storybook
fcoveram 6cd1b04
Add a live preview
fcoveram 1c8f805
Update storybook/stories/design-system/patterns/Save & submit UX.mdx
fcoveram b1c7103
Rename Save & submit UX.mdx to lowercase kebab-case
fcoveram 33239a2
Merge branch 'trunk' into add/save-submit-ux
mirka b6214fb
Normalize formatting
mirka cf4f43d
Fix overscoped story matcher
mirka d83fd67
Update storybook/stories/design-system/patterns/save-and-submit.mdx
jameskoster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
storybook/stories/design-system/patterns/save-and-submit.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { Canvas, Meta } from '@storybook/addon-docs/blocks'; | ||
| import * as SaveSubmitStories from './save-and-submit.story'; | ||
|
|
||
| <Meta of={ SaveSubmitStories } /> | ||
|
|
||
| # Save & Submit | ||
|
|
||
| Guidelines for form submission and saving settings. | ||
|
|
||
| ## Feedback | ||
|
|
||
| The following feedback patterns help users interpret save and submit results. | ||
|
|
||
| ### Saving | ||
|
|
||
| - While saving the button state switches to busy. | ||
| - A [Snackbar](https://wordpress.github.io/gutenberg/?path=/docs/components-snackbar--docs) confirms a successful save. | ||
|
|
||
| <Canvas of={ SaveSubmitStories.SaveFormLayoutCard } /> | ||
|
|
||
| ### No unsaved changes | ||
|
|
||
| When all changes are saved the Save button is disabled and reveals a “No unsaved changes” tooltip on hover or focus. | ||
|
|
||
| ### Invalid fields | ||
|
|
||
| If the save or submit fails due to user error (an invalid field or a required field is omitted) then the page scrolls with animation to the first invalid field, which shows a validation error message. | ||
|
|
||
| ### Failed save | ||
|
|
||
| If the save process fails for any reason the user is notified via `ConfirmDialog`. | ||
|
|
||
| ### Auto-save | ||
|
|
||
| - Auto-saving is restricted to `ToggleControl` fields. | ||
| - Follows the same feedback conventions as other save methods. | ||
| - It is preferable to use a toggle instead of a checkbox for turning features on and off. The exception would be if the checkbox is part of a form with other fields that also need to be updated at the same time. | ||
| - Keep labels short. Use the description under the toggle or in the card title to provide more context. | ||
| - Lead labels with a verb like “Use, Allow, Show,” or “Enable”. | ||
69 changes: 69 additions & 0 deletions
69
storybook/stories/design-system/patterns/save-and-submit.story.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
| import { Button, Card, CardBody } from '@wordpress/components'; | ||
| import { DataForm } from '@wordpress/dataviews'; | ||
| import { useState } from '@wordpress/element'; | ||
|
|
||
| const LayoutCardSaveExample = () => { | ||
| const [ data, setData ] = useState( { title: '' } ); | ||
|
|
||
| return ( | ||
| <div style={ { maxWidth: '480px' } }> | ||
| <Card | ||
| size={ { | ||
| blockStart: 'medium', | ||
| blockEnd: 'medium', | ||
| inlineStart: 'medium', | ||
| inlineEnd: 'medium', | ||
| } } | ||
| > | ||
| <CardBody> | ||
| <DataForm | ||
| data={ data } | ||
| fields={ [ | ||
| { | ||
| id: 'title', | ||
| label: 'Title', | ||
| type: 'text', | ||
| }, | ||
| ] } | ||
| form={ { | ||
| layout: { type: 'regular' }, | ||
| fields: [ 'title' ], | ||
| } } | ||
| onChange={ ( edits ) => | ||
| setData( ( previous ) => ( { | ||
| ...previous, | ||
| ...edits, | ||
| } ) ) | ||
| } | ||
| /> | ||
| <Button | ||
| variant="primary" | ||
| isBusy | ||
| style={ { marginTop: '16px' } } | ||
| > | ||
| Save | ||
| </Button> | ||
| </CardBody> | ||
| </Card> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const meta: Meta< typeof LayoutCardSaveExample > = { | ||
| title: 'Design System/Patterns/Save & Submit', | ||
| component: LayoutCardSaveExample, | ||
| parameters: { | ||
| controls: { disable: true }, | ||
| }, | ||
| tags: [ '!dev' /* Hide individual story pages from sidebar */ ], | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj< typeof LayoutCardSaveExample >; | ||
|
|
||
| export const SaveFormLayoutCard: Story = { | ||
| name: 'Save form layout card', | ||
| render: () => <LayoutCardSaveExample />, | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.