Repository: hackclub/design-system Branch: master Commit: 0a4ced2b81a8 Files: 130 Total size: 165.5 KB Directory structure: gitextract_7404ezv9/ ├── .babelrc ├── .gitignore ├── .npmignore ├── .storybook/ │ ├── .babelrc │ ├── AAA.js │ ├── Avatar.js │ ├── BackgroundImage.js │ ├── Badge.js │ ├── BlockLink.js │ ├── Box.js │ ├── Button.js │ ├── Card.js │ ├── Colors.js │ ├── Container.js │ ├── Field.js │ ├── Flex.js │ ├── Heading.js │ ├── Hide.js │ ├── Icon.js │ ├── IconButton.js │ ├── Image.js │ ├── Input.js │ ├── Label.js │ ├── LargeButton.js │ ├── Layouts.js │ ├── Link.js │ ├── Loading.js │ ├── OutlineButton.js │ ├── Section.js │ ├── Sheet.js │ ├── Slider.js │ ├── Submit.js │ ├── Text.js │ └── config.js ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── docs/ │ ├── Contributing.md │ ├── GettingStarted.md │ ├── README.md │ ├── Theme.md │ └── ThemeProvider.md ├── package.json ├── src/ │ ├── Avatar.js │ ├── BackgroundImage.js │ ├── Badge.js │ ├── BlockLink.js │ ├── Box.js │ ├── Button.js │ ├── Card.js │ ├── Container.js │ ├── Field.js │ ├── Flex.js │ ├── Heading.js │ ├── Hide.js │ ├── Icon.js │ ├── IconButton.js │ ├── Image.js │ ├── Input.js │ ├── Label.js │ ├── LargeButton.js │ ├── Link.js │ ├── Loading.js │ ├── OutlineButton.js │ ├── Section.js │ ├── Sheet.js │ ├── Slider.js │ ├── Submit.js │ ├── Text.js │ ├── ThemeProvider.js │ ├── __tests__/ │ │ ├── Avatar.js │ │ ├── BackgroundImage.js │ │ ├── Badge.js │ │ ├── BlockLink.js │ │ ├── Box.js │ │ ├── Button.js │ │ ├── Card.js │ │ ├── Container.js │ │ ├── Field.js │ │ ├── Flex.js │ │ ├── Heading.js │ │ ├── Hide.js │ │ ├── Icon.js │ │ ├── IconButton.js │ │ ├── Image.js │ │ ├── Input.js │ │ ├── Label.js │ │ ├── LargeButton.js │ │ ├── Link.js │ │ ├── Loading.js │ │ ├── OutlineButton.js │ │ ├── Section.js │ │ ├── Sheet.js │ │ ├── Slider.js │ │ ├── Submit.js │ │ ├── Text.js │ │ ├── ThemeProvider.js │ │ ├── __snapshots__/ │ │ │ ├── Avatar.js.snap │ │ │ ├── BackgroundImage.js.snap │ │ │ ├── Badge.js.snap │ │ │ ├── BlockLink.js.snap │ │ │ ├── Box.js.snap │ │ │ ├── Button.js.snap │ │ │ ├── Card.js.snap │ │ │ ├── Container.js.snap │ │ │ ├── Field.js.snap │ │ │ ├── Flex.js.snap │ │ │ ├── Heading.js.snap │ │ │ ├── Hide.js.snap │ │ │ ├── Icon.js.snap │ │ │ ├── IconButton.js.snap │ │ │ ├── Image.js.snap │ │ │ ├── Input.js.snap │ │ │ ├── Label.js.snap │ │ │ ├── LargeButton.js.snap │ │ │ ├── Link.js.snap │ │ │ ├── Loading.js.snap │ │ │ ├── OutlineButton.js.snap │ │ │ ├── Section.js.snap │ │ │ ├── Sheet.js.snap │ │ │ ├── Slider.js.snap │ │ │ ├── Submit.js.snap │ │ │ ├── Text.js.snap │ │ │ ├── ThemeProvider.js.snap │ │ │ └── theme.js.snap │ │ └── theme.js │ ├── index.js │ └── theme.js └── test-setup.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .babelrc ================================================ { "presets": ["@babel/env", "@babel/preset-react"] } ================================================ FILE: .gitignore ================================================ node_modules npm-debug.log coverage dist .site .DS_Store ================================================ FILE: .npmignore ================================================ src storybook docs test ================================================ FILE: .storybook/.babelrc ================================================ { "presets": ["@babel/preset-env", "@babel/preset-react"] } ================================================ FILE: .storybook/AAA.js ================================================ import React, { Fragment } from 'react' import { storiesOf } from '@storybook/react' import { Box, Flex, Heading, Text, Link, Button, Avatar } from '../src' import styled from 'styled-components' const List = Box.withComponent('ul') const Item = Text.withComponent('li') const Code = Text.withComponent('pre') const Flag = styled(Link)` display: inline-block; background: url(//hackclub.com/orpheus_flag.svg) no-repeat; background-position: top center; width: 8rem; height: 3rem; z-index: 0; margin-top: -1rem; ` storiesOf('👋 Welcome!', module).add('About the project', () => ( Welcome! This is{' '} ’s Design System. It’s a collection of React components designed to: Speed up design and development velocity Help create consistent, beautiful, and usable UI in our various websites Promote best practices for accessibility and responsive web design We hope to accomplish these goals by: Reducing the number of decisions needed when iterating on UI Reducing the amount of code duplication in our apps Serving as the standard for hackclub.com’s visual language Providing easy-to-use and extensible components for anyone to consume yarn add @hackclub/design-system ) ) .add('Colors', () => ( )) .add('Font size', () => ( )) .add('Width', () => ) .add('Disabled', () => ) .add('Scale', () => ) .add('Chevrons', () => ( )) ================================================ FILE: .storybook/Card.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { Card } from '../src' storiesOf('Card', module) .add( 'Card component', withInfo({ inline: true, text: 'Box extension to control box-shadow.' })(() => (
Small Shadow Medium Shadow Large Shadow XLarge Shadow
)) ) .add('Box Shadows with custom borders', () => (
Small Shadow Medium Shadow Large Shadow XLarge Shadow
)) .add('Box Shadows with varying border radii', () => (
Small Shadow Medium Shadow Large Shadow XLarge Shadow
)) ================================================ FILE: .storybook/Colors.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import styled from 'styled-components' import { Box, Flex, Text, Heading, theme } from '../src' const keys = Object.keys(theme.colors).filter( key => !Array.isArray(theme.colors[key]) ) const next = keys.map(key => ({ key, value: theme.colors[key] })) const Chip = props => const Pre = styled(Text.withComponent('pre'))` font-family: ${theme.mono}; ` const Card = ({ name, color }) => ( {name}
      {color}
    
) storiesOf('Color', module).add('Palette', () => (
Color Palette {next.map( color => !color.key[color.key.length - 1].match(/^\d+$/) ? ( ) : null )}
)) ================================================ FILE: .storybook/Container.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { Container } from '../src' storiesOf('Container', module) .add( 'Container component', withInfo({ inline: true, text: ' to constrain the width of content and center it. Uses theme.maxContainerWidth if no maxWidth is provided' })(() => ( Container Component )) ) .add('Custom maxWidth', () => ( 32rem-width Container )) ================================================ FILE: .storybook/Field.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { Field } from '../src' storiesOf('Field', module) .add( 'Field component', withInfo({ inline: true, text: 'Compound component for form fields.' })(() => ) ) .add('with error', () => ( )) .add('textarea type', () => ( )) .add('select type', () => ( )) ================================================ FILE: .storybook/Flex.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { Flex, Box } from '../src' storiesOf('Flex', module) .add('Basic', () => ( Flex Box )) .add('Wrap', () => ( Flex Wrap Wrap )) .add('Justify', () => ( Flex Justify )) .add('Direction', () => ( Flex Direction )) ================================================ FILE: .storybook/Heading.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { Heading } from '../src' const description = 'A type of the component' + ' using HTML h1-h6 element for setting section headings,' + ' supporting all props.' storiesOf('Heading', module) .add( 'Heading component', withInfo({ inline: true, text: description })(() => Heading component (renders h2)) ) .add('Using dot-notation with h1-h6', () => (
Heading h1 Heading h2 (default) Heading h3 Heading h4 Heading h5 Heading h6
)) .add('Using props', () => (
Heading Left Heading Center Heading Right
)) ================================================ FILE: .storybook/Hide.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { Hide, Flex } from '../src' storiesOf('Hide', module).add('Hide', () => ( Hide xs Hide sm Hide md Hide lg Hide xl )) ================================================ FILE: .storybook/Icon.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { Icon, Flex, LargeButton } from '../src' storiesOf('Icon', module) .add( 'Icon component', withInfo({ inline: true, text: 'A wrapper component for @hackclub/icons.' })(() => ) ) .add('Examples', () => (
See all icons
)) ================================================ FILE: .storybook/IconButton.js ================================================ import React, { Fragment } from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { IconButton } from '../src' storiesOf('IconButton', module) .add( 'IconButton component', withInfo({ inline: true, text: 'Use the component to render a primitive button.' })(() => ) ) .add('Rectangular button', () => ( )) .add('Circular button', () => ( )) .add('Disabled circular buttons', () => ( )) ================================================ FILE: .storybook/Image.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { Image, Box } from '../src' const text = 'A low-level layout component that renders an image' const props = { src: 'https://hackclub.com/social-photo_2.jpg', alt: 'Smiling students at a hackathon' } storiesOf('Image', module) .add( 'Image component', withInfo({ text, inline: true })(() => ) ) .add('Responsive width, with Box', () => ( )) ================================================ FILE: .storybook/Input.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { Box, Input, Label, theme } from '../src' storiesOf('Input', module) .add( 'Input component', withInfo({ inline: true, text: 'Simple styled input component that accepts a color and optionally, an error message.' })(() => ) ) .add('With external label', () => ( )) ================================================ FILE: .storybook/Label.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { Label, Input } from '../src' storiesOf('Label', module) .add( 'Label component', withInfo({ inline: true, text: 'Simple styled label component that supports a number of the styled-system props.' })(() => ) ) .add('Using fontSize', () => (
)) .add('Spacing', () => (
)) .add('Colors', () => (
)) .add('htmlFor', () => (
Clicking{' '} {' '} should focus on the input element.
)) ================================================ FILE: .storybook/LargeButton.js ================================================ import React from 'react' import { storiesOf } from '@storybook/react' import { withInfo } from '@storybook/addon-info' import { LargeButton } from '../src' storiesOf('LargeButton', module) .add( 'LargeButton component', withInfo({ inline: true, text: 'A bigger `; exports[`IconButton renders with circle prop 1`] = ` .c1 { margin: 0px; padding-left: 18px; padding-right: 18px; padding-top: 12px; padding-bottom: 12px; background-color: transparent; color: #ffffff; font-size: 24px; -webkit-font-smoothing: antialiased; display: inline-block; vertical-align: middle; text-align: center; -webkit-text-decoration: none; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: bold; line-height: 1.125; -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; box-shadow: 0 2px 4px rgba(0,0,0,0.125); border-radius: 9999px; border: none; } .c1:hover, .c1:focus { outline: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.125); } .c1:active { outline: 0; box-shadow: 0 2px 8px 2px rgba(0,0,0,0.125); } .c2 { -webkit-flex: none; -ms-flex: none; flex: none; } .c0 { box-shadow: none !important; line-height: 0 !important; padding: 12px; } `; ================================================ FILE: src/__tests__/__snapshots__/Image.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Image renders 1`] = ` .c0 { display: block; max-width: 100%; height: auto; } Smiling students at a hackathon `; ================================================ FILE: src/__tests__/__snapshots__/Input.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Input renders 1`] = ` .c0 { -webkit-appearance: none; -moz-appearance: none; appearance: none; display: block; vertical-align: middle; max-width: 32rem; min-height: 36px; line-height: inherit; font-family: inherit; background-color: transparent; border-radius: 4px; border-width: 1px; border-style: solid; border-color: #dde1e4; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; font-size: 18px; margin: 0px; padding-left: 12px; padding-right: 12px; padding-top: 6px; padding-bottom: 6px; width: 100%; color: inherit; background-color: transparent; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0:focus { outline: none; border-color: #2d9ee4; box-shadow: 0 0 0 2px #add9f5; } .c0[type='select'] { background: #fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23606e77' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .75rem center; background-size: .5rem; } .c0[type='textarea'] { resize: vertical; } `; exports[`Input renders with custom fontSize 1`] = ` .c0 { -webkit-appearance: none; -moz-appearance: none; appearance: none; display: block; vertical-align: middle; max-width: 32rem; min-height: 36px; line-height: inherit; font-family: inherit; background-color: transparent; border-radius: 4px; border-width: 1px; border-style: solid; border-color: #dde1e4; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; font-size: 27px; margin: 0px; padding-left: 12px; padding-right: 12px; padding-top: 6px; padding-bottom: 6px; width: 100%; color: inherit; background-color: transparent; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0:focus { outline: none; border-color: #2d9ee4; box-shadow: 0 0 0 2px #add9f5; } .c0[type='select'] { background: #fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23606e77' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .75rem center; background-size: .5rem; } .c0[type='textarea'] { resize: vertical; } `; exports[`Input renders with custom spacing 1`] = ` .c0 { -webkit-appearance: none; -moz-appearance: none; appearance: none; display: block; vertical-align: middle; max-width: 32rem; min-height: 36px; line-height: inherit; font-family: inherit; background-color: transparent; border-radius: 4px; border-width: 1px; border-style: solid; border-color: #dde1e4; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; font-size: 18px; margin: 24px; padding: 24px; padding-left: 12px; padding-right: 12px; padding-top: 6px; padding-bottom: 6px; width: 100%; color: inherit; background-color: transparent; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0::-ms-clear { display: none; } .c0:focus { outline: none; border-color: #2d9ee4; box-shadow: 0 0 0 2px #add9f5; } .c0[type='select'] { background: #fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23606e77' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .75rem center; background-size: .5rem; } .c0[type='textarea'] { resize: vertical; } `; ================================================ FILE: src/__tests__/__snapshots__/Label.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Label it renders 1`] = ` .c1 { font-size: 18px; margin: 0px; color: #384046; } .c0 { display: block; } .c0 a { color: #2d9ee4; -webkit-text-decoration: underline; text-decoration: underline; } `; exports[`LargeButton larger 1`] = ` .c0 { margin: 0px; padding-left: 24px; padding-right: 24px; padding-top: 18px; padding-bottom: 18px; background-color: #7280ed; color: #ffffff; font-size: 24px; -webkit-font-smoothing: antialiased; display: inline-block; vertical-align: middle; text-align: center; -webkit-text-decoration: none; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: bold; line-height: 1.125; -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; box-shadow: 0 2px 4px rgba(0,0,0,0.125); border-radius: 9999px; border: none; text-transform: uppercase; box-shadow: 0 2px 12px rgba(0,0,0,0.125); } .c0:hover, .c0:focus { outline: 0; box-shadow: 0 2px 6px rgba(114,128,237,0.25); } .c0:active { outline: 0; box-shadow: 0 2px 8px 2px rgba(114,128,237,0.25); } .c0:hover, .c0:focus { box-shadow: 0 2px 12px 2px rgba(114,128,237,0.25); } .c0:active { box-shadow: 0 4px 16px 2px rgba(114,128,237,0.25); } `; exports[`LargeButton renders 1`] = ` .c0 { margin: 0px; padding-left: 24px; padding-right: 24px; padding-top: 18px; padding-bottom: 18px; background-color: #e42d42; color: #ffffff; font-size: 24px; -webkit-font-smoothing: antialiased; display: inline-block; vertical-align: middle; text-align: center; -webkit-text-decoration: none; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: bold; line-height: 1.125; -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; box-shadow: 0 2px 4px rgba(0,0,0,0.125); border-radius: 9999px; border: none; text-transform: uppercase; box-shadow: 0 2px 12px rgba(0,0,0,0.125); } .c0:hover, .c0:focus { outline: 0; box-shadow: 0 2px 6px rgba(228,45,66,0.25); } .c0:active { outline: 0; box-shadow: 0 2px 8px 2px rgba(228,45,66,0.25); } .c0:hover, .c0:focus { box-shadow: 0 2px 12px 2px rgba(228,45,66,0.25); } .c0:active { box-shadow: 0 4px 16px 2px rgba(228,45,66,0.25); } `; ================================================ FILE: src/__tests__/__snapshots__/Link.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Link renders 1`] = ` .c0 { color: #2d9ee4; -webkit-text-decoration: none; text-decoration: none; } .c0:before, .c0:after { -webkit-text-decoration: none !important; text-decoration: none !important; display: inline-block; } Hello `; exports[`Link renders chevronleft 1`] = ` .c0 { color: #2d9ee4; -webkit-text-decoration: none; text-decoration: none; } .c0:before, .c0:after { -webkit-text-decoration: none !important; text-decoration: none !important; display: inline-block; } .c0:before { content: '‹'; padding-right: 0.25em; } Left `; exports[`Link renders chevronright 1`] = ` .c0 { color: #2d9ee4; -webkit-text-decoration: none; text-decoration: none; } .c0:before, .c0:after { -webkit-text-decoration: none !important; text-decoration: none !important; display: inline-block; } .c0:after { content: '›'; padding-left: 0.25em; } Right `; exports[`Link renders hoverline 1`] = ` .c0 { color: #2d9ee4; -webkit-text-decoration: none; text-decoration: none; } .c0:focus, .c0:hover { -webkit-text-decoration: underline; text-decoration: underline; } .c0:before, .c0:after { -webkit-text-decoration: none !important; text-decoration: none !important; display: inline-block; } Hoverline `; exports[`Link renders underline 1`] = ` .c0 { color: #2d9ee4; -webkit-text-decoration: underline; text-decoration: underline; } .c0:before, .c0:after { -webkit-text-decoration: none !important; text-decoration: none !important; display: inline-block; } Underline `; ================================================ FILE: src/__tests__/__snapshots__/Loading.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Loading renders 1`] = ` .c1 { color: #e42d42; } .c0 { display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; display: inline-flex; -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center; position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%,-50%); -ms-transform: translate(-50%,-50%); transform: translate(-50%,-50%); width: 64px; height: 64px; border-radius: 50%; } .c2 { position: absolute; border: 4px solid currentColor; opacity: 1; border-radius: 50%; -webkit-transform-origin: center; -ms-transform-origin: center; transform-origin: center; -webkit-animation: EdArQ 0.975s ease-out infinite; animation: EdArQ 0.975s ease-out infinite; }
`; ================================================ FILE: src/__tests__/__snapshots__/OutlineButton.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`OutlineButton disabled prop sets 1`] = ` .c0 { margin: 0px; padding-left: 22px; padding-right: 22px; padding-top: 16px; padding-bottom: 16px; background-color: #e42d42; color: #ffffff; font-size: 24px; -webkit-font-smoothing: antialiased; display: inline-block; vertical-align: middle; text-align: center; -webkit-text-decoration: none; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: bold; line-height: 1.125; -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; box-shadow: 0 2px 4px rgba(0,0,0,0.125); border-radius: 9999px; border: none; opacity: 0.25; cursor: not-allowed; text-transform: uppercase; box-shadow: 0 2px 12px rgba(0,0,0,0.125); background: transparent; border-width: 2px; border-style: solid; border-color: #e42d42; box-shadow: none; color: #e42d42; } .c0:hover, .c0:focus { outline: 0; box-shadow: 0 2px 6px rgba(228,45,66,0.25); } .c0:active { outline: 0; box-shadow: 0 2px 8px 2px rgba(228,45,66,0.25); } .c0:hover, .c0:focus { box-shadow: 0 2px 12px 2px rgba(228,45,66,0.25); } .c0:active { box-shadow: 0 4px 16px 2px rgba(228,45,66,0.25); } .c0:focus:enabled, .c0:hover:enabled { background: #e42d42; color: #ffffff; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) background, 0.1875s cubic-bezier(0.375,0,0.675,1) color; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) background, 0.1875s cubic-bezier(0.375,0,0.675,1) color; } `; exports[`OutlineButton renders 1`] = ` .c0 { margin: 0px; padding-left: 22px; padding-right: 22px; padding-top: 16px; padding-bottom: 16px; background-color: #e42d42; color: #ffffff; font-size: 24px; -webkit-font-smoothing: antialiased; display: inline-block; vertical-align: middle; text-align: center; -webkit-text-decoration: none; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: bold; line-height: 1.125; -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; box-shadow: 0 2px 4px rgba(0,0,0,0.125); border-radius: 9999px; border: none; text-transform: uppercase; box-shadow: 0 2px 12px rgba(0,0,0,0.125); background: transparent; border-width: 2px; border-style: solid; border-color: #e42d42; box-shadow: none; color: #e42d42; } .c0:hover, .c0:focus { outline: 0; box-shadow: 0 2px 6px rgba(228,45,66,0.25); } .c0:active { outline: 0; box-shadow: 0 2px 8px 2px rgba(228,45,66,0.25); } .c0:hover, .c0:focus { box-shadow: 0 2px 12px 2px rgba(228,45,66,0.25); } .c0:active { box-shadow: 0 4px 16px 2px rgba(228,45,66,0.25); } .c0:focus:enabled, .c0:hover:enabled { background: #e42d42; color: #ffffff; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) background, 0.1875s cubic-bezier(0.375,0,0.675,1) color; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) background, 0.1875s cubic-bezier(0.375,0,0.675,1) color; } `; exports[`OutlineButton with custom color 1`] = ` .c0 { margin: 0px; padding-left: 22px; padding-right: 22px; padding-top: 16px; padding-bottom: 16px; background-color: #ffffff; color: #ffffff; font-size: 24px; -webkit-font-smoothing: antialiased; display: inline-block; vertical-align: middle; text-align: center; -webkit-text-decoration: none; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: bold; line-height: 1.125; -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; box-shadow: 0 2px 4px rgba(0,0,0,0.125); border-radius: 9999px; border: none; text-transform: uppercase; box-shadow: 0 2px 12px rgba(0,0,0,0.125); background: transparent; border-width: 2px; border-style: solid; border-color: #ffffff; box-shadow: none; color: #ffffff; } .c0:hover, .c0:focus { outline: 0; box-shadow: 0 2px 6px rgba(255,255,255,0.25); } .c0:active { outline: 0; box-shadow: 0 2px 8px 2px rgba(255,255,255,0.25); } .c0:hover, .c0:focus { box-shadow: 0 2px 12px 2px rgba(255,255,255,0.25); } .c0:active { box-shadow: 0 4px 16px 2px rgba(255,255,255,0.25); } .c0:focus:enabled, .c0:hover:enabled { background: #ffffff; color: #ffffff; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) background, 0.1875s cubic-bezier(0.375,0,0.675,1) color; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) background, 0.1875s cubic-bezier(0.375,0,0.675,1) color; } `; ================================================ FILE: src/__tests__/__snapshots__/Section.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Section renders 1`] = ` .c2 { padding-left: 18px; padding-right: 18px; padding-top: 24px; padding-bottom: 24px; color: #ffffff; text-align: center; } .c1 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; } .c0 { text-align: center; } @media screen and (min-width:32em) { .c2 { padding-top: 36px; padding-bottom: 36px; } }
`; ================================================ FILE: src/__tests__/__snapshots__/Sheet.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Sheet renders 1`] = ` .c3 { margin-left: auto; margin-right: auto; padding: 18px; width: 100%; background-color: rgba(255,255,255,0.875); } .c2 { max-width: 72rem; } .c1 { border-radius: 4px; } .c0 { position: relative; overflow: hidden; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.0625); } @media screen and (min-width:32em) { .c3 { padding: 24px; } }
`; ================================================ FILE: src/__tests__/__snapshots__/Slider.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Slider renders 1`] = ` .c0 { -webkit-appearance: none; -moz-appearance: none; appearance: none; display: block; border-radius: 9999px; height: 4px; cursor: pointer; width: 100%; background-color: #dde1e4; color: #e42d42; } .c0::-webkit-slider-thumb { width: 16px; height: 16px; background-color: currentColor; border: 0; border-radius: 9999px; -webkit-appearance: none; -moz-appearance: none; appearance: none; } `; ================================================ FILE: src/__tests__/__snapshots__/Submit.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Submit renders 1`] = ` .c1 { margin: 0px; padding-left: 18px; padding-right: 18px; padding-top: 12px; padding-bottom: 12px; background-color: #e42d42; color: #ffffff; font-size: 24px; -webkit-font-smoothing: antialiased; display: inline-block; vertical-align: middle; text-align: center; -webkit-text-decoration: none; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: bold; line-height: 1.125; -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; box-shadow: 0 2px 4px rgba(0,0,0,0.125); border-radius: 9999px; border: none; } .c1:hover, .c1:focus { outline: 0; box-shadow: 0 2px 6px rgba(228,45,66,0.25); } .c1:active { outline: 0; box-shadow: 0 2px 8px 2px rgba(228,45,66,0.25); } .c0 { text-transform: uppercase; } `; exports[`Submit renders lg 1`] = ` .c1 { margin: 0px; padding-left: 18px; padding-right: 18px; padding-top: 12px; padding-bottom: 12px; background-color: #e42d42; color: #ffffff; font-size: 24px; -webkit-font-smoothing: antialiased; display: inline-block; vertical-align: middle; text-align: center; -webkit-text-decoration: none; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: bold; line-height: 1.125; -webkit-appearance: none; -moz-appearance: none; appearance: none; cursor: pointer; -webkit-transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; transition: 0.1875s cubic-bezier(0.375,0,0.675,1) box-shadow; box-shadow: 0 2px 4px rgba(0,0,0,0.125); border-radius: 9999px; border: none; } .c1:hover, .c1:focus { outline: 0; box-shadow: 0 2px 6px rgba(228,45,66,0.25); } .c1:active { outline: 0; box-shadow: 0 2px 8px 2px rgba(228,45,66,0.25); } .c0 { text-transform: uppercase; } `; ================================================ FILE: src/__tests__/__snapshots__/Text.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Text align prop sets text-align 1`] = ` .c0 { margin: 0px; text-align: center; }

`; exports[`Text bold prop sets font-weight 1`] = ` .c0 { margin: 0px; font-weight: bold; }

`; exports[`Text caps prop sets text-transform 1`] = ` .c0 { margin: 0px; text-transform: uppercase; }

`; exports[`Text maxWidth prop sets max-width 1`] = ` .c0 { margin: 0px; max-width: 48rem; }

`; exports[`Text mt prop sets margin-top 1`] = ` .c0 { margin: 0px; margin-top: 12px; }

`; exports[`Text regular prop sets font-weight 1`] = ` .c0 { margin: 0px; font-weight: regular; }

`; exports[`Text renders 1`] = ` .c0 { margin: 0px; }

`; ================================================ FILE: src/__tests__/__snapshots__/ThemeProvider.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ThemeProvider renders content with theme 1`] = ` .c0 { color: #e42d42; }

Hello!

`; ================================================ FILE: src/__tests__/__snapshots__/theme.js.snap ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`theme snapshot 1`] = ` Object { "bold": "bold", "boxShadows": Array [ "0 0 2px 0 rgba(0,0,0,.0625),0 2px 4px 0 rgba(0,0,0,0.125)", "0 0 2px 0 rgba(0,0,0,.0625),0 4px 8px 0 rgba(0,0,0,0.125)", "0 0 2px 0 rgba(0,0,0,.0625),0 12px 12px 0 rgba(0,0,0,0.125)", "0 0 2px 0 rgba(0,0,0,.0625),0 24px 24px 0 rgba(0,0,0,0.125)", ], "breakpoints": Array [ 32, 48, 64, 80, ], "colors": Object { "accent": "#7280ed", "base": "#2d9ce4", "black": "#384046", "blue": Array [ "#e6f4fc", "#cce7f8", "#add9f5", "#8bc9f0", "#62b6eb", "#2d9ee4", "#298fce", "#247db4", "#1d6795", "#154a6b", ], "cyan": Array [ "#e7fcfa", "#ccf9f3", "#aff5ed", "#8cf0e5", "#63ebdb", "#2de4cf", "#29cebb", "#24b5a5", "#1e9789", "#166d63", ], "dark": "#17171d", "darker": "#121217", "error": "#b52434", "fuschia": Array [ "#faebfc", "#f5d4fa", "#efbaf6", "#e89bf2", "#df73ed", "#cf2de4", "#bb29ce", "#a424b5", "#881d95", "#61156b", ], "gray": Array [ "#f9f9fa", "#ebeeef", "#dde1e4", "#cdd4d8", "#bcc5cb", "#a9b5bc", "#93a2ab", "#7a8c97", "#606e77", "#384046", ], "green": Array [ "#eafce7", "#d2f9cd", "#b7f5b0", "#99f08d", "#73eb64", "#42e42d", "#3cce29", "#35b524", "#2c971e", "#206d16", ], "indigo": Array [ "#ebedfc", "#d4d8f9", "#bac1f6", "#9aa4f2", "#7280ed", "#2d42e4", "#283bcd", "#2334b3", "#1d2a92", "#141e66", ], "info": "#2d9ee4", "lime": Array [ "#f2fbe4", "#e5f8c6", "#d6f4a6", "#c6ef83", "#b3ea5b", "#9ee42d", "#8fce29", "#7eb524", "#69971e", "#4c6d16", ], "muted": "#7a8c97", "orange": Array [ "#fcefe7", "#f9ddcc", "#f5caaf", "#f0b38d", "#eb9763", "#e4732d", "#ce6829", "#b45b24", "#954b1d", "#6b3615", ], "pink": Array [ "#fcebf6", "#fad5eb", "#f6bbdf", "#f29cd1", "#ed73be", "#e42d9e", "#ce298f", "#b5247d", "#961e68", "#6b154a", ], "primary": "#e42d42", "red": Array [ "#fcebed", "#fad5d9", "#f6bcc2", "#f29da7", "#ed7582", "#e42d42", "#ce293c", "#b52434", "#951d2b", "#6b151f", ], "silver": "#7a8c97", "slate": "#606e77", "smoke": "#dde1e4", "snow": "#f9f9fa", "success": "#2de473", "teal": Array [ "#e7fcef", "#cdf9de", "#b0f5ca", "#8df0b3", "#64eb98", "#2de473", "#29ce68", "#24b55c", "#1e974c", "#166d37", ], "violet": Array [ "#f2ebfc", "#e3d4fa", "#d1baf6", "#bd9bf2", "#a173ed", "#732de4", "#6829cd", "#5a23b3", "#4a1d93", "#341467", ], "warning": "#e4732d", "white": "#ffffff", "yellow": Array [ "#fbf9e3", "#f7f2c4", "#f3eaa4", "#efe280", "#ead959", "#e4cf2d", "#cebb29", "#b5a524", "#97891e", "#6d6316", ], }, "cx": [Function], "font": "\\"Phantom Sans\\",-apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,sans-serif,\\"Apple Color Emoji\\",\\"Segoe UI Emoji\\",\\"Segoe UI Symbol\\"", "fontSizes": Array [ 13.5, 16, 18, 24, 27, 36, 48, 54, 72, 96, ], "fontWeights": Object { "bold": "bold", "regular": "regular", }, "gradient": [Function], "hexa": [Function], "mediaQueries": Object { "0": "@media screen and (min-width:32em)", "1": "@media screen and (min-width:48em)", "2": "@media screen and (min-width:64em)", "3": "@media screen and (min-width:80em)", "reduceMotion": "@media (prefers-reduced-motion: reduce)", "reduceTransparency": "@media (prefers-reduced-transparency: reduce)", }, "mono": "SFMono-Regular,\\"Roboto Mono\\",Menlo,monospace", "pill": "9999px", "radii": Array [ "0px", "4px", "8px", "16px", "9999px", ], "radius": "4px", "regular": "regular", "scaleFactor": 1.0625, "shadowColor": "rgba(0,0,0,0.125)", "space": Array [ 0, 6, 12, 18, 24, 36, 72, 108, 144, 288, 432, ], "transition": "0.1875s cubic-bezier(0.375, 0, 0.675, 1)", } `; ================================================ FILE: src/__tests__/theme.js ================================================ import theme, { cx, colors, space, fontSizes, boxShadows } from '../theme' const aliases = ['sm', 'md', 'lg', 'xl'] describe('theme', () => { test('exports an object', () => { expect(typeof theme).toBe('object') }) test('snapshot', () => { expect(theme).toMatchSnapshot() }) test('exports colors', () => { expect(typeof colors).toBe('object') }) test('cx works', () => { expect(theme.cx('red.5')).toBe(theme.colors.red[5]) expect(theme.cx('#ff6d00')).toBe('#ff6d00') }) test('hexa works', () => { expect(theme.hexa('primary')).toBe('rgb(228, 45, 66)') expect(theme.hexa('primary', 0.5)).toBe('rgba(228, 45, 66, 0.5)') }) test('gradient works', () => { const sample = theme.gradient('accent', 'info') expect(sample).toMatch('radial-gradient') expect(sample).toMatch(cx('accent')) expect(sample).toMatch(cx('info')) }) test('scales are objects', () => { expect(typeof space).toBe('object') expect(typeof fontSizes).toBe('object') expect(typeof boxShadows).toBe('object') }) test('breakpoints have aliases', () => { aliases.forEach((alias, i) => expect(theme.breakpoints[alias]).toEqual(theme.breakpoints[i]) ) }) test('media queries have aliases', () => { aliases.forEach((alias, i) => expect(theme.mediaQueries[alias]).toEqual(theme.mediaQueries[i]) ) expect(theme.mediaQueries.reduceMotion).toEqual( '@media (prefers-reduced-motion: reduce)' ) expect(theme.mediaQueries.reduceTransparency).toEqual( '@media (prefers-reduced-transparency: reduce)' ) }) }) ================================================ FILE: src/index.js ================================================ export { default as Avatar } from './Avatar' export { default as BackgroundImage } from './BackgroundImage' export { default as Badge } from './Badge' export { default as BlockLink } from './BlockLink' export { default as Box } from './Box' export { default as Button } from './Button' export { default as Card } from './Card' export { default as Container } from './Container' export { default as Field } from './Field' export { default as Flex } from './Flex' export { default as Heading } from './Heading' export { default as Hide } from './Hide' export { default as Icon } from './Icon' export { default as IconButton } from './IconButton' export { default as Image } from './Image' export { default as Input } from './Input' export { default as Label } from './Label' export { default as LargeButton } from './LargeButton' export { default as Link } from './Link' export { default as Loading } from './Loading' export { default as OutlineButton } from './OutlineButton' export { default as Section } from './Section' export { default as Sheet } from './Sheet' export { default as Slider } from './Slider' export { default as Submit } from './Submit' export { default as Text } from './Text' export { default as theme } from './theme' export { default as ThemeProvider } from './ThemeProvider' export * from './theme' ================================================ FILE: src/theme.js ================================================ import palx from 'palx' import { includes, get } from 'lodash' const red = '#e42d42' const blue = '#2d9ce4' export const palette = palx(blue) export const grays = { darker: '#121217', dark: '#17171d', black: palette.black, slate: palette.gray[8], silver: palette.gray[7], smoke: palette.gray[2], snow: palette.gray[0], white: '#ffffff' } export const brand = { primary: red, accent: palette.indigo[4], success: palette.teal[5], info: palette.blue[5], warning: palette.orange[5], error: palette.red[7], muted: grays.silver } export const colors = { ...brand, ...grays, ...palette } export const cx = key => get(colors, key, key) const createMediaQuery = n => `@media screen and (min-width:${n}em)` const addAliases = (arr, aliases) => aliases.forEach((key, i) => Object.defineProperty(arr, key, { enumerable: false, get() { return this[i] } }) ) const aliases = ['sm', 'md', 'lg', 'xl'] export const breakpoints = [32, 48, 64, 80] export const mediaQueries = { ...breakpoints.map(createMediaQuery), reduceMotion: '@media (prefers-reduced-motion: reduce)', reduceTransparency: '@media (prefers-reduced-transparency: reduce)' } addAliases(breakpoints, aliases) addAliases(mediaQueries, aliases) export const space = [0, 6, 12, 18, 24, 36, 72, 108, 144, 288, 432] const emoji = '"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"' export const font = `"Phantom Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif,${emoji}` export const mono = 'SFMono-Regular,"Roboto Mono",Menlo,monospace' export const fontSizes = [13.5, 16, 18, 24, 27, 36, 48, 54, 72, 96] export const regular = 'regular' export const bold = 'bold' // styled-system's `fontWeight` function can hook into the `fontWeights` object export const fontWeights = { regular, bold } export const scaleFactor = 17 / 16 export const transition = `${3 / 16}s cubic-bezier(0.375, 0, 0.675, 1)` // styled-system’s `borderRadius` function can hook into the `radii` object/array export const pill = '9999px' export const radii = ['0px', '4px', '8px', '16px', pill] export const radius = '4px' export const shadowColor = 'rgba(0,0,0,0.125)' export const baseShadow = '0 0 2px 0 rgba(0,0,0,.0625),' export const boxShadows = [ baseShadow + `0 2px 4px 0 ${shadowColor}`, baseShadow + `0 4px 8px 0 ${shadowColor}`, baseShadow + `0 12px 12px 0 ${shadowColor}`, baseShadow + `0 24px 24px 0 ${shadowColor}` ] export const hexa = (color, alpha) => { const hex = cx(color) if (!includes(hex, '#')) return shadowColor const r = parseInt(hex.slice(1, 3), 16), g = parseInt(hex.slice(3, 5), 16), b = parseInt(hex.slice(5, 7), 16) if (alpha >= 0) { return `rgba(${r}, ${g}, ${b}, ${alpha})` } else { return `rgb(${r}, ${g}, ${b})` } } export const gradient = (color1, color2) => `radial-gradient( ellipse farthest-corner at top left, ${cx(color1)} 0%, ${cx(color2)} 100% )` const theme = { breakpoints, mediaQueries, space, mono, font, fontSizes, fontWeights, regular, bold, colors, radii, radius, pill, scaleFactor, transition, boxShadows, shadowColor, cx, hexa, gradient } export default theme ================================================ FILE: test-setup.js ================================================ import 'jest-styled-components' import Enzyme from 'enzyme' import Adapter from 'enzyme-adapter-react-16' Enzyme.configure({ adapter: new Adapter() })