Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit 8acbe18

Browse files
simonreletrakannimer
authored andcommitted
docs: add example for the themesDir option (#1105) (#1218)
1 parent 41039a6 commit 8acbe18

10 files changed

Lines changed: 184 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Documenting code is one of the most important and time-heavy processes when you'
140140
- **[with typescript](https://github.com/pedronauck/docz/tree/master/examples/typescript)** - Using Docz with Typescript.
141141
- **[with flow](https://github.com/pedronauck/docz/tree/master/examples/flow)** - Using Docz with Flow.
142142
- **[with images](https://github.com/pedronauck/docz/tree/master/examples/images)** - Using Docz with images in mdx and jsx.
143+
- **[with custom themes](https://github.com/pedronauck/docz/tree/master/examples/with-themes-dir)** - Using Docz with a custom themes directory.
143144

144145
- **[with sass](https://github.com/pedronauck/docz/tree/master/examples/sass)** - Using Docz parsing CSS with SASS.
145146
- **[with less](https://github.com/pedronauck/docz/tree/master/examples/less)** - Using Docz parsing CSS with LESS.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.docz
2+
node_modules

examples/with-themes-dir/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# With themesDir Docz example
2+
3+
## Using `create-docz-app`
4+
5+
```sh
6+
npx create-docz-app docz-app-with-themes-dir
7+
# or
8+
yarn create docz-app docz-app-with-themes-dir
9+
```
10+
11+
## Download manually
12+
13+
```sh
14+
curl https://codeload.github.com/doczjs/docz/tar.gz/master | tar -xz --strip=2 docz-master/examples/with-themes-dir
15+
mv with-themes-dir docz-with-themes-dir-example
16+
cd docz-with-themes-dir-example
17+
```
18+
19+
## Setup
20+
21+
```sh
22+
yarn # npm i
23+
```
24+
25+
## Run
26+
27+
```sh
28+
yarn dev # npm run dev
29+
```
30+
31+
## Build
32+
33+
```sh
34+
yarn build # npm run build
35+
```
36+
37+
## Serve built app
38+
39+
```sh
40+
yarn serve # npm run serve
41+
```

examples/with-themes-dir/doczrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
themesDir: 'theme',
3+
menu: ['Getting Started', 'Components'],
4+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "docz-example-with-themes-dir",
3+
"private": true,
4+
"version": "2.0.0-rc.41",
5+
"license": "MIT",
6+
"files": [
7+
"src/",
8+
"theme/",
9+
"doczrc.js",
10+
"package.json"
11+
],
12+
"scripts": {
13+
"dev": "docz dev",
14+
"build": "docz build",
15+
"serve": "docz serve"
16+
},
17+
"dependencies": {
18+
"docz": "next",
19+
"prop-types": "^15.7.2",
20+
"react": "^16.8.6",
21+
"react-dom": "^16.8.6",
22+
"scheduler": "^0.15.0"
23+
}
24+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react'
2+
import t from 'prop-types'
3+
4+
const kinds = {
5+
info: '#5352ED',
6+
positive: '#2ED573',
7+
negative: '#FF4757',
8+
warning: '#FFA502',
9+
}
10+
11+
const AlertStyled = ({ children, kind, ...rest }) => (
12+
<div
13+
style={{
14+
padding: 20,
15+
background: 'white',
16+
borderRadius: 3,
17+
color: 'white',
18+
background: kinds[kind],
19+
}}
20+
{...rest}
21+
>
22+
{children}
23+
</div>
24+
)
25+
26+
export const Alert = props => <AlertStyled {...props} />
27+
28+
Alert.propTypes = {
29+
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
30+
}
31+
32+
Alert.defaultProps = {
33+
kind: 'info',
34+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Alert
3+
menu: Components
4+
---
5+
6+
import { Playground, Props } from 'docz'
7+
import { Alert } from './Alert'
8+
9+
# Alert
10+
11+
## Properties
12+
13+
<Props of={Alert} />
14+
15+
## Basic usage
16+
17+
<Playground>
18+
<Alert>Some message</Alert>
19+
</Playground>
20+
21+
## Using different kinds
22+
23+
<Playground>
24+
<Alert kind="info">Some message</Alert>
25+
<Alert kind="positive">Some message</Alert>
26+
<Alert kind="negative">Some message</Alert>
27+
<Alert kind="warning">Some message</Alert>
28+
</Playground>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Getting Started
3+
route: /
4+
---
5+
6+
# Getting Started
7+
8+
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.
9+
10+
Regardless of the technologies and tools behind them, a successful design system follows these guiding principles:
11+
12+
- **It’s consistent**. The way components are built and managed follows a predictable pattern.
13+
- **It’s self-contained**. Your design system is treated as a standalone dependency.
14+
- **It’s reusable**. You’ve built components so they can be reused in many contexts.
15+
- **It’s accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web.
16+
- **It’s robust**. No matter the product or platform to which your design system is applied, it should perform with grace and minimal bugs.
17+
18+
## Consistency
19+
20+
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.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @jsx jsx */
2+
import { jsx, Flex } from 'theme-ui'
3+
import { Link, useConfig } from 'docz'
4+
5+
import * as styles from './styles'
6+
7+
export const Logo = () => {
8+
const config = useConfig()
9+
return (
10+
<Flex aligmItems="center" sx={styles.logo} data-testid="logo">
11+
<Link to="/" sx={styles.link}>
12+
{config.title.toUpperCase()}
13+
</Link>
14+
</Flex>
15+
)
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const logo = {
2+
letterSpacing: '-0.02em',
3+
fontWeight: 600,
4+
fontSize: 4,
5+
}
6+
7+
export const link = {
8+
fontWeight: 600,
9+
color: 'header.text',
10+
textDecoration: 'none',
11+
':hover': {
12+
color: 'primary',
13+
},
14+
}

0 commit comments

Comments
 (0)