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

FIX viewmode being hard-coded making custom addons of type TAB impossible #6551

Merged
merged 4 commits into from
Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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"
/>
));