diff --git a/examples/styled-components/package.json b/examples/styled-components/package.json new file mode 100644 index 000000000..e2c04f385 --- /dev/null +++ b/examples/styled-components/package.json @@ -0,0 +1,17 @@ +{ + "name": "docz-example-styled-components", + "version": "0.10.3", + "license": "MIT", + "scripts": { + "dev": "docz dev", + "build": "docz build" + }, + "dependencies": { + "prop-types": "^15.6.2", + "react": "^16.4.2", + "react-dom": "^16.4.2" + }, + "devDependencies": { + "docz": "^0.10.3" + } +} diff --git a/examples/styled-components/src/components/Alert.jsx b/examples/styled-components/src/components/Alert.jsx new file mode 100644 index 000000000..a38574eb5 --- /dev/null +++ b/examples/styled-components/src/components/Alert.jsx @@ -0,0 +1,28 @@ +import React, { Fragment } from 'react' +import styled from 'styled-components' +import t from 'prop-types' + +const kinds = { + info: '#5352ED', + positive: '#2ED573', + negative: '#FF4757', + warning: '#FFA502', +} + +const AlertStyled = styled('div')` + padding: 15px 20px; + background: white; + border-radius: 3px; + color: white; + background: ${({ kind = 'info' }) => kinds[kind]}; +` + +export const Alert = props => + +Alert.propTypes = { + kind: t.oneOf(['info', 'positive', 'negative', 'warning']), +} + +Alert.defaultProps = { + kind: 'info', +} diff --git a/examples/styled-components/src/components/Alert.mdx b/examples/styled-components/src/components/Alert.mdx new file mode 100644 index 000000000..03a0ec9ef --- /dev/null +++ b/examples/styled-components/src/components/Alert.mdx @@ -0,0 +1,40 @@ +--- +name: Alert +menu: Components +--- + +import { Playground, PropsTable } from 'docz' +import { Alert } from './Alert' + +# Alert + +## Properties + + + +## Basic usage + + + Some message + + +## Using different kinds + + + Some message + Some message + Some message + Some message + + +## Use with children as a function + + + {() => { + const message = 'Hello world' + + return ( + {message} + ) + }} + diff --git a/examples/styled-components/src/components/Button.jsx b/examples/styled-components/src/components/Button.jsx new file mode 100644 index 000000000..b89a5342c --- /dev/null +++ b/examples/styled-components/src/components/Button.jsx @@ -0,0 +1,75 @@ +import React from 'react' +import styled from 'styled-components' +import t from 'prop-types' + +const scales = { + small: ` + padding: 5px 10px; + font-size: 14px; + `, + normal: ` + padding: 10px 20px; + font-size: 16px; + `, + big: ` + padding: 20px 30px; + font-size: 18px; + `, +} + +const kind = outline => (bg, color) => { + const boxShadowColor = outline ? bg : 'transparent' + const backgroundColor = outline ? 'transparent' : bg + + return ` + background: ${backgroundColor}; + box-shadow: inset 0 0 0 1px ${boxShadowColor}; + color: ${outline ? bg : color}; + transition: all .3s; + + &:hover { + box-shadow: inset 0 0 0 1000px ${boxShadowColor}; + color: ${color}; + } + ` +} + +const kinds = outline => { + const get = kind(outline) + + return { + primary: get('#1FB6FF', 'white'), + secondary: get('#5352ED', 'white'), + cancel: get('#FF4949', 'white'), + dark: get('#273444', 'white'), + gray: get('#8492A6', 'white'), + } +} + +const getScale = ({ scale = 'normal' }) => scales[scale] +const getKind = ({ kind = 'primary', outline = false }) => kinds(outline)[kind] + +const ButtonStyled = styled('button')` + ${getKind}; + ${getScale}; + cursor: pointer; + margin: 3px 5px; + border: none; + border-radius: 3px; +` + +export const Button = ({ children, ...props }) => ( + {children} +) + +Button.propTypes = { + scales: t.oneOf(['small', 'normal', 'big']), + kind: t.oneOf(['primary', 'secondary', 'cancel', 'dark', 'gray']), + outline: t.bool, +} + +Button.defaultProps = { + scales: 'normal', + kind: 'primary', + outline: false, +} diff --git a/examples/styled-components/src/components/Button.mdx b/examples/styled-components/src/components/Button.mdx new file mode 100644 index 000000000..ccb5530c0 --- /dev/null +++ b/examples/styled-components/src/components/Button.mdx @@ -0,0 +1,57 @@ +--- +name: Button +menu: Components +--- + +import { Playground, PropsTable } from 'docz' +import { Button } from './Button' + +# Button + +Buttons make common actions more obvious and help users more easily perform them. Buttons use labels and sometimes icons to communicate the action that will occur when the user touches them. + +### Best practices + +- Group buttons logically into sets based on usage and importance. +- Ensure that button actions are clear and consistent. +- The main action of a group set can be a primary button. +- Select a single button variation and do not mix them. + +## Properties + + + +## Basic usage + + + + + +## With different sizes + + + + + + + +## With different colors + + + + + + + + + +## Outlined + + + + + + + + + diff --git a/examples/styled-components/src/index.mdx b/examples/styled-components/src/index.mdx new file mode 100644 index 000000000..71f122bbb --- /dev/null +++ b/examples/styled-components/src/index.mdx @@ -0,0 +1,21 @@ +--- +name: Getting Started +route: / +order: 1 +--- + +# Getting Started + +Design systems enable teams to build better products faster by making design reusable—reusability makes scale possible. This is the heart and primary value of design systems. A design system is a collection of reusable components, guided by clear standards, that can be assembled together to build any number of applications. + +Regardless of the technologies and tools behind them, a successful design system follows these guiding principles: + +- **It’s consistent**. The way components are built and managed follows a predictable pattern. +- **It’s self-contained**. Your design system is treated as a standalone dependency. +- **It’s reusable**. You’ve built components so they can be reused in many contexts. +- **It’s accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web. +- **It’s robust**. No matter the product or platform to which your design system is applied, it should perform with grace and minimal bugs. + +## Consistency + +Your first, most important task when starting out is to define the rules of your system, document them, and ensure that everyone follows them. When you have clearly documented code standards and best practices in place, designers and developers from across your organization can easily use and, more importantly, contribute to your design system.