Skip to content

Commit

Permalink
feat: loading store methods to work with routes
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 14, 2020
1 parent ea97ca0 commit 8eab9b1
Show file tree
Hide file tree
Showing 35 changed files with 707 additions and 363 deletions.
9 changes: 9 additions & 0 deletions .vscode/launch.json
Expand Up @@ -91,6 +91,15 @@
"runtimeArgs": ["--nolazy"],
"sourceMaps": false
},
{
"name": "nextjs attach",
"type": "node",
"request": "attach",
"port": 9229,
"skipFiles": [
"<node_internals>/**"
]
},
{
"type": "node",
"request": "launch",
Expand Down
23 changes: 15 additions & 8 deletions core/core/src/stories-utils.ts
Expand Up @@ -20,13 +20,17 @@ export const getDocPath = (
const { basePath = '' } = pagesConfig?.[docType] || {};
const route = doc
? doc.route ||
`${ensureStartingSlash(ensureTrailingSlash(basePath))}${
`${ensureStartingSlash(
ensureTrailingSlash(basePath),
)}${ensureTrailingSlash(strToId(doc.title))}${
activeTab ? `${ensureTrailingSlash(activeTab)}` : ''
}${ensureTrailingSlash(strToId(doc.title))}`
: `${ensureStartingSlash(ensureTrailingSlash(basePath))}${
}`
: `${ensureStartingSlash(
ensureTrailingSlash(basePath),
)}${ensureTrailingSlash(strToId(name))}${
activeTab ? `${ensureTrailingSlash(activeTab)}` : ''
}${ensureTrailingSlash(strToId(name))}`;
return route;
}`;
return ensureTrailingSlash(route);
};

export const getStoryPath = (
Expand All @@ -41,12 +45,15 @@ export const getStoryPath = (
}

const { basePath = '' } = pagesConfig?.[docType] || {};
const route = `${
const docRoute = `${
doc?.route
? ensureStartingSlash(ensureTrailingSlash(doc?.route))
: `${ensureStartingSlash(ensureTrailingSlash(basePath))}`
}${activeTab ? `${ensureTrailingSlash(activeTab)}` : ''}`;
return `${route}${storyId || ''}`;
}`;
const route = `${docRoute}${storyId ? ensureTrailingSlash(storyId) : ''}${
activeTab ? `${ensureTrailingSlash(activeTab)}` : ''
}`;
return ensureTrailingSlash(route);
};

export const docStoryToId = (docId: string, storyId: string) =>
Expand Down
12 changes: 6 additions & 6 deletions core/instrument/test/__snapshots__/esm-hoisted.test.ts.snap
Expand Up @@ -23,7 +23,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -59,7 +59,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {
Expand Down Expand Up @@ -112,7 +112,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -148,7 +148,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {
Expand Down Expand Up @@ -215,7 +215,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -251,7 +251,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {
Expand Down
Expand Up @@ -17,7 +17,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -53,7 +53,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {
Expand Down Expand Up @@ -102,7 +102,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -138,7 +138,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {
Expand Down Expand Up @@ -187,7 +187,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -223,7 +223,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {},
Expand Down
12 changes: 6 additions & 6 deletions core/instrument/test/__snapshots__/esm-parameters.test.ts.snap
Expand Up @@ -23,7 +23,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -59,7 +59,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {
Expand Down Expand Up @@ -114,7 +114,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -150,7 +150,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {
Expand Down Expand Up @@ -219,7 +219,7 @@ Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -255,7 +255,7 @@ Object {
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {
Expand Down
14 changes: 7 additions & 7 deletions core/instrument/test/__snapshots__/esm-props-info.test.ts.snap
Expand Up @@ -2445,10 +2445,10 @@ user setting can display only props table or only controls",
"packages": Object {
"53689598fe7786493f4584ab098c73cc": Object {
"dependencies": Object {
"@component-controls/components": "^1.7.0",
"@component-controls/core": "^1.7.0",
"@component-controls/editors": "^1.7.0",
"@component-controls/store": "^1.7.1",
"@component-controls/components": "^1.8.0",
"@component-controls/core": "^1.8.0",
"@component-controls/editors": "^1.8.0",
"@component-controls/store": "^1.8.0",
"@primer/octicons-react": "^10.0.0",
"@theme-ui/css": "next",
"copy-to-clipboard": "^3.2.1",
Expand Down Expand Up @@ -2492,14 +2492,14 @@ user setting can display only props table or only controls",
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
"a62e1dde0ad3643683513e77602cc630": Object {
"dependencies": Object {
"@babel/generator": "^7.9.4",
"@babel/parser": "^7.9.4",
"@babel/traverse": "^7.9.0",
"@component-controls/core": "^1.7.0",
"@component-controls/core": "^1.8.0",
"@hutson/parse-repository-url": "^5.0.0",
"@mdx-js/loader": "^1.5.5",
"@mdx-js/react": "^1.6.5",
Expand Down Expand Up @@ -2535,7 +2535,7 @@ user setting can display only props table or only controls",
"docs": "https://github.com/ccontrols/component-controls/tree/master#readme",
"issues": "https://github.com/ccontrols/component-controls/issues",
},
"version": "1.7.1",
"version": "1.8.0",
},
},
"stories": Object {},
Expand Down

0 comments on commit 8eab9b1

Please sign in to comment.