Skip to content

Commit 1be89cb

Browse files
committed
New mini browser docs
1 parent 48b38eb commit 1be89cb

File tree

6 files changed

+109
-86
lines changed

6 files changed

+109
-86
lines changed

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

Lines changed: 16 additions & 1 deletion
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/src/components.tsx

Lines changed: 6 additions & 0 deletions
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
Lines changed: 7 additions & 0 deletions
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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
module.exports = {
2-
stories: [
3-
"mini-editor.docs.story.js",
4-
"*.story.mdx",
5-
"*.story.js",
6-
],
2+
stories: ["intro.story.mdx", "*.story.@(js|mdx|tsx)"],
73
addons: [
84
"@storybook/addon-docs",
95
"@storybook/addon-controls",
106
"@storybook/addon-actions",
117
],
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+
},
1220
}
Lines changed: 67 additions & 0 deletions
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.docs.story.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)