Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for @storybook/server #9250

Merged
merged 892 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
892 commits
Select commit Hold shift + click to select a range
f32b34b
v5.3.5
shilman Jan 16, 2020
f058442
Update version.ts to 5.3.5
shilman Jan 16, 2020
b1afe49
5.3.5 latest.json version file
shilman Jan 16, 2020
77364be
Core: Fix default sorting of docs-only stories
shilman Jan 17, 2020
38351a9
Core: Update tests for docs-only stories
shilman Jan 17, 2020
d60b374
Official-storybook: Don't load intro.stories.mdx
shilman Jan 17, 2020
018b6d2
bypass source-loader if no exports
atanasster Jan 17, 2020
3a4f187
Core: Fix default sorting of docs-only stories (#9504)
shilman Jan 17, 2020
3e52df6
Source-loader: Bypass if file has no exports (#9505)
shilman Jan 17, 2020
b14ff77
5.3.6 changelog
shilman Jan 17, 2020
2c312d0
Update peer dependencies to 5.3.6
shilman Jan 17, 2020
b609ebb
v5.3.6
shilman Jan 17, 2020
89a367a
Update version.ts to 5.3.6
shilman Jan 17, 2020
281e783
5.3.6 latest.json version file
shilman Jan 17, 2020
eef741c
refactor: use startsWith
jamesgeorge007 Jan 17, 2020
a6a13f0
deps: update husky to v4
jamesgeorge007 Jan 17, 2020
246734b
Add BBC to list of examples
HarveyPeachey Jan 17, 2020
3bcaaeb
Vue-kitchen-sink add component docgen description
shilman Jan 17, 2020
ce16ce1
remove dedent default and white space wrapping
atanasster Jan 17, 2020
1a9b2db
Add BBC to list of examples (#9510)
ndelangen Jan 18, 2020
e04334f
chore(deps): update husky to v4 (#9509)
ndelangen Jan 18, 2020
7b27cce
Refactor: use startsWith (#9508)
ndelangen Jan 18, 2020
6f05d6e
Revert "Add BBC to list of examples"
ndelangen Jan 18, 2020
68239fa
Fix typos in "Writing presets"
alexzherdev Jan 18, 2020
51d526f
Fix typos in "Writing presets" (#9524)
shilman Jan 18, 2020
94aa521
proptable: convert default prop to string
atanasster Jan 18, 2020
39e9739
added check to make sure summary is defined
atanasster Jan 18, 2020
cbb48bb
revert syntaxhighlighter, added Source.defaultProps.format = false
atanasster Jan 18, 2020
0bad835
remove white space styling
atanasster Jan 18, 2020
321ecb9
docs: add a section about external puppeteer in MIGRATION.md
gaetanmaisse Jan 18, 2020
792064b
docs(storyshot-puppeteer): add a warning to emphasize the fact that a…
gaetanmaisse Jan 18, 2020
93afd7f
Addon-docs: Preserve Source indentation by default (#9513)
shilman Jan 18, 2020
dfffc21
Addon-docs Props: Convert default prop value to string (#9525)
shilman Jan 18, 2020
4a5508d
Update addon storyshot puppeteer doc (#9526)
shilman Jan 18, 2020
20eee2f
Fix broken link to repo in empty knobs panel
fireseasonnow Jan 18, 2020
60961d3
Enabling HMR logging in browser console
dnielbowen Jan 19, 2020
f96900c
fix: move `@types/npmlog` to dependencies as `node-logger` is exporti…
gaetanmaisse Jan 19, 2020
9e7e2c7
Update 1-Button.stories.ts
devtronic Jan 19, 2020
a6c2a85
Core: Fix legacy story URLs
shilman Jan 20, 2020
554b379
initial check0in
atanasster Jan 20, 2020
5c43d0c
Core: Fix legacy story URLs (#9545)
shilman Jan 20, 2020
a38d2a4
clean up further
atanasster Jan 20, 2020
a810ff4
re-generate test snapshots
atanasster Jan 20, 2020
d77bbcf
removed unused code
atanasster Jan 20, 2020
5292bd6
Node-logger: Move `@types/npmlog` to dependencies (#9538)
shilman Jan 20, 2020
8a5e3b8
Revert "Add BBC to list of examples" (#9522)
shilman Jan 20, 2020
17c52fb
Merge branch 'next'
shilman Jan 20, 2020
ce06d6e
5.3.7 changelog
shilman Jan 20, 2020
427a36e
Update peer dependencies to 5.3.7
shilman Jan 20, 2020
d6d7450
v5.3.7
shilman Jan 20, 2020
e63446b
Update version.ts to 5.3.7
shilman Jan 20, 2020
7e4fb09
5.3.7 latest.json version file
shilman Jan 20, 2020
36ee762
fix: clean usage of `@types/webpack-env` dep in all packages
gaetanmaisse Jan 19, 2020
3046a88
Merge branch 'next-6.0.0' into ts-migration/polymer
ndelangen Jan 20, 2020
9ac9da6
Merge branch 'next' into next-6.0.0
ndelangen Jan 20, 2020
9cb8bc2
ADD page about tri-config intro
ndelangen Jan 20, 2020
65c7d2d
FIX missing dep
ndelangen Jan 20, 2020
95ae416
ADD api
ndelangen Jan 20, 2020
0707b42
ADD migration guide ref to docs-pages that are not a starter-guide
ndelangen Jan 20, 2020
5779f18
Clean usage of `@types/webpack-env` dep in all packages (#9536)
shilman Jan 20, 2020
3026db9
Next 6.0.0 (#9212)
ndelangen Jan 20, 2020
5dfc31f
Bump terser-webpack-plugin from 2.2.1 to 2.3.2
dependabot-preview[bot] Jan 20, 2020
bf9506e
Merge branch 'next' into pr/avasuro/7981
ndelangen Jan 20, 2020
1dfa589
fix(webcomponents): make types play nicely with lit-element
urish Jan 20, 2020
593ac5f
Fixed Angular button example story (#9540)
ndelangen Jan 20, 2020
86f67a9
bolean props default false
atanasster Jan 20, 2020
3ab7e7a
6.0.0-alpha.0 changelog
shilman Jan 20, 2020
bd5fda8
Having this causes our bootstrap procedure to fail sporadically local…
ndelangen Jan 20, 2020
95c4c7d
withStorySource deprecation
atanasster Jan 20, 2020
4806058
Merge branch 'next' into core/add-docs-config-overview
ndelangen Jan 20, 2020
c4df691
FIX lockfile
ndelangen Jan 20, 2020
2937617
fix parameters, when locationsMap is null
atanasster Jan 20, 2020
b8543b5
Merge branch 'next' into pr/kroeder/8102
ndelangen Jan 20, 2020
67ed0ce
REMOVE yarn/releases (#9563)
ndelangen Jan 20, 2020
a3cd026
Add/app marionette js (#7981)
ndelangen Jan 20, 2020
d8c7ebc
Typescript: Migrate `@storybook/polymer` (#8102)
ndelangen Jan 20, 2020
3eeed60
Merge pull request #9229 from storybookjs/core/preview-layouts
ndelangen Jan 20, 2020
c35919c
Typescript: Migrate `@storybook/polymer (#9565)
ndelangen Jan 20, 2020
28d4a03
api: adding useSharedState, useStoryState
atanasster Jan 20, 2020
73e9c38
Removing lineHeight hard code.
philippe-lavoie Jan 20, 2020
d4a3e30
useStorybookState instead of useContext
atanasster Jan 20, 2020
015690c
Bump terser-webpack-plugin from 2.2.1 to 2.3.2 (#9386)
ndelangen Jan 20, 2020
9fe650b
feat(addon-docs): named colors with ColorPalette (#9453)
ndelangen Jan 20, 2020
48f4192
Bump corejs-upgrade-webpack-plugin from 2.2.0 to 3.0.1
dependabot-preview[bot] Jan 20, 2020
27379b7
FIX cra-ts-kitchen-sink/src/stories/1-Button.stories.tsx
ndelangen Jan 20, 2020
3429aee
FIX manager using ESM in dev-kits example
ndelangen Jan 20, 2020
b81fb63
IMPROVE the build-storybooks script
ndelangen Jan 20, 2020
54bf0e3
Merge branch 'next' into prop-table-default-false
shilman Jan 21, 2020
cf20e87
Removing lineHeight hard code. (#9567)
shilman Jan 21, 2020
1cdbf1f
Revert "Revert "Add BBC to list of examples""
shilman Jan 21, 2020
1deaeff
Addon-docs: Fix TS false default value in prop table (#9560)
shilman Jan 21, 2020
2df547e
fix: readme
SoloJiang Jan 21, 2020
7c08c48
chore: remove rax-button
SoloJiang Jan 21, 2020
58a770c
fix: readme
SoloJiang Jan 21, 2020
8f525e8
CLI: Improve Rax template (#9574)
shilman Jan 21, 2020
fd33245
Bumped react-dev-utils dependency to v10.
robcaldecottvelo Jan 21, 2020
460be9b
Revert "Revert "Add BBC to list of examples"" (#9571)
ndelangen Jan 21, 2020
31ddf96
Make build-ScriptDetection sync
ndelangen Jan 21, 2020
fed325e
IMPROVE the build-storybooks script (#9569)
ndelangen Jan 21, 2020
8209f5b
Bump corejs-upgrade-webpack-plugin from 2.2.0 to 3.0.1 (#9427)
ndelangen Jan 21, 2020
8604717
MDX support is official
shilman Jan 21, 2020
49cf0e4
Merge branch 'next' into pr/urish/9557
ndelangen Jan 21, 2020
bda16e6
update mdx syntax placeholder
shilman Jan 21, 2020
2b95ec2
FIX linting
ndelangen Jan 21, 2020
630d43a
Merge branch 'next' into patch-webcomponents-types
ndelangen Jan 21, 2020
5bac51c
CLEANUP linting issues
ndelangen Jan 21, 2020
6cdfb53
api: adding useSharedState, useStoryState (#9566)
ndelangen Jan 21, 2020
1c18f79
Bump @babel/runtime from 7.7.4 to 7.7.7 (#9277)
ndelangen Jan 21, 2020
e396769
Bump babel-plugin-emotion from 10.0.23 to 10.0.27 (#9239)
ndelangen Jan 21, 2020
c286653
Bump babel-plugin-macros from 2.7.1 to 2.8.0 (#9236)
ndelangen Jan 21, 2020
94aeb7a
Bumped react-dev-utils dependency to v10. (#9579)
shilman Jan 21, 2020
90f1879
CHANGE netlify to build examples
ndelangen Jan 21, 2020
2d116d9
REMOVE now
ndelangen Jan 21, 2020
14443bc
Fix CSF in MDX recipe
shilman Jan 21, 2020
faa9115
fix typo
shilman Jan 21, 2020
fa9b6f6
Fix CSF in MDX recipe (#9587)
shilman Jan 21, 2020
ee27bb4
6.0.0-alpha.0 changelog updates
shilman Jan 21, 2020
405ac9e
Update peer dependencies to 6.0.0-alpha.0
shilman Jan 21, 2020
0cccdab
v6.0.0-alpha.0
shilman Jan 21, 2020
0818505
Update version.ts to 6.0.0-alpha.0
shilman Jan 21, 2020
a1bbeaa
6.0.0-alpha.0 next.json version file
shilman Jan 21, 2020
045db27
FIX lockfile & FIX linting
ndelangen Jan 21, 2020
3fd5cee
Merge branch 'next' of github.com:storybooks/storybook into next
ndelangen Jan 21, 2020
edfd157
FIX lockfile & version.ts
ndelangen Jan 21, 2020
ddadab0
Merge branch 'next' of github.com:storybooks/storybook into next
ndelangen Jan 21, 2020
8a1c563
Merge branch 'next' into core/netlify-again
ndelangen Jan 21, 2020
d2d5e94
Merge branch 'next' into core/netlify-again
ndelangen Jan 21, 2020
525fc4c
Merge branch 'next' into pr/urish/9557
ndelangen Jan 21, 2020
a30b5ad
Merge branch 'next' into patch-webcomponents-types
ndelangen Jan 21, 2020
7aef75f
Typescript: Export IStory in `@storybook/angular` (#9097)
shilman Jan 21, 2020
e3bf436
code changes according to shilman comments
atanasster Jan 21, 2020
4daacfe
Fix broken link to repo in empty knobs panel (#9530)
ndelangen Jan 21, 2020
11d057c
Merge branch 'next' into pr/9547
shilman Jan 21, 2020
da303c5
5.3.8 changelog
shilman Jan 21, 2020
34816a6
REMOVE polymer
ndelangen Jan 22, 2020
26c1417
DELETE references to polymer
ndelangen Jan 22, 2020
98c0b84
Remove duplicate text
jpylisela Jan 22, 2020
8a3b8ee
FIX lockfile
ndelangen Jan 22, 2020
fb8e08f
DETACH react-native
ndelangen Jan 22, 2020
5f4d79b
CLEANUP
ndelangen Jan 22, 2020
6522279
FIX lockfile
ndelangen Jan 22, 2020
314a9ce
FIX lockfile
ndelangen Jan 22, 2020
c8b3221
FIX problem with typings after regen lockfile
ndelangen Jan 22, 2020
5edeceb
WIP
ndelangen Jan 22, 2020
dd41d91
FIX
ndelangen Jan 22, 2020
c442945
FIX
ndelangen Jan 22, 2020
756fb2b
FIX lockfile
ndelangen Jan 23, 2020
07b3964
FIX some dependencies & ts problems on next (#9603)
ndelangen Jan 23, 2020
8cc7100
Merge branch 'next' into remove/polymer
ndelangen Jan 23, 2020
fcde2a4
FIX lockfile
ndelangen Jan 23, 2020
771d411
Merge branch 'next' into detach/react-native
ndelangen Jan 23, 2020
c7d0a03
no message
ndelangen Jan 23, 2020
8eb4061
FIX now + netlify
ndelangen Jan 23, 2020
b859904
Remove duplicate text (#9597)
shilman Jan 23, 2020
5712310
FIX lockfile
ndelangen Jan 23, 2020
6f8c7e7
REMOVE polymer (#9596)
shilman Jan 23, 2020
b919533
Merge branch 'next' into detach/react-native
shilman Jan 23, 2020
6a3c832
DETACH react-native (#9599)
shilman Jan 23, 2020
fefb6f0
Enabling HMR logging in browser console (#9535)
ndelangen Jan 23, 2020
5077b7d
6.0.0-alpha.1 changelog
shilman Jan 23, 2020
d64f3e6
Update peer dependencies to 6.0.0-alpha.1
shilman Jan 23, 2020
81cb58e
v6.0.0-alpha.1
shilman Jan 23, 2020
ae50d33
Update version.ts to 6.0.0-alpha.1
shilman Jan 23, 2020
b35c7b4
6.0.0-alpha.1 next.json version file
shilman Jan 23, 2020
b49797a
Publish: Remove docs to reduce package size
shilman Jan 23, 2020
ddcd491
FIX lockfile
ndelangen Jan 23, 2020
0862356
Merge branch 'next' into shilman/remove-docs-from-publish
shilman Jan 23, 2020
96037ad
FIX lockfile
ndelangen Jan 23, 2020
963ed75
fix(addon-storyshots): Remove excess slashes from jest transform warning
callumacrae Jan 23, 2020
f1b1a28
fix(addon-storyshots): Remove excess slashes from jest transfor… (#9616)
shilman Jan 23, 2020
3098ee8
Merge branch 'next' into core/add-docs-config-overview
ndelangen Jan 23, 2020
10a30f2
FIX spelling mistakes
ndelangen Jan 23, 2020
a585212
typescript config documentation
South-Paw Jan 23, 2020
8a7f669
indent options to make them stand out better
South-Paw Jan 23, 2020
cd70dc7
fix typo
South-Paw Jan 23, 2020
cae2d95
Improve Typescript Configuration documentation page (#9617)
ndelangen Jan 23, 2020
0077101
withKnobs const set twice
richardhuf84 Jan 24, 2020
b2a1d52
Merge pull request #9612 from storybookjs/shilman/remove-docs-from-pu…
ndelangen Jan 24, 2020
ecc1b55
Merge pull request #9389 from storybookjs/imgbot
ndelangen Jan 24, 2020
dc9a255
Merge pull request #9620 from richardhuf84/next
shilman Jan 24, 2020
e1c8ca0
5.3.9 changelog
shilman Jan 24, 2020
f336327
Enables the consumer to hide the code
Jan 24, 2020
1988d8b
Adds minimal documentation to the README
Jan 24, 2020
a6f80b1
Adds basic test
Jan 24, 2020
0c0f7e2
fix: allow tabs to scroll horizontally
Jan 10, 2020
332ff1a
IMPROVE the section about presets-api addons
ndelangen Jan 25, 2020
28618ce
Merge branch 'next' into core/add-docs-config-overview
ndelangen Jan 25, 2020
cc39879
MIGRATE ember to new "import { hbs } from 'ember-cli-htmlbars'"
ndelangen Jan 25, 2020
a582b3b
MOVE ember dist to "ember-output"
ndelangen Jan 25, 2020
0c3558d
FIX pebkac problem
ndelangen Jan 25, 2020
56647e8
MIGRATE ember to new "import { hbs } from 'ember-cli-htmlbars'" (#9633)
ndelangen Jan 25, 2020
baac066
Clarify and expand on addon-docs manual config
shilman Jan 26, 2020
3cc3c4f
Clarify and expand on addon-docs manual config (#9638)
shilman Jan 26, 2020
2c150ae
Update docs/src/pages/presets/writing-presets/index.md
ndelangen Jan 27, 2020
3f4bf9e
Core: Document main.js config (#9552)
ndelangen Jan 27, 2020
9ebb149
feat(addon-docs): ColorPalette style
Jan 27, 2020
3d671e6
feat(addon-docs): ColorPalette style
Jan 27, 2020
e5229cd
feat(addon-docs): ColorPalette style
Jan 27, 2020
d401a25
fix(addon-docs): ColorPalette style (#9643)
ndelangen Jan 27, 2020
246a33e
Add Paddings addon to addon gallery
rbardini Jan 27, 2020
d636d56
UPGRADE the mini-css-extract-plugin
ndelangen Jan 27, 2020
b0e10fb
Merge branch 'next' into core/netlify-again
ndelangen Jan 27, 2020
45fa76c
Netlify for examples again (#9585)
ndelangen Jan 27, 2020
45755b3
Add Paddings addon to addon gallery (#9647)
ndelangen Jan 28, 2020
43251b8
Update bar.tsx
ndelangen Jan 28, 2020
0114672
Merge branch 'next' into knob-groups-overflow-not-scrolling
ndelangen Jan 28, 2020
fc6d8d1
Merge branch 'next' into next
ndelangen Jan 28, 2020
2882cbd
Merge branch 'next' into patch-webcomponents-types
ndelangen Jan 28, 2020
d30bad3
Merge pull request #9652 from storybookjs/fix/9462-sass-loading
shilman Jan 28, 2020
615ce7f
Merge branch 'next' into pr/9090
shilman Jan 28, 2020
d8e13a0
Sidebar: Clean up viewMode handling and add tests
shilman Jan 28, 2020
5eaf233
Merge branch 'next' into pr/9090
shilman Jan 28, 2020
3e086ef
Document viewMode story parameter
shilman Jan 28, 2020
21a4592
UI: Add `viewMode` parameter to control story nav UI (#9090)
shilman Jan 28, 2020
8a49725
Merge branch 'next' into pr/9547
shilman Jan 28, 2020
d0096dc
Create source-loader.stories.storyshot
shilman Jan 28, 2020
86c4099
Fix default value for web components prop table docs
telpalbrox Jan 28, 2020
2bee5dd
Source-loader: Overhaul to remove decorators, support user-conf… (#9547)
shilman Jan 28, 2020
d9ab84b
Merge branch 'next' into pr/9095
shilman Jan 28, 2020
8cf7dc5
ADD notices describing the incompatibilities with manager.js theming …
ndelangen Jan 28, 2020
f955b12
documentation fix #9498 - theming + addon-docs incompatible (#9661)
ndelangen Jan 28, 2020
e7a772d
ADD support for className prop on Form.Field
ndelangen Jan 28, 2020
29ab066
Merge pull request #9665 from storybookjs/fix/styled-form-fields
shilman Jan 29, 2020
17095f8
Merge pull request #9383 from baker-travis/knob-groups-overflow-not-s…
shilman Jan 29, 2020
544091d
fix(webcomponents): make types play nicely with lit-element (#9557)
ndelangen Jan 29, 2020
9c62740
@storybook/addon-cssresources - Hide Code (#9627)
ndelangen Jan 29, 2020
924e403
REMOVE addon-info & addon-notes
ndelangen Jan 29, 2020
8d7cc39
CLEANUP lockfile
ndelangen Jan 29, 2020
9530f23
REMOVE unneeded snapshots
ndelangen Jan 29, 2020
9b4e69d
Merge branch 'next' into remove/addon-notes-info
ndelangen Jan 29, 2020
43bdfa8
CLEANUP
ndelangen Jan 29, 2020
4642284
Merge branch 'remove/addon-notes-info' of github.com:storybooks/story…
ndelangen Jan 29, 2020
f5398ca
FIX linting
ndelangen Jan 29, 2020
71ee7af
Fix default value for web components prop table docs (#9655)
ndelangen Jan 30, 2020
f0d411e
configure tabs: title, visibility, order and disable (#9095)
ndelangen Jan 30, 2020
614f34f
6.0.0-alpha.2 changelog
shilman Jan 30, 2020
675a6b8
Update peer dependencies to 6.0.0-alpha.2
shilman Jan 30, 2020
779ef47
v6.0.0-alpha.2
shilman Jan 30, 2020
303747c
Update version.ts to 6.0.0-alpha.2
shilman Jan 30, 2020
cc6de18
6.0.0-alpha.2 next.json version file
shilman Jan 30, 2020
2aa4507
CHANGE devtools example for previewWrapper
ndelangen Jan 30, 2020
60655c1
Merge branch 'next' into remove/addon-notes-info
ndelangen Jan 30, 2020
2a30c72
FIX lockfile
ndelangen Jan 30, 2020
bebc24c
check if docsOnly is set to hide the addon panels
atanasster Jan 30, 2020
b4713a2
MOVE addon-notes & addon-info to own repo (#9673)
shilman Jan 31, 2020
2b0f4a1
check if docsOnly is set to hide the addon panels (#9687)
ndelangen Jan 31, 2020
c589b96
Fix jsconfig support with CRA (#9324)
shilman Jan 31, 2020
a0f51c8
Merge branch 'storybook_server' of https://github.com/jonspalmer/stor…
tmeasday Feb 3, 2020
0a65a5a
Fix typo
tmeasday Feb 3, 2020
c15feb6
Rename `id` to `path` to be a bit more general
tmeasday Feb 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion addons/docs/src/blocks/DocsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export const DocsContainer: FunctionComponent<DocsContainerProps> = ({ context,
const allComponents = { ...defaultComponents, ...userComponents };

useEffect(() => {
const url = new URL(window.parent.location);
let url: URL;
try {
url = new URL(window.parent.location);
} catch (err) {
return;
}

if (url.hash) {
const element = document.getElementById(url.hash.substring(1));
if (element) {
Expand Down
11 changes: 7 additions & 4 deletions addons/docs/src/blocks/mdx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ export const CodeOrSourceMdx: FC<CodeOrSourceMdxProps> = ({ className, children,
};

function generateHrefWithHash(hash: string): string {
const url = new URL(window.parent.location);
const href = `${url.origin}/${url.search}#${hash}`;

return href;
try {
const url = new URL(window.parent.location);
const href = `${url.origin}/${url.search}#${hash}`;
return href;
} catch (err) {
return '';
}
}

// @ts-ignore
Expand Down
25 changes: 25 additions & 0 deletions app/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Storybook for Server
tmeasday marked this conversation as resolved.
Show resolved Hide resolved

---

Storybook for Server is a UI development environment for your plain HTML snippets rendered by your server backend.
With it, you can visualize different states of your UI components and develop them interactively.

![Storybook Screenshot](https://github.com/storybookjs/storybook/blob/master/media/storybook-intro.gif)

Storybook runs outside of your app.
So you can develop UI components in isolation without worrying about app specific dependencies and requirements.

## Getting Started

```sh
cd my-app
npx -p @storybook/cli sb init -t server
```

For more information visit: [storybook.js.org](https://storybook.js.org)

---

Storybook also comes with a lot of [addons](https://storybook.js.org/addons/introduction) and a great API to customize as you wish.
You can also build a [static version](https://storybook.js.org/basics/exporting-storybook) of your storybook and deploy it anywhere you want.
4 changes: 4 additions & 0 deletions app/server/bin/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

process.env.NODE_ENV = process.env.NODE_ENV || 'production';
require('../dist/server/build');
3 changes: 3 additions & 0 deletions app/server/bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/server');
59 changes: 59 additions & 0 deletions app/server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@storybook/server",
"version": "5.3.0-rc.7",
"description": "Storybook for Server: View HTML snippets from a server in isolation with Hot Reloading.",
"keywords": [
"storybook"
],
"homepage": "https://github.com/storybookjs/storybook/tree/master/app/server",
"bugs": {
"url": "https://github.com/storybookjs/storybook/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"directory": "app/html"
},
"license": "MIT",
"files": [
"bin/**/*",
"dist/**/*",
"README.md",
"*.js",
"*.d.ts"
],
"main": "dist/client/index.js",
"types": "dist/client/index.d.ts",
"bin": {
"build-storybook": "./bin/build.js",
"start-storybook": "./bin/index.js",
"storybook-server": "./bin/index.js"
},
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addons": "5.3.0-rc.7",
"@storybook/core": "5.3.0-rc.7",
"@storybook/node-logger": "^5.2.8",
"@types/webpack-env": "^1.13.9",
"core-js": "^3.0.1",
"global": "^4.3.2",
"regenerator-runtime": "^0.13.3",
"safe-identifier": "^0.3.1",
"ts-dedent": "^1.1.0"
},
"devDependencies": {
"fs-extra": "^8.0.1"
},
"peerDependencies": {
"babel-loader": "^7.0.0 || ^8.0.0"
},
"engines": {
"node": ">=8.0.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "6ad2664adf18b50ea3ce015cbae2ff3e9a60cc4a"
}
14 changes: 14 additions & 0 deletions app/server/src/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export {
storiesOf,
setAddon,
addDecorator,
addParameters,
configure,
getStorybook,
forceReRender,
raw,
} from './preview';

if (module && module.hot && module.hot.decline) {
module.hot.decline();
}
3 changes: 3 additions & 0 deletions app/server/src/client/preview/globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { window } from 'global';

window.STORYBOOK_ENV = 'SERVER';
43 changes: 43 additions & 0 deletions app/server/src/client/preview/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { start } from '@storybook/core/client';
import { ClientStoryApi, Loadable } from '@storybook/addons';

import './globals';
import { renderMain as render, setFetchStoryHtml } from './render';
import { StoryFnServerReturnType, IStorybookSection, ConfigureOptionsArgs } from './types';

const framework = 'server';

interface ClientApi extends ClientStoryApi<StoryFnServerReturnType> {
setAddon(addon: any): void;
configure(loader: Loadable, module: NodeModule, options?: ConfigureOptionsArgs): void;
getStorybook(): IStorybookSection[];
clearDecorators(): void;
forceReRender(): void;
raw: () => any; // todo add type
}

const api = start(render);

export const storiesOf: ClientApi['storiesOf'] = (kind, m) => {
return (api.clientApi.storiesOf(kind, m) as ReturnType<ClientApi['storiesOf']>).addParameters({
framework,
});
};

const setRenderFecthAndConfigure: ClientApi['configure'] = (loader, module, options) => {
tmeasday marked this conversation as resolved.
Show resolved Hide resolved
if (options && options.fetchStoryHtml) {
setFetchStoryHtml(options.fetchStoryHtml);
}
api.configure(loader, module, framework);
};

export const configure: ClientApi['configure'] = setRenderFecthAndConfigure;
export const {
addDecorator,
addParameters,
clearDecorators,
setAddon,
forceReRender,
getStorybook,
raw,
} = api.clientApi;
61 changes: 61 additions & 0 deletions app/server/src/client/preview/render.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { document, fetch, Node } from 'global';
import dedent from 'ts-dedent';
import { RenderMainArgs, FetchStoryHtmlType } from './types';

const rootElement = document.getElementById('root');

let fetchStoryHtml: FetchStoryHtmlType = async (url, id, params) => {
tmeasday marked this conversation as resolved.
Show resolved Hide resolved
const fetchUrl = new URL(`${url}/${id}`);
fetchUrl.search = new URLSearchParams(params).toString();

const response = await fetch(fetchUrl);
return response.text();
};

export async function renderMain({
storyFn,
id,
selectedKind,
selectedStory,
showMain,
showError,
forceRender,
parameters,
}: RenderMainArgs) {
const storyParams = storyFn();

const {
server: { url, id: storyId, params },
} = parameters;

const fetchId = storyId || id;
const fetchParams = { ...params, ...storyParams };
const element = await fetchStoryHtml(url, fetchId, fetchParams);

showMain();
if (typeof element === 'string') {
rootElement.innerHTML = element;
} else if (element instanceof Node) {
// Don't re-mount the element if it didn't change and neither did the story
if (rootElement.firstChild === element && forceRender === true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (rootElement.firstChild === element && forceRender === true) {
if (rootElement.firstChild === element && forceRender !== true) {

Is this what you meant?

return;
}

rootElement.innerHTML = '';
rootElement.appendChild(element);
} else {
showError({
title: `Expecting an HTML snippet or DOM node from the story: "${selectedStory}" of "${selectedKind}".`,
description: dedent`
Did you forget to return the HTML snippet from the story?
Use "() => <your snippet or node>" or when defining the story.
`,
});
}
}

export const setFetchStoryHtml: any = (fetchHtml: FetchStoryHtmlType) => {
if (fetchHtml !== undefined) {
fetchStoryHtml = fetchHtml;
}
};
35 changes: 35 additions & 0 deletions app/server/src/client/preview/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { StoryFn } from '@storybook/addons';

export type StoryFnServerReturnType = any;

export type FetchStoryHtmlType = (url: string, id: string, params: any) => Promise<string | Node>;

export interface IStorybookStory {
name: string;
render: () => any;
}

export interface IStorybookSection {
kind: string;
stories: IStorybookStory[];
}

export interface ShowErrorArgs {
title: string;
description: string;
}

export interface ConfigureOptionsArgs {
fetchStoryHtml: FetchStoryHtmlType;
}

export interface RenderMainArgs {
storyFn: () => StoryFn<StoryFnServerReturnType>;
id: string;
selectedKind: string;
selectedStory: string;
showMain: () => void;
showError: (args: ShowErrorArgs) => void;
forceRender: boolean;
parameters: any;
}
15 changes: 15 additions & 0 deletions app/server/src/lib/compiler/__testfixtures__/a11y.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"title": "Addons/a11y",
"addons": ["a11y"],
"parameters": {
"options": { "selectedPanel": "storybook/a11y/panel" }
},
"stories": [
{
"name": "Label",
"parameters": {
"server": { "id": "addons/a11y/label" }
}
}
]
}
28 changes: 28 additions & 0 deletions app/server/src/lib/compiler/__testfixtures__/a11y.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`json-to-csf-compiler a11y.json 1`] = `
"import { withA11y } from '@storybook/addon-a11y';

export default {
title: 'Addons/a11y',
decorators: [
withA11y
],
parameters: {
options: {
selectedPanel: 'storybook/a11y/panel'
}
}
};

export const Label = () => {};
Label.story = {
name: 'Label',
parameters: {
server: {
id: 'addons/a11y/label'
}
}
};
"
`;
16 changes: 16 additions & 0 deletions app/server/src/lib/compiler/__testfixtures__/actions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": "Addons/Actions",
"addons": ["actions"],
"parameters": {
"options": { "selectedPanel": "storybook/actions/panel" }
},
"stories": [
{
"name": "Multiple actions + config",
"parameters": {
"server": { "id": "addons/actions/story3" }
},
"actions": ["click", "contextmenu", { "clearOnStoryChange": false }]
}
]
}
34 changes: 34 additions & 0 deletions app/server/src/lib/compiler/__testfixtures__/actions.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`json-to-csf-compiler actions.json 1`] = `
"import { withActions } from '@storybook/addon-actions';

export default {
title: 'Addons/Actions',
parameters: {
options: {
selectedPanel: 'storybook/actions/panel'
}
}
};

export const Multiple_actions_config = () => {};
Multiple_actions_config.story = {
decorators: [
withActions(
'click',
'contextmenu',
{
clearOnStoryChange: false
}
)
],
name: 'Multiple actions + config',
parameters: {
server: {
id: 'addons/actions/story3'
}
}
};
"
`;
Loading