feat(docz-plugin-css): add initial version (#78)

* fix(docz-core): reduce from plugins arguments
* feat(docz-plugin-css): add initial version of plugin
* chore(docz-plugin-css): add some examples
This commit is contained in:
Pedro Nauck
2018-06-21 19:37:50 -03:00
committed by GitHub
parent bc0b7e0223
commit 299372ebca
39 changed files with 1982 additions and 39 deletions

View File

@@ -0,0 +1,10 @@
import { css } from 'docz-plugin-css'
export default {
plugins: [
css({
preprocessor: 'less',
cssmodules: true,
}),
],
}

View File

@@ -0,0 +1,20 @@
{
"name": "docz-example-css-less",
"version": "0.2.9",
"license": "MIT",
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"classnames": "^2.2.6",
"docz": "^0.2.9",
"docz-core": "^0.2.9",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1"
},
"devDependencies": {
"docz-plugin-css": "^0.2.9"
}
}

View File

@@ -0,0 +1,23 @@
import React, { Fragment } from 'react'
import cx from 'classnames'
import t from 'prop-types'
import styles from './Alert.module.less'
export const Alert = ({ children, kind }) => (
<div
className={cx(styles.alert, {
[styles[kind]]: true,
})}
>
{children}
</div>
)
Alert.propTypes = {
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
}
Alert.defaultProps = {
kind: 'info',
}

View File

@@ -0,0 +1,41 @@
---
name: Alert
menu: Components
---
import './index.less'
import { Playground, PropsTable } from 'docz'
import { Alert } from './Alert'
# Alert
## Properties
<PropsTable of={Alert} />
## Basic usage
<Playground>
<Alert>Some message</Alert>
</Playground>
## Using different kinds
<Playground>
<Alert kind="info">Some message</Alert>
<Alert kind="positive">Some message</Alert>
<Alert kind="negative">Some message</Alert>
<Alert kind="warning">Some message</Alert>
</Playground>
## Use with children as a function
<Playground>
{() => {
const message = 'Hello world'
return (
<Alert>{message}</Alert>
)
}}
</Playground>

View File

@@ -0,0 +1,22 @@
.alert {
padding: 15px 20px;
background: white;
border-radius: 3px;
color: white;
}
.info {
background: #5352ED;
}
.positive {
background: #2ED573;
}
.negative {
background: #FF4757;
}
.warning {
background: #FFA502;
}

View File

@@ -0,0 +1,3 @@
body {
background: white;
}

View File

@@ -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:
- **Its consistent**. The way components are built and managed follows a predictable pattern.
- **Its self-contained**. Your design system is treated as a standalone dependency.
- **Its reusable**. Youve built components so they can be reused in many contexts.
- **Its accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web.
- **Its 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.

View File

@@ -0,0 +1,10 @@
import { css } from 'docz-plugin-css'
export default {
plugins: [
css({
preprocessor: 'stylus',
cssmodules: true,
}),
],
}

View File

@@ -0,0 +1,20 @@
{
"name": "docz-example-css-postcss",
"version": "0.2.9",
"license": "MIT",
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"classnames": "^2.2.6",
"docz": "^0.2.9",
"docz-core": "^0.2.9",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1"
},
"devDependencies": {
"docz-plugin-css": "^0.2.9"
}
}

View File

@@ -0,0 +1,23 @@
import React, { Fragment } from 'react'
import cx from 'classnames'
import t from 'prop-types'
import styles from './Alert.module.css'
export const Alert = ({ children, kind }) => (
<div
className={cx(styles.alert, {
[styles[kind]]: true,
})}
>
{children}
</div>
)
Alert.propTypes = {
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
}
Alert.defaultProps = {
kind: 'info',
}

View File

@@ -0,0 +1,41 @@
---
name: Alert
menu: Components
---
import './index.css'
import { Playground, PropsTable } from 'docz'
import { Alert } from './Alert'
# Alert
## Properties
<PropsTable of={Alert} />
## Basic usage
<Playground>
<Alert>Some message</Alert>
</Playground>
## Using different kinds
<Playground>
<Alert kind="info">Some message</Alert>
<Alert kind="positive">Some message</Alert>
<Alert kind="negative">Some message</Alert>
<Alert kind="warning">Some message</Alert>
</Playground>
## Use with children as a function
<Playground>
{() => {
const message = 'Hello world'
return (
<Alert>{message}</Alert>
)
}}
</Playground>

View File

@@ -0,0 +1,22 @@
.alert {
padding: 15px 20px;
background: white;
border-radius: 3px;
color: white;
}
.info {
background: #5352ED;
}
.positive {
background: #2ED573;
}
.negative {
background: #FF4757;
}
.warning {
background: #FFA502;
}

View File

@@ -0,0 +1,3 @@
body {
background: white;
}

View File

