Skip to content
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

Storybook docs structure #3755

Merged
merged 9 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export const parameters = {
date: /Date$/,
},
},
options: {
storySort: {
order: ["Documentation", ["Introduction", "Colors", "Icons"], "Component Library"],
Hinton marked this conversation as resolved.
Show resolved Hide resolved
},
},
Comment on lines +15 to +19
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I didn't know you could do this! Nice!

docs: { inlineStories: true },
};

Expand Down
2 changes: 1 addition & 1 deletion libs/components/src/stories/Introduction.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from "@storybook/addon-docs";

<Meta title="Common/Introduction" />
<Meta title="Documentation/Introduction" />
Copy link
Member

Choose a reason for hiding this comment

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

I can't comment on things that weren't changed, but on line 89 the words "Role out" should be "Roll out"

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed, nice catch!


<style>{`
.subheading {
Expand Down
73 changes: 73 additions & 0 deletions libs/components/src/stories/buttondocs.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Meta, Story, Source } from "@storybook/addon-docs";
Hinton marked this conversation as resolved.
Show resolved Hide resolved

<Meta title="Documentation/Buttons" />

# Buttons

Use buttons for actions in forms, dialogs, and more with support for style, block, icon, and state.

For pairings in the bottom left corner of a page or component, the `primary` call to action will go on the left side of a button group with the `secondary` call to action option on the left.

Pairings in the top right corner of a page, should have the `primary` call to action on the right.

Groups of buttons should have 1rem of spacing between them.

## Choosing the `<a>` or `<button>`

Buttons can use either the `<a>` or `<button>` tags. Choose which based on the action the button takes:

- If navigating to a new page, use `<a>`
- If taking an action on the current page use `<button>`
- If the button launches a dialog, use `<button>`

## Submit and async actions

Both submit and async action buttons use a loading button state while an action is taken.

<Story id="component-library-button--loading" />

If your button is preforming a long running task in the background like a server API call, be sure to review the [Async Actions Directive](https://components.bitwarden.com/?path=/story/component-library-async-actions-overview--page).

## Styles

There are 3 main styles for the button: Primary, Secondary, and Danger.

### Primary

<Story id="component-library-button--primary" />

Use the primary button styling for all Primary call to actions. An action is "primary" if it relates to the main purpose of a page. There should never be 2 primary styled buttons next to each other.

### Secondary

<Story id="component-library-button--secondary" />

The secondary styling should be used for secondary calls to action. An action is "secondary" if it relates indirectly to the purpose of a page. There may be multiple secondary buttons next to each other; however, generally there should only be 1 or 2 calls to action per page.

### Danger

<Story id="component-library-button--danger" />

Use the danger styling only in settings when the user may preform a permanent action.

## Disabled UI

Both the disabled and loading states use the default state’s color with a 60% opacity or `tw-opacity-60`.

<Story id="component-library-button--disabled" />

## Block

Typically button widths expand with thier text. In some causes though buttons may need to be block where the width is fixed and the text wraps to 2 lines if exceeding the button’s width.

<Story id="component-library-button--block" />

## Accessibility

### Color contrast

All button styles are WCAG compliant when displayed on `background` and `background-alt` colors. To use a button on a different background, double check that the color contrast is sufficient in both the light and dark themes.

### Loading Buttons

Include an `aria-label` attribute that defaults to “loading” but can be configurable per implementation. On click, the screen reader should announce the `aria-label`. Once the action is compelted, use another messaging pattern to alert the user that the action is complete (example: success toast).
Copy link
Contributor

@coroiu coroiu Oct 12, 2022

Choose a reason for hiding this comment

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

thought(non-blocking): I don't think we're changing aria-label when buttons transitions to the loading state. We probably have to update the button components with this logic

2 changes: 1 addition & 1 deletion libs/components/src/stories/colors.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta } from "@storybook/addon-docs";

<Meta title="Common/Colors" />
<Meta title="Documentation/Colors" />
Copy link
Member Author

Choose a reason for hiding this comment

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

@bitwarden/dept-design I've created this draft PR so we can nail down the title for the documentation pages. We discussed using "Documentation" last week so I've added that here as a placeholder. Does this work for you all?


export const Row = (name) => (
<tr class="tw-h-16">
Expand Down
2 changes: 1 addition & 1 deletion libs/components/src/stories/icons.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Meta } from "@storybook/addon-docs/";

<Meta title="Common/Icons" />
<Meta title="Documentation/Icons" />

# Iconography

Expand Down