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

Storybook Composition - loading a prebuilt storybook into yours #9210

Merged
merged 255 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
255 commits
Select commit Hold shift + click to select a range
cbd296a
ADD refs to Sidebar
ndelangen Feb 12, 2020
f37dcb2
Merge branch 'next' into core/inception
ndelangen Feb 13, 2020
3503ccb
IMPROVE types for Addons
ndelangen Feb 13, 2020
9d39929
REORGANISE tools & preview
ndelangen Feb 13, 2020
e8d85dc
FIX matching of source
ndelangen Feb 14, 2020
e9b1574
CHANGE ref to only refId
ndelangen Feb 14, 2020
d57ec9f
ADD ability to emit event to target
ndelangen Feb 14, 2020
0152280
ADD ability to getData to get stories from refs
ndelangen Feb 14, 2020
a04a660
ADD state for refs to be injected
ndelangen Feb 14, 2020
67b4224
CLEANUP
ndelangen Feb 14, 2020
a83e9b1
FIX zooming on refs
ndelangen Feb 14, 2020
ca7a6ab
CLEANUP
ndelangen Feb 14, 2020
115e3d0
FIX search in refs
ndelangen Feb 14, 2020
845c1db
RENAME isInjected to initialState startInjected, state is preserved i…
ndelangen Feb 14, 2020
2e2ec0f
REFACTOR preview so it renders many iframes
ndelangen Feb 14, 2020
c2fb34e
CLEANUP
ndelangen Feb 14, 2020
a6bb86a
CHANGE ManagerConsumer into a FunctionComponent that auto-memoizes & …
ndelangen Feb 14, 2020
9a18574
REMOVE unneeded type annotations after improvement of types in lib/api
ndelangen Feb 14, 2020
2213c43
Merge branch 'ts/better-api-consumer' into core/inception
ndelangen Feb 14, 2020
4d4642a
Merge branch 'next' into core/inception
ndelangen Feb 14, 2020
0e0e130
CLEANUP
ndelangen Feb 15, 2020
4ae3b18
FIX getData throwing on undefined storyId
ndelangen Feb 17, 2020
f7fca36
CLEANUP
ndelangen Feb 17, 2020
beb2999
Merge branch 'next' into core/ingestion
ndelangen Feb 17, 2020
c30051f
CLEANUP types of refs && RENAME ref.data to ref.stories && CHANGE a r…
ndelangen Feb 17, 2020
b4ac0c6
CLEANUP
ndelangen Feb 17, 2020
22c61f4
ADD data.json fetch in node, for fetching data stories in before star…
ndelangen Feb 17, 2020
e9cb575
ADD example data for what data.json should look like
ndelangen Feb 17, 2020
94f4627
FIX rename data to stories
ndelangen Feb 17, 2020
945479a
ADD data.json to cra-ts-kitchen-sink
ndelangen Feb 17, 2020
073b60b
FIX default value of refs
ndelangen Feb 17, 2020
466632f
CLEANUP && FIX issue where component did not re-render when passing d…
ndelangen Feb 17, 2020
7419337
FIX bad depth field
ndelangen Feb 18, 2020
7cdce26
CLEANUP
ndelangen Feb 18, 2020
7d8cb0e
UPDATE data.json for example
ndelangen Feb 18, 2020
cec068d
CHANGE to useState to keep track of which frames have been injected &…
ndelangen Feb 18, 2020
2d2e135
FIX version
ndelangen Feb 18, 2020
1355574
USE api.getData to retrieve storyObject
ndelangen Feb 18, 2020
5782dd9
CHANGE Root to also have refId optional
ndelangen Feb 18, 2020
cf2e8a4
ADD fullAPI to modules api initiaization
ndelangen Feb 18, 2020
fbdba62
CHANGE initProviderApi to be a void operation
ndelangen Feb 18, 2020
1c4e025
CHANGE addons module to use getData from fullAPI
ndelangen Feb 18, 2020
b52497e
CHANGE jumpStory to use getData
ndelangen Feb 18, 2020
fe6c1ea
FIX addon-links
ndelangen Feb 18, 2020
a7c8428
Oops
ndelangen Feb 18, 2020
5c825a3
CHANGE behavior of SidebarSearch, it should search all stories & refs
ndelangen Feb 18, 2020
facfc9e
FIX problem where when filtered, nodes could not be expanded
ndelangen Feb 18, 2020
98d85ed
IMPROVE filter code readability
ndelangen Feb 18, 2020
6cf29bb
CHANGE search to only search in leafs, to prevent empty groups in the…
ndelangen Feb 18, 2020
7552dfc
CLEANUP
ndelangen Feb 18, 2020
52551d3
FIX empty message
ndelangen Feb 18, 2020
20d1c98
ADD story for filtered dataset
ndelangen Feb 18, 2020
5c5e5fa
CLEANUP
ndelangen Feb 18, 2020
9ca2276
Merge branch 'next' into core/ingestion
ndelangen Feb 18, 2020
d5fa89b
FIX tests
ndelangen Feb 18, 2020
df8c6a1
FIX overflow of text & close button SearchField
ndelangen Feb 18, 2020
5b3c72e
IMPROVE search fuzzyness
ndelangen Feb 18, 2020
090167a
CHANGE initial state of treeview expanded to all expanded when filter…
ndelangen Feb 18, 2020
a66a70c
Merge branch 'next' into core/ingestion
ndelangen Feb 18, 2020
50b5a76
CHANGE fetch to local version in TS
ndelangen Feb 19, 2020
152e627
FIX fetch
ndelangen Feb 19, 2020
e16fe16
FIX logo
ndelangen Feb 20, 2020
54e9f5e
ADD title to example usage of refs
ndelangen Feb 20, 2020
2054690
ADD title to InceptionRef interface
ndelangen Feb 20, 2020
38c22f7
REMOVE content-background from <Main>
ndelangen Feb 20, 2020
2e6e34f
IMPROVE types of setConfig
ndelangen Feb 20, 2020
6eff823
CHANGE example of dark-theme tweak
ndelangen Feb 20, 2020
18e5ea3
CHANGE 'empty because of filter' workings
ndelangen Feb 21, 2020
30d9dea
WIP
ndelangen Feb 24, 2020
b995a9a
RENAME loading to isLoading
ndelangen Feb 24, 2020
50ac560
Never mutate in lib/api
ndelangen Feb 24, 2020
8d320f0
REFACTOR treeview & sidebar
ndelangen Feb 24, 2020
5973e9c
Merge branch 'next' into core/ingestion
ndelangen Feb 24, 2020
b227f77
MIGRATE addon-events
ndelangen Feb 24, 2020
7a66e76
CHANGE refs
ndelangen Feb 24, 2020
e597771
REMOVE warning
ndelangen Feb 24, 2020
ca7d473
OVERHAUL sidebar
ndelangen Feb 25, 2020
fa3a0f1
IMPROVE memoization of menu
ndelangen Feb 25, 2020
9c95047
Revert "MIGRATE addon-events"
ndelangen Feb 25, 2020
bb02da3
ADD cors to netlify
ndelangen Feb 25, 2020
331c08a
REMOVE loading of refs in node, load them in the browser always && AD…
ndelangen Feb 26, 2020
c99ab1b
IMPROVE typings of Icons
ndelangen Feb 26, 2020
2e1c885
FIX loading
ndelangen Feb 26, 2020
acf8dac
FIX ts error
ndelangen Feb 26, 2020
22a5ae3
IMPROVE tooltips
ndelangen Feb 27, 2020
a0ed780
FIX bug of initial storyId of ref iframe
ndelangen Feb 27, 2020
d21551e
REFACTOR api modules/stories for improved types
ndelangen Feb 27, 2020
193f97f
IMPROVE readability of tooltip in darkmode
ndelangen Feb 27, 2020
ad8874c
IMPROVE text on tooltips for refs
ndelangen Feb 27, 2020
31361c5
ADD SmoothHeight
ndelangen Feb 27, 2020
27f7594
REMOVE SmoothHeight
ndelangen Feb 27, 2020
a13ec4b
Make generated title look pretty
ndelangen Feb 27, 2020
8fcdc01
Merge branch 'next' into core/ingestion
ndelangen Feb 27, 2020
459a687
Merge branch 'next' into core/ingestion
ndelangen Mar 2, 2020
4c7bd7d
Merge branch 'next' into core/ingestion
ndelangen Mar 2, 2020
51172de
FIX loading appearance
ndelangen Mar 2, 2020
890afeb
CHANGE listitem, cannot be loading && FIX selectedStory being rendere…
ndelangen Mar 2, 2020
111588f
Merge branch 'next' into core/ingestion
ndelangen Mar 2, 2020
d44bf76
Merge branch 'tech/use-getdata' into core/ingestion
ndelangen Mar 3, 2020
938c904
Merge branch 'next' into core/ingestion
ndelangen Mar 3, 2020
27ea029
Merge branch 'tech/use-getdata' into core/ingestion
ndelangen Mar 3, 2020
5b8adc4
FIX e2e by adding an ID back to the ListItem
ndelangen Mar 3, 2020
665cbb8
FIX package.json
ndelangen Mar 3, 2020
f844262
Merge branch 'next' into core/ingestion
ndelangen Mar 4, 2020
303757d
Merge branch 'next' into core/ingestion
ndelangen Mar 4, 2020
bd2ff09
FIX ember docs generation if the component parameter is missing (for …
ndelangen Mar 4, 2020
6b828d6
FIX unrenderable docs upon initialization
ndelangen Mar 4, 2020
3366f61
CHANGE event target to full iframe id
ndelangen Mar 4, 2020
f3600ae
ADD key to li
ndelangen Mar 4, 2020
0911348
FIX typings
ndelangen Mar 4, 2020
c9ad738
CLEANUP
ndelangen Mar 4, 2020
5c214e9
Merge branch 'next' into core/ingestion
ndelangen Mar 4, 2020
05a89f2
CLEANUP
ndelangen Mar 4, 2020
1486314
CLEANUP mockdata, so it's not as huge
ndelangen Mar 5, 2020
e9adbe8
FIX loader being invisible on light background or dark ones
ndelangen Mar 5, 2020
2585213
IMPROVE typings of toolbar
ndelangen Mar 5, 2020
121c50a
FIX copy & eject functionality to work with refs
ndelangen Mar 5, 2020
93149ac
REMOVE unneeded div
ndelangen Mar 5, 2020
903cbb9
CHANGE width of vertical dragger so it doesn't overlay the scrollbar
ndelangen Mar 5, 2020
f4081c0
ADD documentation for theme colors in dark & light
ndelangen Mar 5, 2020
167adb4
CHANGE theme so when in dark mode lightest === darkest etc.
ndelangen Mar 5, 2020
629cdad
IMPROVE theming on colors documentation page
ndelangen Mar 5, 2020
d1fc984
CHANGE Spaced to work across any type of children
ndelangen Mar 5, 2020
e1425c9
IMPROVE theming of sidebar && ADD stories for refs && IMPROVE how sid…
ndelangen Mar 5, 2020
b464211
ADD authUrl to ref
ndelangen Mar 6, 2020
710c6a3
ADD gray Button
ndelangen Mar 6, 2020
aa3591c
CHANGE loader so Container its is re-usable
ndelangen Mar 6, 2020
3bb9c6d
REFACTOR Refs to match design
ndelangen Mar 6, 2020
7d9f6fa
IMPROVE stories for Refs
ndelangen Mar 6, 2020
6c2030d
IMPROVE the text when a user has authenticated
ndelangen Mar 6, 2020
a59efd8
IMPROVE typings of Button
ndelangen Mar 6, 2020
e6cacd2
FIX deepscan issue
ndelangen Mar 6, 2020
ec59cc9
REFACTOR Refs components, splitting them into single purpose components
ndelangen Mar 6, 2020
b1e1665
IMPROVE the error display in refs
ndelangen Mar 6, 2020
48b25be
IMPROVE layout of long ref names & long version names
ndelangen Mar 6, 2020
dee7754
CHANGE stories to share mockdata between them && ADD story for long n…
ndelangen Mar 6, 2020
359f191
EXTRACTY RefHelpers & RefTypes to new module
ndelangen Mar 6, 2020
a5ae5b1
IMPROVE typings of menulist
ndelangen Mar 6, 2020
e0074a9
REMOVE need for shadow prop
ndelangen Mar 6, 2020
bd25b7b
REMOVE unused file
ndelangen Mar 6, 2020
cf803c8
MIGRATE badge from css template literal to css objects
ndelangen Mar 6, 2020
d594fcd
no message
ndelangen Mar 7, 2020
a635a79
Merge branch 'next' into core/ingestion
ndelangen Mar 7, 2020
0962485
Merge branch 'next' into core/ingestion
ndelangen Mar 8, 2020
0620237
CHANGE so all types & interfaces are exported
ndelangen Mar 9, 2020
3128e97
FIX initial storyId being '*' in FramesRenderer
ndelangen Mar 9, 2020
7bc9d58
ADD ability for MenuListItems to receive the listItem in the onClickH…
ndelangen Mar 9, 2020
68e03ca
FIX initial rendering of preview with "no story selected"
ndelangen Mar 9, 2020
f3d789e
ADD changeRefVersion API
ndelangen Mar 9, 2020
d27547e
ADD onClick handler that refetches version to Ref VersionSelector
ndelangen Mar 9, 2020
03cc58f
ADD cors to local dev
ndelangen Mar 9, 2020
d752cbd
REMOVE really weird href = object type
ndelangen Mar 9, 2020
c78e42c
FIX missing key warning
ndelangen Mar 9, 2020
ba6de13
FIX state between switching versions && FIX wrong storyId being passed
ndelangen Mar 9, 2020
c54ee0b
MOVE tooltips
ndelangen Mar 9, 2020
348d09b
CHANGE so all interfaces & types are exported
ndelangen Mar 9, 2020
2b715eb
Merge branch 'tech/improvements-2' into core/ingestion
ndelangen Mar 9, 2020
4f477d7
REMOVE fluff from mockfiles
ndelangen Mar 9, 2020
b258a9a
Merge branch 'next' into core/ingestion
ndelangen Mar 9, 2020
d5c3964
FIX setRef call
ndelangen Mar 9, 2020
43557b1
MOVE handlers into module's init
ndelangen Mar 9, 2020
4f3146f
FIX test
ndelangen Mar 10, 2020
b1972e4
Merge branch 'tech/improvements-3' into core/ingestion
ndelangen Mar 10, 2020
4900508
FIX test
ndelangen Mar 10, 2020
f8fc1f7
Merge branch 'next' into core/ingestion
ndelangen Mar 10, 2020
6b9f3a7
REMOVE dummy data
ndelangen Mar 10, 2020
b800846
Merge branch 'next' into core/ingestion
ndelangen Mar 10, 2020
1447858
Merge branch 'next' into core/ingestion
ndelangen Mar 10, 2020
47f31be
Merge branch 'next' into core/ingestion
ndelangen Mar 10, 2020
4e41392
Merge branch 'next' into core/ingestion
ndelangen Mar 10, 2020
1412b57
ADD args to storyInput
ndelangen Mar 10, 2020
ba5b750
FIX missing args property on mockdata
ndelangen Mar 10, 2020
9ca86fa
REMOVE need for knownAs, since it can be deduced from refId + storyid
ndelangen Mar 11, 2020
f2a8dc7
CHANGE to prefer getCurrentParameters
ndelangen Mar 12, 2020
cb02c3e
REFACTOR to take current refId from router && REMOVE id mapping on re…
ndelangen Mar 12, 2020
dadc161
REFACTOR to simplify mapping & adding refIds
ndelangen Mar 12, 2020
db44f05
FIX test for css-resouces
ndelangen Mar 12, 2020
ac43fe5
CHANGE setStories to be async && navigate to default story after stat…
ndelangen Mar 12, 2020
76e31c2
RENAME InceptionRef to ComposedRef
ndelangen Mar 12, 2020
caf1e01
REFACTOR lib/api entrypoint & modules to not use default export
ndelangen Mar 12, 2020
d95de4d
FIX test
ndelangen Mar 12, 2020
9523263
IMPROVE typings of lib/api
ndelangen Mar 12, 2020
0cfe87a
Merge branch 'next' into core/ingestion
ndelangen Mar 12, 2020
fa4039a
REFACTOR so loading refs from config & loading refs from state are se…
ndelangen Mar 12, 2020
76e11f7
REMOVE unneeded code for ensuring a title exists on a ref
ndelangen Mar 12, 2020
5cc9470
CLEANUP
ndelangen Mar 12, 2020
9249dcd
IMPROVE getEventSourceUrl
ndelangen Mar 12, 2020
a4c7a74
CLEANUP
ndelangen Mar 12, 2020
7d11d60
FIX type error
ndelangen Mar 12, 2020
edf4f2b
FIX linting
ndelangen Mar 13, 2020
236bc3d
FIX tests
ndelangen Mar 13, 2020
cc7b7e5
CHANGE loader to always be round
ndelangen Mar 13, 2020
b7168d5
CLEANUP
ndelangen Mar 13, 2020
584cc30
CLEANUP
ndelangen Mar 13, 2020
2e1db38
Merge branch 'next' into core/ingestion
ndelangen Mar 13, 2020
60e684a
Merge branch 'core/ingestion' of github.com:storybookjs/storybook int…
ndelangen Mar 13, 2020
c1db7d1
CHANGE styling active frame from a funky span to a data attribute
ndelangen Mar 13, 2020
d9fd47a
Merge branch 'tech/parallel-chromatic' into core/ingestion
ndelangen Mar 13, 2020
95a01f3
Merge branch 'next' into core/ingestion
ndelangen Mar 16, 2020
ba20c6c
Merge branch 'next' into core/ingestion
ndelangen Mar 16, 2020
7eda949
ADD an extract command to storybook cli
ndelangen Mar 16, 2020
e364cac
ADD data.json to all examples automatically
ndelangen Mar 16, 2020
1551f0c
IMPROVE cli.extract && ADD missing dependency
ndelangen Mar 17, 2020
652d0bc
REMOVE support for setting options from refs
ndelangen Mar 17, 2020
1e178b6
IMPROVE debugging by adding colors to output of debug logs for channe…
ndelangen Mar 17, 2020
6abdbd7
CHANGE so frames for channel are filtered to only "ready" frames & fl…
ndelangen Mar 18, 2020
47d62ca
CLEANUP
ndelangen Mar 18, 2020
91e624b
CHANGE prefer getCurrentParameter over getParameters
ndelangen Mar 18, 2020
606ff7f
CHANGE name of getCurrentFrame to plural
ndelangen Mar 18, 2020
1139d43
ADD tests for router utils
ndelangen Mar 18, 2020
39a3cc0
ADD extract command to cli
ndelangen Mar 18, 2020
a9305fe
ADD data.json to all examples automatically
ndelangen Mar 16, 2020
9ccde7a
RENAME data.json to stories.json
ndelangen Mar 18, 2020
a8d47bf
FIX tests
ndelangen Mar 18, 2020
20bd8da
Merge branch 'add/extract-command-to-cli' into core/ingestion
ndelangen Mar 18, 2020
27fea9a
ADD support for stories.json & metadata.json
ndelangen Mar 18, 2020
7e40bf8
FIX linting error
ndelangen Mar 18, 2020
869a75f
ADD puppeteer orb
ndelangen Mar 18, 2020
cfd6bb7
CHANGE to use puppeteer fix
ndelangen Mar 18, 2020
85c1315
IMRPOVE puppeteer deps install
ndelangen Mar 18, 2020
adf4d2b
CHANGE to use get-port
ndelangen Mar 18, 2020
8c85bdd
Merge branch 'next' into core/ingestion
ndelangen Mar 18, 2020
7c63638
Merge branch 'next' into add/extract-command-to-cli
ndelangen Mar 18, 2020
f863575
SIMPLIFY bugger logic
ndelangen Mar 18, 2020
9054c90
FIX missing await
ndelangen Mar 18, 2020
0a50d7d
FIX try using localhost, since it seems the server returned address d…
ndelangen Mar 18, 2020
b4857c7
FIX
ndelangen Mar 18, 2020
8c8a493
Merge branch 'add/extract-command-to-cli' into core/ingestion
ndelangen Mar 18, 2020
6d7633f
MOVE pretty logger to client-logger
ndelangen Mar 18, 2020
66b7fe8
Merge branch 'next' into core/ingestion
ndelangen Mar 18, 2020
b906a2a
IMPROVE typing of client-logger
ndelangen Mar 18, 2020
2c2f23e
CLEANUP
ndelangen Mar 18, 2020
0a4d447
CHANGE checkRef api to merge stories data & meta data
ndelangen Mar 18, 2020
d6bbfa5
Merge branch 'fix/generated-load-order' into core/ingestion
ndelangen Mar 19, 2020
fb68cfb
Merge branch 'next' into core/ingestion
ndelangen Mar 19, 2020
7d7c1e6
Merge branch 'next' into core/ingestion
ndelangen Mar 20, 2020
9fc42ec
Merge branch 'next' into add/extract-command-to-cli
ndelangen Mar 20, 2020
b63c2cb
Merge branch 'next' into core/ingestion
ndelangen Mar 23, 2020
c08f305
CHANGE to lazy-install puppeteer
ndelangen Mar 24, 2020
36078d4
FIX use npx instead
ndelangen Mar 24, 2020
caec732
FIX ref to logger
ndelangen Mar 25, 2020
903e99e
Merge branch 'next' into add/extract-command-to-cli
ndelangen Mar 25, 2020
41ac1c2
Merge branch 'add/extract-command-to-cli' into core/ingestion
ndelangen Mar 25, 2020
77ec7e0
CHANGE to use puppeteer-core install script
ndelangen Mar 25, 2020
0235dff
Merge branch 'add/extract-command-to-cli' into core/ingestion
ndelangen Mar 25, 2020
1e88f25
FIX wait for script to finish
ndelangen Mar 25, 2020
e5d00b5
FIX wait for script to finish
ndelangen Mar 25, 2020
cd9c595
FIX linting
ndelangen Mar 25, 2020
4ac5cbf
FIX path to install.js
ndelangen Mar 25, 2020
1d21e6b
Merge branch 'add/extract-command-to-cli' into core/ingestion
ndelangen Mar 25, 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
11 changes: 10 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: 2.1

aliases:
- &defaults
working_directory: /tmp/storybook
Expand Down Expand Up @@ -83,6 +83,15 @@ jobs:
- checkout
- attach_workspace:
at: .
- run:
name: Install Headless Chrome dependencies
command: |
sudo apt-get install -yq \
gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates \
fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
- run:
name: examples
command: |
Expand Down
3 changes: 1 addition & 2 deletions addons/backgrounds/src/containers/BackgroundSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ const getSelectedBackgroundColor = (list: Input[], currentSelectedValue: string)
};

