Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
chore(docz): add css preprocessor examples and info
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperorb authored and rakannimer committed Oct 5, 2019
1 parent a53a1fe commit 38a4709
Show file tree
Hide file tree
Showing 29 changed files with 427 additions and 5 deletions.
25 changes: 25 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,28 @@ export default ({ children }) => (
</div>
)
```

## CSS preprocessors managed by gatsby

CSS preprocessors and modules were handled by [`docz-plugin-css`](https://github.com/doczjs/docz-plugin-css) which hooked into the bundler config to add different loader support via webpack.

With the change to gatsby preprocessors like `sass` can be handled by gatby via [Plugins](https://www.gatsbyjs.org/plugins/)

These plugins are added by adding a `gatsby-config.js` in your project root or modifying an existing one. For example if you want to add support for `sass` you would do the following:

1. Install [`node-sass`](https://github.com/sass/node-sass) and [`gatsby-plugin-sass`](https://www.gatsbyjs.org/packages/gatsby-plugin-sass/)
```bash
# npm
npm install --save node-sass gatsby-plugin-sass

# yarn
yarn add node-sass gatsby-plugin-sass
```

2. Add the plugin to your `gatsby-config.js`
```js
//gatsby-config.js
module.exports = {
plugins: ['gatsby-plugin-sass']
}
```
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ Documenting code is one of the most important and time-heavy processes when you'
- **[with flow](https://github.com/pedronauck/docz/tree/master/examples/flow)** - Using Docz with Flow.
- **[with images](https://github.com/pedronauck/docz/tree/master/examples/images)** - Using Docz with images in mdx and jsx.

<!-- TODO: Add missing v2 examples-->
<!-- - **[with sass](https://github.com/pedronauck/docz-plugin-css/tree/master/examples/css-sass)** - Using Docz parsing CSS with SASS.
- **[with less](https://github.com/pedronauck/docz-plugin-css/tree/master/examples/css-less)** - Using Docz parsing CSS with LESS.
- **[with postcss](https://github.com/pedronauck/docz-plugin-css/tree/master/examples/css-postcss)** - Using Docz parsing CSS with PostCSS.
- **[with stylus](https://github.com/pedronauck/docz-plugin-css/tree/master/examples/css-stylus)** - Using Docz parsing CSS with Stylus. -->
- **[with sass](https://github.com/pedronauck/docz/tree/master/examples/sass)** - Using Docz parsing CSS with SASS.
- **[with less](https://github.com/pedronauck/docz/tree/master/examples/less)** - Using Docz parsing CSS with LESS.
- **[with stylus](https://github.com/pedronauck/docz/tree/master/examples/css-stylus)** - Using Docz parsing CSS with Stylus.
- **with css modules**: works out of the box with gatsby

## 👉🏻 &nbsp; More info on [our website](https://docz.site)

Expand Down
2 changes: 2 additions & 0 deletions examples/less/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.docz
node_modules
29 changes: 29 additions & 0 deletions examples/less/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# less Docz example

## Using `create-docz-app`

```sh
npx create-docz-app docz-app-less --example less
# or
yarn create docz-app docz-app-less --example less
```

## Download manually

```sh
curl https://codeload.github.com/doczjs/docz/tar.gz/master | tar -xz --strip=2 docz-master/examples/less
mv less docz-less-example
cd docz-less-example
```

## Setup

```sh
yarn # npm i
```

## Run

```sh
yarn dev # npm run dev
```
4 changes: 4 additions & 0 deletions examples/less/doczrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
title: 'Docz Less',
menu: ['Getting Started', 'Components'],
}
3 changes: 3 additions & 0 deletions examples/less/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ['gatsby-plugin-less'],
}
24 changes: 24 additions & 0 deletions examples/less/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"private": true,
"name": "docz-example-less",
"version": "2.0.0-rc.52",
"license": "MIT",
"files": [
"src/",
"doczrc.js",
"package.json"
],
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"docz": "next",
"gatsby-plugin-less": "3.0.9",
"less": "3.10.3",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"scheduler": "^0.15.0"
}
}
18 changes: 18 additions & 0 deletions examples/less/src/components/Alert.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import t from 'prop-types'

import './Alert.less'

export const Alert = ({ children, kind, ...rest }) => (
<div className="Alert" {...rest}>
{children}
</div>
)

Alert.propTypes = {
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
}

Alert.defaultProps = {
kind: 'info',
}
5 changes: 5 additions & 0 deletions examples/less/src/components/Alert.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Alert {
padding: 1rem;
margin: 1rem;
border-radius: 0.25rem;
}
28 changes: 28 additions & 0 deletions examples/less/src/components/Alert.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Alert
menu: Components
---

import { Playground, Props } from 'docz'
import { Alert } from './Alert'

# Alert

## Properties

<Props 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>
20 changes: 20 additions & 0 deletions examples/less/src/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Getting Started
route: /
---

# 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.
2 changes: 2 additions & 0 deletions examples/sass/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.docz
node_modules
29 changes: 29 additions & 0 deletions examples/sass/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Sass Docz example

## Using `create-docz-app`

```sh
npx create-docz-app docz-app-sass --example sass
# or
yarn create docz-app docz-app-sass --example sass
```

## Download manually

```sh
curl https://codeload.github.com/doczjs/docz/tar.gz/master | tar -xz --strip=2 docz-master/examples/sass
mv sass docz-sass-example
cd docz-sass-example
```

## Setup

```sh
yarn # npm i
```

## Run

```sh
yarn dev # npm run dev
```
4 changes: 4 additions & 0 deletions examples/sass/doczrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
title: 'Docz Sass',
menu: ['Getting Started', 'Components'],
}
3 changes: 3 additions & 0 deletions examples/sass/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ['gatsby-plugin-sass'],
}
24 changes: 24 additions & 0 deletions examples/sass/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"private": true,
"name": "docz-example-sass",
"version": "2.0.0-rc.52",
"license": "MIT",
"files": [
"src/",
"doczrc.js",
"package.json"
],
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"docz": "next",
"gatsby-plugin-sass": "2.1.17",
"node-sass": "4.12.0",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"scheduler": "^0.15.0"
}
}
18 changes: 18 additions & 0 deletions examples/sass/src/components/Alert.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import t from 'prop-types'

import './Alert.scss'

export const Alert = ({ children, kind, ...rest }) => (
<div className="Alert" {...rest}>
{children}
</div>
)

Alert.propTypes = {
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
}

Alert.defaultProps = {
kind: 'info',
}
28 changes: 28 additions & 0 deletions examples/sass/src/components/Alert.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Alert
menu: Components
---

import { Playground, Props } from 'docz'
import { Alert } from './Alert'

# Alert

## Properties

<Props 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>
5 changes: 5 additions & 0 deletions examples/sass/src/components/Alert.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Alert {
padding: 1rem;
margin: 1rem;
border-radius: 0.25rem;
}
20 changes: 20 additions & 0 deletions examples/sass/src/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Getting Started
route: /
---

# 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.
2 changes: 2 additions & 0 deletions examples/stylus/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.docz
node_modules
29 changes: 29 additions & 0 deletions examples/stylus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# stylus Docz example

## Using `create-docz-app`

```sh
npx create-docz-app docz-app-stylus --example stylus
# or
yarn create docz-app docz-app-stylus --example stylus
```

## Download manually

```sh
curl https://codeload.github.com/doczjs/docz/tar.gz/master | tar -xz --strip=2 docz-master/examples/stylus
mv stylus docz-stylus-example
cd docz-stylus-example
```

## Setup

```sh
yarn # npm i
```

## Run

```sh
yarn dev # npm run dev
```
4 changes: 4 additions & 0 deletions examples/stylus/doczrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
title: 'Docz Stylus',
menu: ['Getting Started', 'Components'],
}
3 changes: 3 additions & 0 deletions examples/stylus/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ['gatsby-plugin-stylus'],
}
23 changes: 23 additions & 0 deletions examples/stylus/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"private": true,
"name": "docz-example-stylus",
"version": "2.0.0-rc.52",
"license": "MIT",
"files": [
"src/",
"doczrc.js",
"package.json"
],
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"docz": "next",
"gatsby-plugin-stylus": "2.1.11",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"scheduler": "^0.15.0"
}
}
Loading

0 comments on commit 38a4709

Please sign in to comment.