Skip to content

Commit 18f1a5e

Browse files
authored
Merge pull request #71 from code-hike/add-storybook-docs
Add storybook docs
2 parents 4aa8849 + 3ae9f6b commit 18f1a5e

36 files changed

+2064
-1232
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ dist
55
yarn-error.log
66
.prettierignore
77
.env
8-
.vscode
8+
.vscode
9+
storybook-static

.gitmodules

-6
This file was deleted.

contributing.md

-13
This file was deleted.

external/new-react-website

-1
This file was deleted.

external/site

-1
This file was deleted.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"watch-package": "lerna run --scope @*/mini-frame --include-dependencies --parallel x -- watch",
1313
"watch-all": "lerna run --parallel x -- watch",
1414
"storybook": "lerna run --scope storybook start --stream",
15+
"docs": "lerna run build-docs --stream",
1516
"dev": "lerna run --scope react-website dev --stream",
1617
"release": "auto shipit"
1718
},

packages/mini-browser/src/use-steps.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
import React from "react"
22

33
type MiniBrowserStep = {
4+
/**
5+
* The url to display on the navigation bar.
6+
*/
47
url?: string
8+
/**
9+
* Override the url used for the iframe and "Open in new tab" button.
10+
*/
511
loadUrl?: string
6-
children?: React.ReactNode
12+
/**
13+
* Scale the content of the browser.
14+
*/
715
zoom?: number
16+
/**
17+
* Prepend the current origin to the url.
18+
*/
819
prependOrigin?: boolean
20+
/**
21+
* The content to display in the browser. If not provided, an iframe for the url will be displayed.
22+
*/
23+
children?: React.ReactNode
924
}
1025

