Skip to content

Commit

Permalink
Merge pull request #6551 from storybooks/fix/addon-tab-type
Browse files Browse the repository at this point in the history
FIX viewmode being hard-coded making custom addons of type TAB impossible
  • Loading branch information
shilman authored Apr 18, 2019
2 parents 4d15755 + 37a519c commit 907c42a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/router/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface StoryData {
storyId?: string;
}

const knownViewModesRegex = /(story|info)/;
export const knownNonViewModesRegex = /(settings)/;
const splitPath = /\/([^/]+)\/([^/]+)?/;

// Remove punctuation https://gist.github.com/davidjrice/9d2af51100e41c6c4b4a
Expand Down Expand Up @@ -39,7 +39,7 @@ export const storyDataFromString: (path?: string) => StoryData = memoize(1000)(

if (path) {
const [, viewMode, storyId] = path.match(splitPath) || [undefined, undefined, undefined];
if (viewMode && viewMode.match(knownViewModesRegex)) {
if (viewMode && !viewMode.match(knownNonViewModesRegex)) {
Object.assign(result, {
viewMode,
storyId,
Expand Down
24 changes: 14 additions & 10 deletions lib/ui/src/components/layout/__snapshots__/layout.stories.storyshot
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,7 @@ exports[`Storyshots UI|Layout/Mobile page 1`] = `
overflow: hidden;
}

.emotion-11 {
.emotion-12 {
position: fixed;
left: 0;
top: 0;
Expand Down Expand Up @@ -2948,7 +2948,7 @@ exports[`Storyshots UI|Layout/Mobile page 1`] = `
border-left: 1px solid rgba(0,0,0,.1);
}

.emotion-10 {
.emotion-11 {
position: fixed;
bottom: 0;
left: 0;
Expand All @@ -2962,14 +2962,14 @@ exports[`Storyshots UI|Layout/Mobile page 1`] = `
background: #FFFFFF;
}

.emotion-10 > * {
.emotion-11 > * {
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
}

<div
class="emotion-11"
class="emotion-12"
>
<div
class="emotion-7"
Expand All @@ -2995,9 +2995,7 @@ exports[`Storyshots UI|Layout/Mobile page 1`] = `
class="emotion-4"
>
<div>
<div
hidden=""
>
<div>
<div
class="emotion-2"
color="deepskyblue"
Expand All @@ -3010,6 +3008,7 @@ exports[`Storyshots UI|Layout/Mobile page 1`] = `
<pre>
{
"id": "main",
"viewMode": "settings",
"debug": {
"initialActive": 1
}
Expand Down Expand Up @@ -3046,14 +3045,14 @@ exports[`Storyshots UI|Layout/Mobile page 1`] = `
</h2>
<pre>
{
"hidden": true
"hidden": false
}
</pre>
</div>
</div>
</div>
<nav
class="emotion-10"
class="emotion-11"
>
<button
class="emotion-8"
Expand All @@ -3063,7 +3062,12 @@ exports[`Storyshots UI|Layout/Mobile page 1`] = `
<button
class="emotion-8"
>
settings
Canvassettings
</button>
<button
class="emotion-8"
>
Addons
</button>
</nav>
</div>
Expand Down
5 changes: 1 addition & 4 deletions lib/ui/src/components/layout/desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ const Desktop = React.memo(
<Nav debug={navProps} />
</S.Nav>
<S.Main {...mainProps}>
<S.Preview
{...previewProps}
hidden={!(viewMode === 'story' || viewMode === 'info')}
>
<S.Preview {...previewProps} hidden={viewMode === 'settings'}>
<Preview id="main" debug={previewProps} />
</S.Preview>

Expand Down
4 changes: 2 additions & 2 deletions lib/ui/src/components/layout/layout.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ storiesOf('UI|Layout/Desktop', module)
render: () => <MockPage />,
},
]}
viewMode={undefined}
viewMode="settings"
/>
));

Expand Down Expand Up @@ -208,6 +208,6 @@ storiesOf('UI|Layout/Mobile', module)
render: () => <MockPage />,
},
]}
viewMode={undefined}
viewMode="settings"
/>
));

0 comments on commit 907c42a

Please sign in to comment.