Skip to content

Commit

Permalink
Add a button section to the styleguide (#2088)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbo authored Jan 17, 2020
1 parent ca08ad8 commit 31d1093
Show file tree
Hide file tree
Showing 21 changed files with 215 additions and 4 deletions.
47 changes: 47 additions & 0 deletions packages/venia-styleguide/src/components/Button/Button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.root {
--color: var(--venia-global-color-gray-900);
background: none;
border-color: rgb(var(--color));
border-radius: 1.5rem;
border-style: solid;
border-width: 1px;
color: rgb(var(--color));
font-size: var(--venia-global-text-fontSize-100);
font-weight: var(--venia-global-text-fontWeight-bold);
height: 2rem;
line-height: var(--venia-global-text-lineHeight-300);
max-width: 100%;
min-width: 7.5rem;
outline: none;
padding: 0 1rem;
transition-duration: 384ms;
transition-property: background-color, border-color, color;
transition-timing-function: var(--venia-global-anim-standard);
}

.root:hover {
--color: var(--venia-brand-color-1-700);
}

.root:focus {
box-shadow: 0 0 0 2px rgb(var(--venia-pattern-glow-color)),
0 0 0.5rem 2px rgb(var(--color) / 0.2);
--color: var(--venia-brand-color-1-700);
}

.root--priority-high {
composes: root;
background-color: rgb(var(--color));
color: rgb(var(--venia-global-color-gray-50));
}

.root--priority-normal {
composes: root;
}

.content {
min-width: 0;
overflow: hidden;
text-overflow: clip;
white-space: nowrap;
}
25 changes: 25 additions & 0 deletions packages/venia-styleguide/src/components/Button/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { useMemo } from 'react';

import finalizeClasses from '../../util/finalizeClasses';
import classes from './Button.css';

const Button = props => {
const { children, priority, ...rest } = props;

const finalClasses = useMemo(() => {
return finalizeClasses(classes, { priority });
}, [priority]);

return (
<button {...rest} className={finalClasses.get('root')}>
<span className={classes.content}>{children}</span>
</button>
);
};

export default Button;

Button.defaultProps = {
priority: 'normal',
type: 'button'
};
1 change: 1 addition & 0 deletions packages/venia-styleguide/src/components/Button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Button';
5 changes: 4 additions & 1 deletion packages/venia-styleguide/src/components/Columns/Columns.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
}

