Skip to content

Commit dce0716

Browse files
authored
docs: fixes LinkTo and adds new docs to README
Fixes LinkTo and adds new docs to README. Also adds inline examples to ToolTips after realizing they weren't rendering
1 parent 2c5bd79 commit dce0716

File tree

33 files changed

+225
-202
lines changed

33 files changed

+225
-202
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ We provide a single package to manage the versions of a few core dependencies: `
5858
## Local development
5959

6060
1. Run `yarn` in the root directory
61-
1. Run `yarn build` to build all of the packages (certain packages like `gamut-icons` need to be built to function in storybook).
61+
2. Run `yarn build` to build all of the packages (certain packages like `gamut-icons` need to be built to function in storybook).
6262

6363
### Running the storybook styleguide
6464

65-
1. Run `yarn start` to start the storybook server
66-
1. Add new stories to `packages/styleguide/stories`
67-
1. Stories are written using storybook's [Component Story Format](https://storybook.js.org/docs/formats/component-story-format/)
65+
1. Run `yarn nx storybook styleguide` to start the storybook server
66+
2. Add new stories to `packages/styleguide/src`
67+
3. Stories are written using storybook's [Component Story Format](https://storybook.js.org/docs/formats/component-story-format/) and [MDX](https://storybook.js.org/docs/writing-docs/mdx#basic-example). Check out our comprehensive guide on writing stories [here](https://gamut.codecademy.com/?path=/docs/meta-stories--docs#quick-start).
6868

6969
### Publishing Modules
7070

packages/styleguide/.storybook/components/Elements/Markdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Anchor, AnchorBase } from '@codecademy/gamut';
1+
import { Anchor } from '@codecademy/gamut';
22
import { themed } from '@codecademy/gamut-styles';
33
import styled from '@emotion/styled';
44
import { linkTo } from '@storybook/addon-links';

packages/styleguide/src/lib/Atoms/Badge/Badge.mdx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Use `Badge`s to display read-only information like statuses, attributes, and oth
3838

3939
### When NOT to use:
4040

41-
- **Interactivity**- when text is meant to be clickable, use the <LinkTo component="Atoms/Button">Button</LinkTo> or <LinkTo component="Typography/Anchor">Anchor</LinkTo> (link) components instead.
42-
- **Categorization**- for labeling or catgorizing content, use the <LinkTo component="Atoms/Tag">Tag</LinkTo> component instead.
41+
- **Interactivity**- when text is meant to be clickable, use the <LinkTo id="Atoms/Buttons">Button</LinkTo> or <LinkTo id="Typography/Anchor">Anchor</LinkTo> components instead.
42+
- **Categorization**- for labeling or catgorizing content, use the <LinkTo id="Atoms/Tag">Tag</LinkTo> component instead.
4343

4444
## Anatomy
4545

@@ -92,24 +92,31 @@ Use the accent variant to draw attention to important details or statuses with a
9292
<Canvas of={BadgeStories.Accent} />
9393

9494
## Sizes
95+
9596
We have two `size` options, which should be used according to their context.
9697

9798
### Default size
99+
98100
Use `primary` when the `Badge` is a standalone entitity.
99-
<Canvas of={BadgeStories.DefaultSize} />
100101

102+
<Canvas of={BadgeStories.DefaultSize} />
101103

102104
### Small size
103-
Use `sm` when the `Badge` is inline with other components such as <LinkTo kind='Typography/Text'>Text</LinkTo>.
105+
106+
Use `sm` when the `Badge` is inline with other components such as <LinkTo id='Typography/Text'>Text</LinkTo>.
107+
104108
<Canvas of={BadgeStories.SmallSize} />
105109

106110
## Leading icon
111+
107112
Include the `icon` property when the icon reinforces the badge’s message and improves scannability. Since badges are inherently small, it's recommended to use Gamut's mini icons. Below are examples of using icons with the different `Badge` sizes.
108113

109114
### Default size with icon
115+
110116
<Canvas of={BadgeStories.DefaultSizeWithIcon} />
111117

112118
### Small size with icon
119+
113120
<Canvas of={BadgeStories.SmallSizeWithIcon} />
114121

115122
## Playground

packages/styleguide/src/lib/Atoms/Buttons/Button/Button.mdx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,26 @@ All but CTA button support a size of either `normal` (default) or `small`.
3939

4040
- Avoid using a color mode outside of its context (no light buttons on navy backgrounds)
4141

42-
4342
## Variants
43+
4444
The examples below use `FillButton` to showcase the `primary` and `secondary` button variants.
45+
4546
### Primary
47+
4648
<Canvas of={ButtonStories.Primary} />
4749

4850
### Secondary
51+
4952
<Canvas of={ButtonStories.Secondary} />
5053

5154
## Inline icons
52-
Our <LinkTo id="atoms-buttons-fillbutton">FillButton </LinkTo>, <LinkTo id="atoms-buttons-strokebutton">StrokeButton </LinkTo>, and <LinkTo id="atoms-buttons-textbutton">TextButton </LinkTo> all support a single inline icon. You can align the icon to the left or right of the button text using the `iconPosition` prop. These icons should be from the mini set to be legible at a smaller size.
55+
56+
Our <LinkTo id="Atoms/Buttons/FillButton">FillButton </LinkTo>, <LinkTo id="Atoms/Buttons/StrokeButton">StrokeButton </LinkTo>, and <LinkTo id="Atoms/Buttons/TextButton">TextButton</LinkTo> all support a single inline icon. You can align the icon to the left or right of the button text using the `iconPosition` prop. These icons should be from the mini set to be legible at a smaller size.
5357

5458
<Canvas of={ButtonStories.InlineIcons} />
5559

5660
## Buttons in light and dark mode
61+
5762
Below are examples of how buttons could look in their respective light and dark modes.
5863

5964
### Light mode
@@ -68,7 +73,7 @@ Below are examples of how buttons could look in their respective light and dark
6873

6974
Writing words for a link or button? Above all else, make sure that the words alone make it clear where a button or link will take the user. Refer to the checklist below for guidance. For more tips and best practices, check out the full guide about <LinkTo id="ux-writing-component-guidelines-buttons-and-links--page">writing for buttons and links</LinkTo>.
7075

71-
* Make sure it is clear where the link or button will take the user.
72-
* Use sentence case, capitalizing only proper nouns.
73-
* For buttons, start with an action-oriented verb (like “explore” or “view”).
74-
* For buttons, use 3 words or less (unless more words are necessary for clarity).
76+
- Make sure it is clear where the link or button will take the user.
77+
- Use sentence case, capitalizing only proper nouns.
78+
- For buttons, start with an action-oriented verb (like “explore” or “view”).
79+
- For buttons, use 3 words or less (unless more words are necessary for clarity).

packages/styleguide/src/lib/Atoms/Buttons/IconButton/IconButton.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Canvas, Controls, Meta } from '@storybook/blocks';
22

3-
import { ComponentHeader } from '~styleguide/blocks';
3+
import { ComponentHeader, LinkTo } from '~styleguide/blocks';
44

55
import * as IconButtonStories from './IconButton.stories';
66

@@ -23,9 +23,13 @@ export const parameters = {
2323
<ComponentHeader {...parameters} />
2424

2525
## Usage
26-
Use for secondary or space-constrained actions with recognizable icons. Use regular icons for normal buttons and mini icons for small buttons. Icon-only buttons must include an aria-label, which will also appear in the tooltip on hover and focus.
26+
27+
Use for secondary or space-constrained actions with recognizable icons. Use regular icons for normal buttons and mini icons for small buttons. Icon-only buttons must include a `tip` prop, which will also appear in the tooltip on hover and focus.
28+
29+
For more detailed information on `IconButton` tooltips, take a look at the <LinkTo id='Molecules/Tips/ToolTip'>ToolTip</LinkTo> story.
2730

2831
## Playground
32+
2933
<Canvas sourceState="shown" of={IconButtonStories.Default} />
3034

3135
<Controls />

packages/styleguide/src/lib/Atoms/FormElements/About.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,45 @@ Both of our Form organisms provide the following benefits:
2020
1. **Accessibility**: All our forms handle accessibility styling and behaviors, passing tests out-of-the-box.
2121
2. **Functionality**: Validation and submission logic is handled by the [react-hook-form](https://react-hook-form.com) library
2222

23-
We recommend <LinkTo id='organisms-gridForm'>GridForm</LinkTo> if you have a form that sticks to a 12x12 visual grid with consistent vertical rhythm and grid spacing.
24-
25-
For everything else, we recommend <LinkTo id='organisms-connectedForm'>ConnectedForm</LinkTo>.
23+
We recommend <LinkTo id='Organisms/GridForm'>GridForm</LinkTo> if you have a form that sticks to a 12x12 visual grid with consistent vertical rhythm and grid spacing.
2624

25+
For everything else, we recommend <LinkTo id='Organisms/ConnectedForm'>ConnectedForm</LinkTo>.
2726

2827
<TableOfContents
2928
links={[
3029
{
3130
id: 'Atoms/FormElements/Form',
32-
subtitle: 'A customizable `<form />` element for wrapping other form elements.',
31+
subtitle:
32+
'A customizable `<form />` element for wrapping other form elements.',
3333
title: 'Form',
3434
status: 'current',
3535
},
3636
{
3737
id: 'Atoms/FormElements/FormGroup',
38-
subtitle: 'A label and description wrapper for a form element that provides conditional styling.',
38+
subtitle:
39+
'A label and description wrapper for a form element that provides conditional styling.',
3940
title: 'FormGroup',
4041
status: 'current',
4142
},
4243
{
4344
id: 'Atoms/FormElements/FormGroupDescription',
44-
subtitle: 'A description wrapper to format a longer description of a group of inputs.',
45+
subtitle:
46+
'A description wrapper to format a longer description of a group of inputs.',
4547
title: 'FormGroupDescription',
4648
status: 'current',
4749
},
4850
{
4951
id: 'Atoms/FormElements/FormGroupLabel',
50-
subtitle: "A label element to be tied to a group of elements.",
52+
subtitle: 'A label element to be tied to a group of elements.',
5153
title: 'FormGroupLabel',
5254
status: 'current',
5355
},
5456
{
5557
id: 'Atoms/FormElements/FormRequiredText',
56-
subtitle: "A Text element that renders our required field explanation, should be included in all forms with required fields.",
58+
subtitle:
59+
'A Text element that renders our required field explanation, should be included in all forms with required fields.',
5760
title: 'FormRequiredText',
5861
status: 'current',
59-
}
62+
},
6063
]}
6164
/>
62-
63-
64-

packages/styleguide/src/lib/Atoms/FormElements/Form/Form.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { ComponentHeader, LinkTo } from '~styleguide/blocks';
55
import * as FormStories from './Form.stories';
66

77
export const parameters = {
8-
subtitle: 'A customizable `<form />` element for wrapping other form elements',
8+
subtitle:
9+
'A customizable `<form />` element for wrapping other form elements',
910
status: 'current',
1011
source: {
1112
repo: 'gamut',
1213
githubLink:
13-
'https://github.com/Codecademy/gamut/blob/main/packages/gamut/src/Form/elements/Form.tsx'
14+
'https://github.com/Codecademy/gamut/blob/main/packages/gamut/src/Form/elements/Form.tsx',
1415
},
1516
};
1617

@@ -20,14 +21,14 @@ export const parameters = {
2021

2122
## Usage
2223

23-
This is `Form` atom is the base component for other forms like the organisms: <LinkTo kind='Atoms/GridForm'>GridForm</LinkTo> and <LinkTo kind='Atoms/ConnectedForm'>ConnectedForm</LinkTo>.
24-
24+
This is `Form` atom is the base component for other forms like the organisms: <LinkTo id='Organisms/GridForm'>GridForm</LinkTo> and <LinkTo id='Organisms/ConnectedForm'>ConnectedForm</LinkTo>.
2525

2626
### Best practices:
27-
- You should not use this component directly, instead use <LinkTo kind='Atoms/GridForm'>GridForm</LinkTo> or <LinkTo kind='Atoms/ConnectedForm'>ConnectedForm</LinkTo> depending on your needs.
27+
28+
- You should not use this component directly, instead use <LinkTo id='Organisms/GridForm'>GridForm</LinkTo> or <LinkTo id='Organisms/ConnectedForm'>ConnectedForm</LinkTo> depending on your needs.
2829

2930
## Playground
31+
3032
<Canvas sourceState="shown" of={FormStories.Default} />
3133

3234
<Controls />
33-

packages/styleguide/src/lib/Atoms/FormElements/FormGroup/FormGroup.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,43 @@ Use `FormGroup` to provide a label and description for a form element.
2929
It is best to provide `htmlFor` to both the FormGroup + inner form element to make it super accessible. If this is not provided, the FormLabel will default to `<div>`. If an `htmlFor` is provided, it will be a `<label>`.
3030

3131
Below shows how adding an `htmlFor` to both the FormGroup and inner form element will make the FormLabel a `<label>`.
32+
3233
<Canvas of={FormGroupStories.FormGroupHtmlFor} />
3334

3435
This example below omits the `htmlFor` prop on the FormGroup and inner form element, which will make the FormLabel a `<div>`.
36+
3537
<Canvas of={FormGroupStories.FormGroupDiv} />
3638

3739
### States
40+
3841
#### Default state
42+
3943
Here's a `FormGroup` without an error or validation:
44+
4045
<Canvas of={FormGroupStories.DefaultState} />
4146

4247
#### `error`
48+
4349
When including an error message, the `FormGroup` should have an `error` prop with a string that describes the error. The inner element wrapped by the `FormGroup` should also have an `error` prop with a boolean to either display or hide the error message. The `error` prop will add a red border to the form element and display the error message below the form element.
4450

4551
<Canvas of={FormGroupStories.Error} />
4652

4753
#### `valid`
54+
4855
Adding `valid` to a `FormGroup`'s inner element will add a green checkmark to the form element.
56+
4957
<Canvas of={FormGroupStories.Valid} />
5058

5159
### Including InfoTip
52-
A field can include <LinkTo id="molecules-tips--infotip"> our existing `InfoTip`</LinkTo>
60+
61+
A field can include <LinkTo id="Molecules/Tips/InfoTip"> our existing `InfoTip`</LinkTo>
5362

5463
#### Low emphasis
64+
5565
<Canvas of={FormGroupStories.LowEmphasisInfoTip} />
5666

5767
#### High emphasis
68+
5869
<Canvas of={FormGroupStories.HighEmphasisInfoTip} />
5970

6071
## Playground

packages/styleguide/src/lib/Atoms/FormElements/FormRequiredText/FormRequiredText.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export const parameters = {
2020

2121
## Usage
2222

23-
`FormRequiredText` should be included in all forms with required fields. Accepts all props of <LinkTo id="typography-text">our existing `Text`</LinkTo> component.
23+
`FormRequiredText` should be included in all forms with required fields. Accepts all props of <LinkTo id="Typography/Text">our existing `Text`</LinkTo> component.
2424

2525
## Playground
26+
2627
<Canvas sourceState="shown" of={FormRequiredTextStories.Default} />
2728

2829
<Controls />

packages/styleguide/src/lib/Foundations/Layout.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ This section would be 6 columns at the smallest screen size and 4 columns at any
113113

114114
## Spacing
115115

116-
For spacing between components and sections use these as a guide. Each of these scales is a subset of our `spacing` sizes found on <LinkTo id="foundations-theme--spacing">our theme</LinkTo>. While you will have access to all of them in your code use these sets as a practical guide.
116+
For spacing between components and sections use these as a guide. Each of these scales is a subset of our `spacing` sizes found on <LinkTo id="Foundations/Theme">our theme</LinkTo>. While you will have access to all of them in your code use these sets as a practical guide.
117117

118118
<TokenTable
119119
rows={[

0 commit comments

Comments
 (0)