Skip to content

Commit

Permalink
feat(docz-plugin-css): add initial version (#78)
Browse files Browse the repository at this point in the history
* fix(docz-core): reduce from plugins arguments
* feat(docz-plugin-css): add initial version of plugin
* chore(docz-plugin-css): add some examples
  • Loading branch information
pedronauck authored Jun 21, 2018
1 parent bc0b7e0 commit 299372e
Show file tree
Hide file tree
Showing 39 changed files with 1,982 additions and 39 deletions.
10 changes: 10 additions & 0 deletions examples/css-less/doczrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { css } from 'docz-plugin-css'

export default {
plugins: [
css({
preprocessor: 'less',
cssmodules: true,
}),
],
}
20 changes: 20 additions & 0 deletions examples/css-less/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
23 changes: 23 additions & 0 deletions examples/css-less/src/components/Alert.jsx
Original file line number Diff line number Diff line change
@@ -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',
}
41 changes: 41 additions & 0 deletions examples/css-less/src/components/Alert.mdx
Original file line number Diff line number Diff line change
@@ -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>
22 changes: 22 additions & 0 deletions examples/css-less/src/components/Alert.module.less
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 3 additions & 0 deletions examples/css-less/src/components/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: white;
}
21 changes: 21 additions & 0 deletions examples/css-less/src/index.mdx
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions examples/css-postcss/doczrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { css } from 'docz-plugin-css'

export default {
plugins: [
css({
preprocessor: 'stylus',
cssmodules: true,
}),
],
}
20 changes: 20 additions & 0 deletions examples/css-postcss/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
23 changes: 23 additions & 0 deletions examples/css-postcss/src/components/Alert.jsx
Original file line number Diff line number Diff line change
@@ -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',
}
41 changes: 41 additions & 0 deletions examples/css-postcss/src/components/Alert.mdx
Original file line number Diff line number Diff line change
@@ -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>
22 changes: 22 additions & 0 deletions examples/css-postcss/src/components/Alert.module.css
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 3 additions & 0 deletions examples/css-postcss/src/components/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: white;
}
21 changes: 21 additions & 0 deletions examples/css-postcss/src/index.mdx
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions examples/css-sass/doczrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { css } from 'docz-plugin-css'

export default {
plugins: [
css({
preprocessor: 'sass',
cssmodules: true,
}),
],
}
20 changes: 20 additions & 0 deletions examples/css-sass/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
23 changes: 23 additions & 0 deletions examples/css-sass/src/components/Alert.jsx
Original file line number Diff line number Diff line change
@@ -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',
}
41 changes: 41 additions & 0 deletions examples/css-sass/src/components/Alert.mdx
Original file line number Diff line number Diff line change
@@ -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>
Loading

0 comments on commit 299372e

Please sign in to comment.