.figure {
background-color: rgb(250 250 250);
align-items: center;
background-color: rgb(var(--venia-global-color-gray-75));
border-radius: 4px;
display: grid;
justify-items: center;
min-height: 10rem;
padding: 3rem 5rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.root {
align-items: center;
display: grid;
gap: 2rem;
justify-items: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

import classes from './ExampleGroup.css';

const ExampleGroup = props => <div {...props} className={classes.root} />;

export default ExampleGroup;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ExampleGroup';
5 changes: 5 additions & 0 deletions packages/venia-styleguide/src/components/Routes/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ groups: !!pairs
- "design-tokens"
- "color"
- "typography"
- components:
label: "Components"
items:
- "button"

pages: !!pairs
- button: "Button"
- color: "Color"
- design-tokens: "Design tokens"
- principles: "Principles"
Expand Down
5 changes: 2 additions & 3 deletions packages/venia-styleguide/src/components/Section/Section.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
}

.rule {
background-color: rgb(75 75 75);
background-color: rgb(var(--venia-global-color-gray-800));
border: none;
border-radius: 2px;
height: 4px;
height: 2px;
margin: 0.5rem 0 2.5rem;
}

Expand Down
29 changes: 29 additions & 0 deletions packages/venia-styleguide/src/pages/button/Button.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Article from "../../components/Article"
import Section from "../../components/Section"
import TableOfContents from "../../components/TableOfContents"

import Behaviors from "./sections/Behaviors"
import Options from "./sections/Options"

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce
quis euismod nisi. Morbi metus mauris, volutpat ac aliquet eget,
laoreet vel tortor. Pellentesque commodo tellus nibh, vitae
varius lectus pharetra in. Aliquam quis nisi ligula. Proin sit
amet mauris ac lacus efficitur varius eget in urna. Ut sagittis
feugiat ex et dictum. Nam ut tempor urna, at dapibus erat.
Aenean ac dui a tellus venenatis accumsan.

***

<Section title="Table of contents">
<TableOfContents />
</Section>
<Section title="Options">
<Options />
</Section>
<Section title="Behaviors">
<Behaviors />
</Section>

export const title = "Button"
export default Article
1 change: 1 addition & 0 deletions packages/venia-styleguide/src/pages/button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Button';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Flexible width

A button derives its width from the text.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Minimum width

Standard buttons have a minimum width of `7.5rem`, ensuring their shape is easily identifiable even when the text is short. Quiet buttons have no minimum width.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Text overflow

If the text overflows, it will clip, not wrap to a second line. To avoid clipping, keep the text as concise as possible.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Button from "../../../../components/Button"
import Columns from "../../../../components/Columns"
import ExampleGroup from "../../../../components/ExampleGroup"
import FlexibleWidth from "./FlexibleWidth"
import MinimumWidth from "./MinimumWidth"
import TextOverflow from "./TextOverflow"

<Columns reverse>
<FlexibleWidth />
<ExampleGroup>
<Button>Send</Button>
<Button>Create Account</Button>
<Button>Enter Registration Code</Button>
</ExampleGroup>
</Columns>
<Columns reverse>
<MinimumWidth />
<ExampleGroup>
<Button>Go</Button>
</ExampleGroup>
</Columns>
<Columns reverse>
<TextOverflow />
<ExampleGroup>
<Button>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce quis euismod nisi</Button>
</ExampleGroup>
</Columns>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### High priority

A high priority button is more prominent than other buttons, attracting the user's attention and inviting them to consider taking a particular action. Avoid having more than one high priority button on the screen at once.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Normal priority

A normal button presents the user with an optional or less preferable action.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#### Table of options

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce
quis euismod nisi.

Property | Values | Default Value
:--- | :--- | :---
priority | high / normal | normal
quiet | true / false | false
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Button from "../../../../components/Button"
import Columns from "../../../../components/Columns"
import ExampleGroup from "../../../../components/ExampleGroup"
import HighPriority from "./HighPriority"
import NormalPriority from "./NormalPriority"
import OptionsTable from "./OptionsTable"

<Columns reverse>
<HighPriority />
<ExampleGroup>
<Button priority="high">
Submit
</Button>
</ExampleGroup>
</Columns>
<Columns reverse>
<NormalPriority />
<ExampleGroup>
<Button priority="normal">
Cancel
</Button>
</ExampleGroup>
</Columns>
<OptionsTable />
6 changes: 6 additions & 0 deletions packages/venia-styleguide/src/styles/reset.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,22 @@
border-collapse: collapse;
border-spacing: 0;
font-size: var(--venia-typography-body-S-fontSize);
margin: 2rem 0 1rem;
width: 100%;
}

:global table:first-child {
margin-top: 0;
}

:global td {
border: 0 solid rgb(225 225 225);
border-width: 1px 0;
padding: 1em 1rem;
}

:global th {
color: rgb(var(--venia-global-color-gray-700));
font-size: var(--venia-typography-detail-S-fontSize);
font-weight: var(--venia-global-text-fontWeight-bold);
line-height: var(--venia-typography-detail-lineHeight);
Expand Down
6 changes: 6 additions & 0 deletions packages/venia-styleguide/src/styles/tokens.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/* global tokens */
:global :root {
/* animation */
--venia-global-anim-in: cubic-bezier(0, 0, 0.2, 1);
--venia-global-anim-out: cubic-bezier(0.4, 0, 1, 1);
--venia-global-anim-standard: cubic-bezier(0.4, 0, 0.2, 1);

/* color */
--venia-global-color-gray-50: 255 255 255; /* ffffff 100% 1.09 */
--venia-global-color-gray-75: 250 250 250; /* fafafa 98% 1.04 */
Expand Down Expand Up @@ -59,6 +64,7 @@
/* colors */
--venia-brand-color-1-400: var(--venia-global-color-teal-400);
--venia-brand-color-1-700: var(--venia-global-color-teal-700);
--venia-pattern-glow-color: var(--venia-global-color-sea-500);
/* typography */
/* heading */
--venia-typography-heading-XL-fontSize: var(
Expand Down

0 comments on commit 31d1093

Please sign in to comment.