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

feat: query-parameters persisting when opening a story on a full-view-mode #1845

Merged
merged 7 commits into from
Jan 30, 2024
12 changes: 7 additions & 5 deletions .storybook/preview.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import '../src/tailwind.css'
import './sb-theming.css'
import { ToC } from '@docs/helpers/ToC'

import queryString from 'query-string'
import { DocsContainer } from '@storybook/blocks'
import { withThemeByDataAttribute } from '@storybook/addon-styling'
import { Icon } from '@spark-ui/icon'
import { ShareExpand } from '@spark-ui/icons/dist/icons/ShareExpand'

import '../src/tailwind.css'
import './sb-theming.css'
import { ToC } from '@docs/helpers/ToC'

const ExampleContainer = ({ children, ...props }) => {
return (
<DocsContainer {...props}>
Expand Down Expand Up @@ -51,12 +52,13 @@ export const decorators = [
attributeName: 'data-theme',
}),
(storyFn, { id, viewMode }) => {
const { globals } = queryString.parse(window.top?.location.search)
return (
<div className="relative w-full">
{viewMode === 'docs' && (
<div className="absolute -right-lg -top-xl">
<a
href={`/iframe.html?&id=${id}`}
href={`/iframe.html?${queryString.stringify({ id, globals })}`}
target="_blank"
className="text-basic hover:text-basic-hovered focus:text-basic-focused enabled:active:text-basic-pressed"
>
Expand Down
52 changes: 52 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"postcss": "8.4.31",
"prettier": "3.2.4",
"prettier-plugin-tailwindcss": "0.5.11",
"query-string": "^8.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't we use the URLSearchParams API instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll change it.

"react": "18.2.0",
"react-dom": "18.2.0",
"react-live": "3.2.0",
Expand Down
Loading