Skip to content

Commit 15ee105

Browse files
authored
Merge pull request #3594 from Shopify/dc-add-more-docs
Add Best practices to more Polaris docs
2 parents ff974a4 + 6a40f48 commit 15ee105

File tree

27 files changed

+499
-5
lines changed

27 files changed

+499
-5
lines changed

packages/ui-extensions/src/surfaces/admin/components/Avatar/Avatar.doc.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,35 @@ const data: AdminReferenceEntityTemplateSchema = {
55
...sharedContent,
66
thumbnail: '/assets/templated-apis-screenshots/admin/components/avatar.png',
77
isVisualComponent: true,
8+
subSections: [
9+
{
10+
title: 'Useful for',
11+
type: 'Generic' as const,
12+
anchorLink: 'useful-for',
13+
sectionContent: `- Identifying individuals or businesses
14+
- Representing merchants, customers, or other entities visually
15+
- Seeing visual indicators of people or businesses in lists, tables, or cards`,
16+
},
17+
{
18+
title: 'Best practices',
19+
type: 'Generic' as const,
20+
anchorLink: 'best-practices',
21+
sectionContent: `- \`small-200\`: use in tightly condensed layouts
22+
- \`small\`: use when the base size is too big for the layout, or when the avatar has less importance
23+
- \`base\`: use as the default size
24+
- \`large\`: use when an avatar is a focal point, such as on a single customer card
25+
- \`large-200\`: use when extra emphasis is required`,
26+
},
27+
{
28+
title: 'Content guidelines',
29+
type: 'Generic' as const,
30+
anchorLink: 'content-guidelines',
31+
sectionContent: `For avatars, we recommend using a format that describes what will show in the image:
32+
- alt="Person's name" if avatar represents a person
33+
- alt="Business's name" if avatar represents a business
34+
- alt="" if the name appears next to the avatar as text`,
35+
},
36+
],
837
definitions: [
938
{
1039
title: 'Properties',

packages/ui-extensions/src/surfaces/admin/components/Badge/Badge.doc.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,38 @@ const data: AdminReferenceEntityTemplateSchema = {
55
...sharedContent,
66
thumbnail: '/assets/templated-apis-screenshots/admin/components/badge.png',
77
isVisualComponent: true,
8+
subSections: [
9+
{
10+
title: 'Useful for',
11+
type: 'Generic' as const,
12+
anchorLink: 'useful-for',
13+
sectionContent: `- Communicating the state of an object
14+
- Identifying objects that need attention or action
15+
- Quickly scanning complex lists to find specific object states`,
16+
},
17+
{
18+
title: 'Best practices',
19+
type: 'Generic' as const,
20+
anchorLink: 'best-practices',
21+
sectionContent: `- \`base\`: use in tables where many badges are displayed
22+
- \`large\`: use when badge needs to stand out prominently
23+
- Text truncates automatically, keep labels short to avoid truncation
24+
- Badges are static indicators, not interactive or dismissible
25+
- Use \`critical\` or \`warning\` tones for errors needing immediate attention
26+
- Use consistent styles and icons for common statuses
27+
- When using badges in line items, integrate them with the full content group rather than attaching only to the header
28+
- Don't use badges for merchant-created information. Instead, use a Chip or ClickableChip`,
29+
},
30+
{
31+
title: 'Content guidelines',
32+
type: 'Generic' as const,
33+
anchorLink: 'content-guidelines',
34+
sectionContent: `Badge labels should:
35+
- Use 1-2 words maximum: \`Fulfilled\`, \`Partially refunded\`
36+
- Always use past tense: \`Refunded\` not \`Refund\`
37+
`,
38+
},
39+
],
840
definitions: [
941
{
1042
title: 'Properties',

packages/ui-extensions/src/surfaces/admin/components/Banner/Banner.doc.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ const data: AdminReferenceEntityTemplateSchema = {
66
thumbnail: '/assets/templated-apis-screenshots/admin/components/banner.png',
77
isVisualComponent: true,
88
subSections: [
9+
{
10+
title: 'Useful for',
11+
type: 'Generic' as const,
12+
anchorLink: 'useful-for',
13+
sectionContent: `- Showing important information or changes
14+
- Prompting merchants to take a specific action
15+
- Displaying warnings, errors, or critical information
16+
- Communicating persistent conditions that need attention
17+
`,
18+
},
919
{
1020
title: 'Outside of a section',
1121
type: 'Generic' as const,
@@ -28,6 +38,16 @@ const data: AdminReferenceEntityTemplateSchema = {
2838
- Info, Warning and Critical banners should contain a call to action and clear next steps. Users should know what to do after seeing the banner.
2939
- Avoid banners that can't be dismissed unless the user is required to take action.`,
3040
},
41+
{
42+
title: 'Content guidelines',
43+
type: 'Generic' as const,
44+
anchorLink: 'content-guidelines',
45+
sectionContent: `- Keep titles concise and clear
46+
- Limit body content to 1-2 sentences where possible
47+
- Use action-led buttons with strong verbs (e.g., "Activate Apple Pay" not "Try Apple Pay")
48+
- Avoid unnecessary words and articles in button text
49+
- For warning and critical banners, explain how to resolve the issue`,
50+
},
3151
],
3252
definitions: [
3353
{

packages/ui-extensions/src/surfaces/admin/components/Box/Box.doc.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ const data: AdminReferenceEntityTemplateSchema = {
1111
type: 'Generic' as const,
1212
anchorLink: 'useful-for',
1313
sectionContent: `- Creating custom designs when you can't build what you need with the existing components.
14-
- Setting up specific stylings such as background colors, paddings, and borders.
15-
- Nesting with other components.`,
14+
- Setting up specific stylings such as background colors, paddings, and borders.
15+
- Nesting with other components.`,
16+
},
17+
{
18+
title: 'Best practices',
19+
type: 'Generic' as const,
20+
anchorLink: 'best-practices',
21+
sectionContent: `- Use for structural layouts with consistent spacing patterns
22+
- Avoid adding too many borders that may visually fragment the interface`,
1623
},
1724
],
1825
definitions: [

packages/ui-extensions/src/surfaces/admin/components/Button/Button.doc.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,37 @@ const data: AdminReferenceEntityTemplateSchema = {
55
...sharedContent,
66
thumbnail: '/assets/templated-apis-screenshots/admin/components/button.png',
77
isVisualComponent: true,
8+
subSections: [
9+
{
10+
title: 'Useful for',
11+
type: 'Generic' as const,
12+
anchorLink: 'useful-for',
13+
sectionContent: `- Taking primary actions like saving or creating resources
14+
- Taking secondary actions like canceling forms or filtering results
15+
- Triggering destructive operations like deletion or disconnection
16+
- Accessing supplementary actions via tertiary buttons`,
17+
},
18+
{
19+
title: 'Best practices',
20+
type: 'Generic' as const,
21+
anchorLink: 'best-practices',
22+
sectionContent: `- Be clearly and accurately labeled with strong, actionable verbs
23+
- Use established button tones appropriately (e.g., critical tone only for actions that are difficult to undo)
24+
- Prioritize the most important actions to avoid confusion
25+
- Be positioned in consistent locations in the interface
26+
- Use buttons for actions and links for navigation`,
27+
},
28+
{
29+
title: 'Content guidelines',
30+
type: 'Generic' as const,
31+
anchorLink: 'content-guidelines',
32+
sectionContent: `- Use simple, concise verbs (e.g., "Save", "Edit", "Add tags")
33+
- Write in sentence case
34+
- Avoid unnecessary words and articles (e.g., "a", "an", "the")
35+
- Don't use punctuation
36+
- For icon-only buttons, use \`accessibilityLabel\` to describe the action`,
37+
},
38+
],
839
definitions: [
940
{
1041
title: 'Properties',

packages/ui-extensions/src/surfaces/admin/components/ButtonGroup/ButtonGroup.doc.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ const data: AdminReferenceEntityTemplateSchema = {
66
thumbnail:
77
'/assets/templated-apis-screenshots/admin/components/buttongroup.png',
88
isVisualComponent: true,
9+
subSections: [
10+
{
11+
title: 'Useful for',
12+
type: 'Generic' as const,
13+
anchorLink: 'useful-for',
14+
sectionContent: `- Accessing related actions in a consistent layout
15+
- Making secondary actions visible alongside primary actions`,
16+
},
17+
{
18+
title: 'Best practices',
19+
type: 'Generic' as const,
20+
anchorLink: 'best-practices',
21+
sectionContent: `- Group together related calls to action
22+
- Avoid too many actions that may cause uncertainty
23+
- Consider how buttons will work on small screens`,
24+
},
25+
],
926
definitions: [
1027
{
1128
title: 'Properties',

packages/ui-extensions/src/surfaces/admin/components/Checkbox/Checkbox.doc.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ const data: AdminReferenceEntityTemplateSchema = {
55
...sharedContent,
66
thumbnail: '/assets/templated-apis-screenshots/admin/components/checkbox.png',
77
isVisualComponent: true,
8+
subSections: [
9+
{
10+
title: 'Best practices',
11+
type: 'Generic' as const,
12+
anchorLink: 'best-practices',
13+
sectionContent: `- Work independently from each other
14+
- Be framed positively (e.g., "Publish store" not "Hide store")
15+
- Always have a label when used to activate or deactivate a setting
16+
- Be listed in a logical order (alphabetical, numerical, time-based, etc.)`,
17+
},
18+
{
19+
title: 'Content guidelines',
20+
type: 'Generic' as const,
21+
anchorLink: 'content-guidelines',
22+
sectionContent: `- Start each option with a capital letter
23+
- Don't use commas or semicolons at the end of each line
24+
- Use first person when asking merchants to agree to terms (e.g., "I agree to the Terms of Service")`,
25+
},
26+
],
827
definitions: [
928
{
1029
title: 'Properties',

packages/ui-extensions/src/surfaces/admin/components/Chip/Chip.doc.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,38 @@ const data: AdminReferenceEntityTemplateSchema = {
55
...sharedContent,
66
thumbnail: '/assets/templated-apis-screenshots/admin/components/chip.png',
77
isVisualComponent: true,
8+
subSections: [
9+
{
10+
title: 'Useful for',
11+
type: 'Generic' as const,
12+
anchorLink: 'useful-for',
13+
sectionContent: `- Labeling, organizing, and categorizing objects
14+
- Highlighting content attributes
15+
- Enhancing discoverability by identifying items with similar properties`,
16+
},
17+
{
18+
title: 'Best practices',
19+
type: 'Generic' as const,
20+
anchorLink: 'best-practices',
21+
sectionContent: `- \`subdued\`: use for secondary or less important information
22+
- \`base\`: use as default color
23+
- \`strong\`: use for important or verified status
24+
- Text truncates automatically, keep labels short to avoid truncation
25+
- Chips are static indicators, not interactive or dismissible. For interactive chips, use ClickableChip
26+
- Add icons to \`graphic\` slot to provide visual context
27+
- Display chips near the content they classify`,
28+
},
29+
{
30+
title: 'Content guidelines',
31+
type: 'Generic' as const,
32+
anchorLink: 'content-guidelines',
33+
sectionContent: `Chip labels should:
34+
- Be short and concise to avoid truncation
35+
- Use \`accessibilityLabel\` to describe purpose for screen readers
36+
- Common status labels: \`Active\`, \`Draft\`, \`Published\`, \`Verified\`
37+
- Common category labels: \`Product type\`, \`Collection\`, \`Tag name\``,
38+
},
39+
],
840
definitions: [
941
{
1042
title: 'Properties',

packages/ui-extensions/src/surfaces/admin/components/ChoiceList/ChoiceList.doc.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ const data: AdminReferenceEntityTemplateSchema = {
77
thumbnail:
88
'/assets/templated-apis-screenshots/admin/components/choicelist.png',
99
isVisualComponent: true,
10+
subSections: [
11+
{
12+
title: 'Best practices',
13+
type: 'Generic' as const,
14+
anchorLink: 'best-practices',
15+
sectionContent: `- Include a title that tells merchants what to do or explains the available options
16+
- Label options clearly based on what the option will do
17+
- Avoid mutually exclusive options when allowing multiple selection`,
18+
},
19+
{
20+
title: 'Content guidelines',
21+
type: 'Generic' as const,
22+
anchorLink: 'content-guidelines',
23+
sectionContent: `- Write titles and choices in sentence case
24+
- End titles with a colon if they introduce the list
25+
- Start each choice with a capital letter
26+
- Don't use commas or semicolons at the end of lines`,
27+
},
28+
],
1029
definitions: [
1130
{
1231
title: 'Properties',

packages/ui-extensions/src/surfaces/admin/components/ClickableChip/ClickableChip.doc.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ const data: AdminReferenceEntityTemplateSchema = {
66
thumbnail:
77
'/assets/templated-apis-screenshots/admin/components/clickable-chip.png',
88
isVisualComponent: true,
9+
subSections: [
10+
{
11+
title: 'Useful for',
12+
type: 'Generic' as const,
13+
anchorLink: 'useful-for',
14+
sectionContent: `- Creating interactive filters or tags that can be clicked or removed
15+
- Navigating to related content when configured as a link
16+
- Allowing merchants to dismiss or remove applied filters or selections`,
17+
},
18+
{
19+
title: 'Best practices',
20+
type: 'Generic' as const,
21+
anchorLink: 'best-practices',
22+
sectionContent: `- Use for interactive chips that merchants can click or dismiss
23+
- Use Chip component instead for static, non-interactive indicators
24+
- Keep labels short to avoid truncation
25+
- Use color variants to indicate importance (subdued, base, strong)
26+
- Add icons to provide visual context`,
27+
},
28+
],
929
definitions: [
1030
{
1131
title: 'Properties',

0 commit comments

Comments
 (0)