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

Commit 9fa000d

Browse files
committed
docs: add env variables example
1 parent 2e888b3 commit 9fa000d

10 files changed

Lines changed: 175 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GATSBY_API_URL=https://dev.example.com/api
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.docz
2+
node_modules
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Docz With Env Variables Example
2+
3+
## Using `create-docz-app`
4+
5+
```sh
6+
npx create-docz-app docz-app-with-env-variables
7+
# or
8+
yarn create docz-app docz-app-with-env-variables
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-env-variables
15+
mv with-env-variables docz-with-env-variables-example
16+
cd docz-with-env-variables-example
17+
```
18+
19+
## Notes
20+
21+
Environment variables are defined in `gatsby-node.js` by changing the webpack config (process.env.FOO, process.env.PROD) or in .env.* and then imported using `dotenv` in `gatsby-config.js` (process.env.GATSBY_API_URL).
22+
23+
## Setup
24+
25+
```sh
26+
yarn # npm i
27+
```
28+
29+
## Run
30+
31+
```sh
32+
yarn dev # npm run dev
33+
```
34+
35+
## Build
36+
37+
```sh
38+
yarn build # npm run build
39+
```
40+
41+
## Serve built app
42+
43+
```sh
44+
yarn serve # npm run serve
45+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
menu: ['Getting Started', 'Components'],
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('dotenv').config({
2+
path: `.env.development`,
3+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
exports.onCreateWebpackConfig = ({ plugins, actions }) => {
2+
const { setWebpackConfig } = actions
3+
4+
setWebpackConfig({
5+
plugins: [
6+
plugins.define({
7+
'process.env.FOO': JSON.stringify('BAR'),
8+
'process.env.PROD': JSON.stringify(true),
9+
}),
10+
],
11+
})
12+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "docz-example-basic",
3+
"private": true,
4+
"version": "2.0.0-rc.41",
5+
"license": "MIT",
6+
"files": [
7+
"src/",
8+
"doczrc.js",
9+
"package.json"
10+
],
11+
"scripts": {
12+
"dev": "docz dev",
13+
"build": "docz build",
14+
"serve": "docz serve"
15+
},
16+
"dependencies": {
17+
"docz": "next",
18+
"prop-types": "^15.7.2",
19+
"react": "^16.11.0",
20+
"react-dom": "^16.11.0"
21+
}
22+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
export const Alert = ({ 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+
<h3>{process.env.PROD ? 'PROD' : 'NOT PROD'}</h3>
23+
<h4>{process.env.FOO}</h4>
24+
<h4>{process.env.GATSBY_API_URL}</h4>
25+
26+
{children}
27+
</div>
28+
)
29+
30+
Alert.propTypes = {
31+
/**
32+
* The kind prop is used to set the alert's background color
33+
*/
34+
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
35+
}
36+
37+
Alert.defaultProps = {
38+
kind: 'info',
39+
}
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.

0 commit comments

Comments
 (0)