@@ -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:
- **Its consistent**. The way components are built and managed follows a predictable pattern.
- **Its self-contained**. Your design system is treated as a standalone dependency.
- **Its reusable**. Youve built components so they can be reused in many contexts.
- **Its accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web.
- **Its 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.

View File

@@ -0,0 +1,10 @@
import { css } from 'docz-plugin-css'
export default {
plugins: [
css({
preprocessor: 'sass',
cssmodules: true,
}),
],
}

View File

@@ -0,0 +1,20 @@
{
"name": "docz-example-css-sass",
"version": "0.2.9",
"license": "MIT",
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"classnames": "^2.2.6",
"docz": "^0.2.9",
"docz-core": "^0.2.9",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1"
},
"devDependencies": {
"docz-plugin-css": "^0.2.9"
}
}

View File

@@ -0,0 +1,23 @@
import React, { Fragment } from 'react'
import cx from 'classnames'
import t from 'prop-types'
import styles from './Alert.module.scss'
export const Alert = ({ children, kind }) => (
<div
className={cx(styles.alert, {
[styles[kind]]: true,
})}
>
{children}
</div>
)
Alert.propTypes = {
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
}
Alert.defaultProps = {
kind: 'info',
}

View File

@@ -0,0 +1,41 @@
---
name: Alert
menu: Components
---
import './index.scss'
import { Playground, PropsTable } from 'docz'
import { Alert } from './Alert'
# Alert
## Properties
<PropsTable of={Alert} />
## Basic usage
<Playground>
<Alert>Some message</Alert>
</Playground>
## Using different kinds
<Playground>
<Alert kind="info">Some message</Alert>
<Alert kind="positive">Some message</Alert>
<Alert kind="negative">Some message</Alert>
<Alert kind="warning">Some message</Alert>
</Playground>
## Use with children as a function
<Playground>
{() => {
const message = 'Hello world'
return (
<Alert>{message}</Alert>
)
}}
</Playground>

View File

@@ -0,0 +1,22 @@
.alert {
padding: 15px 20px;
background: white;
border-radius: 3px;
color: white;
}
.info {
background: #5352ED;
}
.positive {
background: #2ED573;
}
.negative {
background: #FF4757;
}
.warning {
background: #FFA502;
}

View File

@@ -0,0 +1,3 @@
body {
background: white;
}

View File

@@ -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:
- **Its consistent**. The way components are built and managed follows a predictable pattern.
- **Its self-contained**. Your design system is treated as a standalone dependency.
- **Its reusable**. Youve built components so they can be reused in many contexts.
- **Its accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web.
- **Its 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.

View File

@@ -0,0 +1,10 @@
import { css } from 'docz-plugin-css'
export default {
plugins: [
css({
preprocessor: 'stylus',
cssmodules: true,
}),
],
}

View File

@@ -0,0 +1,20 @@
{
"name": "docz-example-css-stylus",
"version": "0.2.9",
"license": "MIT",
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"classnames": "^2.2.6",
"docz": "^0.2.9",
"docz-core": "^0.2.9",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1"
},
"devDependencies": {
"docz-plugin-css": "^0.2.9"
}
}

View File

@@ -0,0 +1,23 @@
import React, { Fragment } from 'react'
import cx from 'classnames'
import t from 'prop-types'
import styles from './Alert.module.styl'
export const Alert = ({ children, kind }) => (
<div
className={cx(styles.alert, {
[styles[kind]]: true,
})}
>
{children}
</div>
)
Alert.propTypes = {
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
}
Alert.defaultProps = {
kind: 'info',
}

View File

@@ -0,0 +1,41 @@
---
name: Alert
menu: Components
---
import './index.styl'
import { Playground, PropsTable } from 'docz'
import { Alert } from './Alert'
# Alert
## Properties
<PropsTable of={Alert} />
## Basic usage
<Playground>
<Alert>Some message</Alert>
</Playground>
## Using different kinds
<Playground>
<Alert kind="info">Some message</Alert>
<Alert kind="positive">Some message</Alert>
<Alert kind="negative">Some message</Alert>
<Alert kind="warning">Some message</Alert>
</Playground>
## Use with children as a function
<Playground>
{() => {
const message = 'Hello world'
return (
<Alert>{message}</Alert>
)
}}
</Playground>

View File

@@ -0,0 +1,22 @@
.alert {
padding: 15px 20px;
background: white;
border-radius: 3px;
color: white;
}
.info {
background: #5352ED;
}
.positive {
background: #2ED573;
}
.negative {
background: #FF4757;
}
.warning {
background: #FFA502;
}

View File

@@ -0,0 +1,3 @@
body {
background: white;
}

View File

@@ -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:
- **Its consistent**. The way components are built and managed follows a predictable pattern.
- **Its self-contained**. Your design system is treated as a standalone dependency.
- **Its reusable**. Youve built components so they can be reused in many contexts.
- **Its accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web.
- **Its 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.