1126
type InternalStep = {

packages/storybook/package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"private": true,
44
"version": "0.3.0-next.0",
55
"scripts": {
6-
"start": "start-storybook -c ./src",
7-
"build-storybook": "build-storybook -c ./src -o ./dist"
6+
"start": "start-storybook -c ./src -s ./public",
7+
"build-storybook": "build-storybook -c ./src -s ./public -o ./dist",
8+
"build-docs": "build-storybook -c ./src -s ./public --docs"
89
},
910
"dependencies": {
1011
"@code-hike/code-diff": "0.3.0-next.0",
@@ -17,16 +18,16 @@
1718
"@code-hike/sim-user": "0.3.0-next.0",
1819
"@code-hike/smooth-column": "0.3.0-next.0",
1920
"@code-hike/smooth-lines": "0.3.0-next.0",
20-
"@storybook/addon-actions": "^6.0.26",
21-
"@storybook/addon-controls": "^6.0.26",
22-
"@storybook/addon-docs": "^6.0.26",
2321
"prism-svelte": "^0.4.7",
2422
"react": "^16.9.0",
2523
"react-dom": "^16.9.0"
2624
},
2725
"devDependencies": {
2826
"@babel/core": "^7.4.5",
29-
"@storybook/react": "^6.0.26",
27+
"@storybook/addon-essentials": "^6.3.0",
28+
"@storybook/addons": "^6.3.2",
29+
"@storybook/react": "^6.3.0",
30+
"@storybook/theming": "^6.3.2",
3031
"babel-loader": "^8.0.6",
3132
"chromatic": "^5.9.2"
3233
}
35 KB
Loading
1.18 KB
Loading
2.6 KB
Loading
7.54 KB
Loading

packages/storybook/public/favicon.ico

1.12 KB
Binary file not shown.

packages/storybook/public/logo.png

17.7 KB
Loading

packages/storybook/src/code.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { WithProgress } from "./utils"
44
import { codeDiff } from "@code-hike/code-diff"
55

66
export default {
7-
title: "Smooth Code",
7+
title: "Test/Smooth Code",
88
argTypes: {
99
center: { control: "boolean" },
1010
containerWidth: {

packages/storybook/src/column.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { WithProgress } from "./utils"
33
import { SmoothColumn } from "@code-hike/smooth-column"
44

55
export default {
6-
title: "Smooth Column",
6+
title: "Test/Smooth Column",
77
}
88
export const oneExitOneEnter = () => {
99
const padding = 10

packages/storybook/src/components.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// importing and exporting components
2+
// so we can use them with Storybook's ArgsTable
3+
4+
import * as mb from "@code-hike/mini-browser"
5+
6+
export const MiniBrowser = mb.MiniBrowser
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Meta, Story, Canvas } from "@storybook/addon-docs"
2+
3+
<Meta title="Code Hike" />
4+
5+
The docs for Code Hike's building blocks.
6+
7+
For more info and higher level packages, see [codehike.org](https://codehike.org).

packages/storybook/src/main.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
module.exports = {
2-
stories: ["*.story.js"],
2+
stories: ["intro.story.mdx", "*.story.@(js|mdx|tsx)"],
33
addons: [
44
"@storybook/addon-docs",
55
"@storybook/addon-controls",
66
"@storybook/addon-actions",
77
],
8+
typescript: {
9+
reactDocgen: "react-docgen-typescript",
10+
reactDocgenTypescriptOptions: {
11+
propFilter: prop => true,
12+
// componentNameResolver: (exp, source) =>
13+
// console.log("!!!$$$", exp, source) || true,
14+
compilerOptions: {
15+
allowSyntheticDefaultImports: false,
16+
esModuleInterop: false,
17+
},
18+
},
19+
},
820
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<link
2+
rel="icon"
3+
type="image/png"
4+
sizes="32x32"
5+
href="/favicon-32x32.png"
6+
/>
7+
<link
8+
rel="icon"
9+
type="image/png"
10+
sizes="16x16"
11+
href="/favicon-16x16.png"
12+
/>
13+
14+
<style>
15+
.sidebar-header > *:first-child {
16+
margin: 0;
17+
}
18+
.sidebar-header > *:nth-child(2) {
19+
display: none;
20+
}
21+
.search-field {
22+
display: none !important;
23+
}
24+
</style>

packages/storybook/src/manager.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { addons } from "@storybook/addons"
2+
import { create } from "@storybook/theming"
3+
4+
const isProd = process.env.NODE_ENV === "production"
5+
6+
// https://storybook.js.org/docs/react/configure/theming
7+
const theme = create({
8+
base: "light",
9+
brandTitle: "Code Hike",
10+
brandUrl: "https://codehike.org",
11+
brandImage: "/codehike.png",
12+
appBg: "#ffffff",
13+
appContentBg: "#eaedf6",
14+
})
15+
16+
// https://storybook.js.org/docs/react/configure/features-and-behavior
17+
addons.setConfig({
18+
theme,
19+
isFullscreen: false,
20+
showNav: true,
21+
showPanel: false,
22+
panelPosition: "bottom",
23+
enableShortcuts: false,
24+
isToolshown: true,
25+
selectedPanel: undefined,
26+
initialActive: "sidebar",
27+
sidebar: {
28+
showRoots: true,
29+
collapsedRoots: ["test"],
30+
},
31+
toolbar: {
32+
title: { hidden: false },
33+
zoom: { hidden: true },
34+
eject: { hidden: false },
35+
copy: { hidden: true },
36+
fullscreen: { hidden: true },
37+
},
38+
})

packages/storybook/src/mini-browser-hike.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "@code-hike/mini-browser/dist/index.css"
44
import { WithProgress, Page } from "./utils"
55

66
export default {
7-
title: "Mini Browser Hike",
7+
title: "Test/Mini Browser Hike",
88
}
99

1010
export const basic = () => (

packages/storybook/src/mini-browser.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "@code-hike/mini-browser/dist/index.css"
44
import { WithProgress, Page } from "./utils"
55

66
export default {
7-
title: "Mini Browser",
7+
title: "Test/Mini Browser",
88
}
99

1010
export const basic = () => (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import {
2+
Meta,
3+
Story,
4+
Canvas,
5+
ArgsTable,
6+
} from "@storybook/addon-docs"
7+
import { MiniBrowser } from "./components"
8+
9+
<Meta
10+
title="Mini Browser"
11+
component={MiniBrowser}
12+
argTypes={{ url: { control: { type: "text" } } }}
13+
/>
14+
15+
# `<MiniBrowser />`
16+
17+
Import it with:
18+
19+
```js
20+
import { MiniBrowser } from "@code-hike/mini-browser"
21+
```
22+
23+
A component that looks like a browser.
24+
25+
### Usage without `children`
26+
27+
If you don't pass `children`, it will show an iframe using the `url` prop. If you want to display an url but load a different one use the `loadUrl` prop.
28+
29+
export const Template = props => <MiniBrowser {...props} />
30+
31+
<Canvas>
32+
<Story
33+
name="MiniBrowser without children"
34+
args={{
35+
url: "google.com",
36+
loadUrl: "https://whatismyviewport.com/",
37+
zoom: 0.5,
38+
style: { height: "200px" },
39+
}}
40+
argTypes={{ url: { control: { type: "text" } } }}
41+
>
42+
{Template.bind({})}
43+
</Story>
44+
</Canvas>
45+
46+
## Props
47+
48+
<ArgsTable story="MiniBrowser without children" />
49+
50+
## Usage with `children`
51+
52+
If you pass `children`, it will render the children inside the iframe.
53+
54+
<Canvas>
55+
<Story
56+
name="MiniBrowser with children"
57+
args={{
58+
url: "google.com",
59+
loadUrl: "https://whatismyviewport.com/",
60+
style: { height: "200px" },
61+
children: <h1>This is a child</h1>,
62+
}}
63+
argTypes={{ url: { control: { type: "text" } } }}
64+
>
65+
{Template.bind({})}
66+
</Story>
67+
</Canvas>

packages/storybook/src/mini-editor-hike.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Page, WithProgress } from "./utils"
44
import "@code-hike/mini-editor/dist/index.css"
55

66
export default {
7-
title: "Mini Editor Hike",
7+
title: "Test/Mini Editor Hike",
88
}
99

1010
const code1 = `console.log(1)`

packages/storybook/src/mini-editor-tween.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { WithProgress } from "./utils"
44
import "@code-hike/mini-editor/dist/index.css"
55

66
export default {
7-
title: "Mini Editor Tween",
7+
title: "Test/Mini Editor Tween",
88
}
99

1010
export const oneToOne = () => {

packages/storybook/src/mini-editor.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Page } from "./utils"
44
import "@code-hike/mini-editor/dist/index.css"
55

66
export default {
7-
title: "Mini Editor",
7+
title: "Test/Mini Editor",
88
}
99

1010
const code1 = `console.log(1)

packages/storybook/src/mini-frame.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "@code-hike/mini-frame/dist/index.css"
77
import { Page } from "./utils"
88

99
export default {
10-
title: "Mini Frame",
10+
title: "Test/Mini Frame",
1111
}
1212

1313
export const basic = () => (

packages/storybook/src/mini-terminal.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { WithProgress, Page } from "./utils"
77
import "@code-hike/mini-terminal/dist/index.css"
88

99
export default {
10-
title: "Mini Terminal",
10+
title: "Test/Mini Terminal",
1111
}
1212

1313
export const basic = () => (

packages/storybook/src/player.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Video, Controls } from "@code-hike/player"
44
import videoSrc from "./assets/timer.mp4"
55

66
export default {
7-
title: "Player",
7+
title: "Test/Player",
88
}
99

1010
const src = videoSrc

packages/storybook/src/scroller.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Page } from "./utils"
33
import { Scroller, Step } from "@code-hike/scroller"
44

55
export default {
6-
title: "Scroller",
6+
title: "Test/Scroller",
77
}
88

99
const steps = [1, 2, 3, 4, 5, 6, 7]

packages/storybook/src/scrollycoding.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import RepeatedSteps from "./assets/scrollycoding.repeat.mdx"
1515
import { MDXProvider } from "@mdx-js/react"
1616

1717
export default {
18-
title: "ScrollyCoding",
18+
title: "Test/ScrollyCoding",
1919
}
2020

2121
export function basic() {

packages/storybook/src/sim-user.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Page } from "./utils"
33
import { sim } from "@code-hike/sim-user"
44

55
export default {
6-
title: "Sim User",
6+
title: "Test/Sim User",
77
}
88
export const click = () => {
99
const [count, setCount] = React.useState(0)

packages/storybook/src/smooth-lines.story.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { SmoothLines } from "@code-hike/smooth-lines"
33
import { WithProgress } from "./utils"
44

55
export default {
6-
title: "Smooth Lines",
6+
title: "Test/Smooth Lines",
77
argTypes: {
88
center: { control: "boolean" },
99
containerWidth: {

0 commit comments

Comments
 (0)