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

Commit 06c89e7

Browse files
committed
docs: add logo in sidebar example
1 parent 3064af4 commit 06c89e7

8 files changed

Lines changed: 223 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.docz
2+
node_modules

examples/logo-in-sidebar/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Logo In Sidebar Docz example
2+
3+
## Using `create-docz-app`
4+
5+
```sh
6+
npx create-docz-app docz-app-logo-in-sidebar --example logo-in-sidebar
7+
# or
8+
yarn create docz-app docz-app-logo-in-sidebar --example logo-in-sidebar
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/logo-in-sidebar
15+
mv logo-in-sidebar docz-logo-in-sidebar-example
16+
cd docz-logo-in-sidebar-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+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "docz-example-logo-in-sidebar",
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.8.6",
20+
"react-dom": "^16.8.6",
21+
"scheduler": "^0.15.0"
22+
}
23+
}
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+
export const Alert = ({ children, kind, ...rest }) => (
12+
<div
13+
style={{
14+
padding: 20,
15+
borderRadius: 3,
16+
color: "white",
17+
background: kinds[kind] || "white"
18+
}}
19+
{...rest}
20+
>
21+
{children}
22+
</div>
23+
);
24+
25+
Alert.propTypes = {
26+
/**
27+
* The kind prop is used to set the alert's background color
28+
*/
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const Header = () => {
2+
return null;
3+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/** @jsx jsx */
2+
import React, { useState, useRef, useEffect } from "react";
3+
import { Global } from "@emotion/core";
4+
import { jsx, Box } from "theme-ui";
5+
import { useMenus, useCurrentDoc } from "docz";
6+
7+
import * as styles from "gatsby-theme-docz/src/components/Sidebar/styles";
8+
import { NavSearch } from "gatsby-theme-docz/src/components/NavSearch";
9+
import { NavLink } from "gatsby-theme-docz/src/components/NavLink";
10+
import { NavGroup } from "gatsby-theme-docz/src/components/NavGroup";
11+
12+
export const Sidebar = React.forwardRef((props, ref) => {
13+
const [query, setQuery] = useState("");
14+
const menus = useMenus({ query });
15+
const currentDoc = useCurrentDoc();
16+
const currentDocRef = useRef();
17+
const handleChange = ev => {
18+
setQuery(ev.target.value);
19+
};
20+
useEffect(() => {
21+
if (ref.current && currentDocRef.current) {
22+
ref.current.scrollTo(0, currentDocRef.current.offsetTop);
23+
}
24+
}, []);
25+
return (
26+
<>
27+
<Box onClick={props.onClick} sx={styles.overlay(props)}>
28+
{props.open && <Global styles={styles.global} />}
29+
</Box>
30+
<Box ref={ref} sx={styles.wrapper(props)} data-testid="sidebar">
31+
<img src="https://placekitten.com/200/100" />
32+
33+
<NavSearch
34+
placeholder="Type to search..."
35+
value={query}
36+
onChange={handleChange}
37+
/>
38+
{menus &&
39+
menus.map(menu => {
40+
if (!menu.route)
41+
return <NavGroup key={menu.id} item={menu} sidebarRef={ref} />;
42+
if (menu.route === currentDoc.route) {
43+
return (
44+
<NavLink key={menu.id} item={menu} ref={currentDocRef}>
45+
{menu.name}
46+
</NavLink>
47+
);
48+
}
49+
return (
50+
<NavLink key={menu.id} item={menu}>
51+
{menu.name}
52+
</NavLink>
53+
);
54+
})}
55+
</Box>
56+
</>
57+
);
58+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.
21+
22+
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.
23+
24+
Regardless of the technologies and tools behind them, a successful design system follows these guiding principles:
25+
26+
- **It’s consistent**. The way components are built and managed follows a predictable pattern.
27+
- **It’s self-contained**. Your design system is treated as a standalone dependency.
28+
- **It’s reusable**. You’ve built components so they can be reused in many contexts.
29+
- **It’s accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web.
30+
- **It’s robust**. No matter the product or platform to which your design system is applied, it should perform with grace and minimal bugs.
31+
32+
## Consistency
33+
34+
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)