const mapper = ({ api, state }: Combo): { items: Input[]; selected: string | null } => {
const story = api.getData(state.storyId);
const list = story ? api.getParameters(story.id, PARAM_KEY) : [];
const list = api.getCurrentParameter<Input[]>(PARAM_KEY);
const selected = state.addons[PARAM_KEY] || null;

return { items: list || [], selected };
Expand Down
28 changes: 15 additions & 13 deletions addons/cssresources/src/css-resource-panel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const defaultProps = {
emit: jest.fn(),
on: jest.fn(),
off: jest.fn(),
getParameters: jest.fn(() => defaultParameters),
getCurrentParameter: jest.fn(() => defaultParameters),
},
};

Expand Down Expand Up @@ -104,11 +104,13 @@ describe('CSSResourcePanel', () => {

it('should remove STORY_RENDERED listener from the api', () => {
const apiRemove = jest.fn();
const getCurrentParameter = jest.fn(() => newFakeParameters);
const node = shallowNode({
...defaultProps,
api: {
...defaultProps.api,
off: apiRemove,
getCurrentParameter,
},
});
const { onStoryChange } = node.instance();
Expand All @@ -125,18 +127,18 @@ describe('CSSResourcePanel', () => {
expect(node.state('list')).toMatchObject(defaultParameters);
});

it('should pull default items from getParameters', () => {
const apiGetParameters = jest.fn(() => newFakeParameters);
it('should pull default items from getCurrentParameter', () => {
const getCurrentParameter = jest.fn(() => newFakeParameters);
const node = shallowNode({
...defaultProps,
api: {
...defaultProps.api,
getParameters: apiGetParameters,
getCurrentParameter,
},
});
expect(node.state('list')).toMatchObject([]);
node.instance().onStoryChange('fake-story-id');
expect(apiGetParameters).toHaveBeenCalledWith('fake-story-id', PARAM_KEY);
expect(getCurrentParameter).toHaveBeenCalledWith(PARAM_KEY);
expect(node.state('list')).toMatchObject(newFakeParameters);
});

Expand All @@ -159,12 +161,12 @@ describe('CSSResourcePanel', () => {

it("should not overwrite list when story id hasn't changed", () => {
const fakeList = [];
const apiGetParameters = jest.fn(() => newFakeParameters);
const getCurrentParameter = jest.fn(() => newFakeParameters);
const node = shallowNode({
...defaultProps,
api: {
...defaultProps.api,
getParameters: apiGetParameters,
getCurrentParameter,
},
});
node.setState({ list: fakeList, currentStoryId: 'fake-story-id' });
Expand All @@ -175,12 +177,12 @@ describe('CSSResourcePanel', () => {

it('should not overwrite list when default list is undefined', () => {
const fakeList = [];
const apiGetParameters = jest.fn(() => undefined);
const getCurrentParameter = jest.fn(() => undefined);
const node = shallowNode({
...defaultProps,
api: {
...defaultProps.api,
getParameters: apiGetParameters,
getCurrentParameter,
},
});
node.setState({ list: fakeList });
Expand Down Expand Up @@ -279,7 +281,7 @@ describe('CSSResourcePanel', () => {
});

it('should not render code for items without a code', () => {
const apiGetParameters = jest.fn(() => [
const getCurrentParameter = jest.fn(() => [
{
id: 'local-fake-id-1',
picked: true,
Expand All @@ -294,15 +296,15 @@ describe('CSSResourcePanel', () => {
...defaultProps,
api: {
...defaultProps.api,
getParameters: apiGetParameters,
getCurrentParameter,
},
});
node.instance().onStoryChange('fake-story-id');
expect(node.find(SyntaxHighlighter).length).toEqual(1);
});

it('should not render code for items /w the `hideCode` flag', () => {
const apiGetParameters = jest.fn(() => [
const getCurrentParameter = jest.fn(() => [
{
id: 'local-fake-id-1',
code: 'local-fake-code-1',
Expand All @@ -320,7 +322,7 @@ describe('CSSResourcePanel', () => {
...defaultProps,
api: {
...defaultProps.api,
getParameters: apiGetParameters,
getCurrentParameter,
},
});

Expand Down
2 changes: 1 addition & 1 deletion addons/cssresources/src/css-resource-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class CssResourcePanel extends Component<Props, State> {
onStoryChange = (id: string) => {
const { list: currentList, currentStoryId } = this.state;
const { api } = this.props;
const list = api.getParameters(id, PARAM_KEY) as CssResource[];
const list = api.getCurrentParameter<CssResource[]>(PARAM_KEY);

if (list && currentStoryId !== id) {
const existingIds = currentList.reduce((lookup: CssResourceLookup, res) => {
Expand Down
4 changes: 2 additions & 2 deletions addons/docs/src/register.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import addons, { types } from '@storybook/addons';
import { ADDON_ID, PANEL_ID } from './shared';

addons.register(ADDON_ID, api => {
addons.register(ADDON_ID, () => {
addons.add(PANEL_ID, {
type: types.TAB,
title: 'Docs',
route: ({ storyId }) => `/docs/${storyId}`,
route: ({ storyId, refId }) => (refId ? `/docs/${refId}_${storyId}` : `/docs/${storyId}`),
match: ({ viewMode }) => viewMode === 'docs',
render: () => null,
});
Expand Down
9 changes: 8 additions & 1 deletion addons/graphql/src/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ const GQL: FunctionComponent<GQLProps> = ({ active }) => {
<Consumer>
{({ api, state }: Combo) => {
const story = api.getData(state.storyId);
const parameters = story ? api.getParameters(story.id, PARAM_KEY) : null;
const parameters = story
? api.getCurrentParameter<{
query: string;
variables: Record<string, any>;
url: string;
fetcher: ReturnType<typeof getDefaultFetcher>;
}>(PARAM_KEY)
: null;

if (parameters) {
const query = reIndentQuery(parameters.query);
Expand Down
9 changes: 5 additions & 4 deletions addons/storysource/src/StoryPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export const StoryPanel: React.FC<StoryPanelProps> = ({ api }) => {
useInlineStyles,
location,
id,
}: SyntaxHighlighterRendererProps & { location: SourceBlock; id: string }) => {
refId,
}: SyntaxHighlighterRendererProps & { location: SourceBlock; id: string; refId?: string }) => {
const first = location.startLoc.line - 1;
const last = location.endLoc.line;

Expand All @@ -113,7 +114,7 @@ export const StoryPanel: React.FC<StoryPanelProps> = ({ api }) => {
);
}
return (
<StyledStoryLink to={`/story/${id}`} key={storyKey}>
<StyledStoryLink to={refId ? `/story/${refId}_${id}` : `/story/${id}`} key={storyKey}>
{storySource}
</StyledStoryLink>
);
Expand All @@ -127,12 +128,12 @@ export const StoryPanel: React.FC<StoryPanelProps> = ({ api }) => {
const location = locationsMap[key];
const first = location.startLoc.line - 1;
const last = location.endLoc.line;
const { kind } = story;
const { kind, refId } = story;
// source loader ids are different from story id
const sourceIdParts = key.split('--');
const id = api.storyId(kind, sourceIdParts[sourceIdParts.length - 1]);
const start = createPart({ rows: rows.slice(lastRow, first), stylesheet, useInlineStyles });
const storyPart = createStoryPart({ rows, stylesheet, useInlineStyles, location, id });
const storyPart = createStoryPart({ rows, stylesheet, useInlineStyles, location, id, refId });

parts.push(start);
parts.push(storyPart);
Expand Down
10 changes: 9 additions & 1 deletion examples/dev-kits/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
module.exports = {
stories: ['./stories/*.*'],
webpack: async (config, { configType }) => ({
refs: {
ember: {
id: 'ember',
title: 'Ember',
url: 'https://deploy-preview-9210--storybookjs.netlify.com/ember-cli',
},
cra: 'https://deploy-preview-9210--storybookjs.netlify.com/cra-ts-kitchen-sink',
},
webpack: async config => ({
...config,
module: {
...config.module,
Expand Down
1 change: 1 addition & 0 deletions examples/official-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@storybook/addon-viewport": "6.0.0-alpha.28",
"@storybook/addons": "6.0.0-alpha.28",
"@storybook/components": "6.0.0-alpha.28",
"@storybook/cli": "6.0.0-alpha.28",
"@storybook/core-events": "6.0.0-alpha.28",
"@storybook/node-logger": "6.0.0-alpha.28",
"@storybook/react": "6.0.0-alpha.28",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { Fragment } from 'react';

const text = 'Testing the a11y addon';
const href = 'javascript:void 0';
const href = 'http://example.com';

export default {
title: 'Addons/A11y/Typography',
Expand Down
Loading