Skip to content

Commit

Permalink
feat: query-paramiters persisting when opening a story on a full-view…
Browse files Browse the repository at this point in the history
…-mode
  • Loading branch information
andresin87 committed Jan 25, 2024
1 parent 3d4a57c commit dd97cf3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .storybook/preview.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
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'

const ExampleContainer = ({ children, ...props }) => {
console.log(props)
return (
<DocsContainer {...props}>
<div id="spark-doc-container">{children}</div>
Expand Down Expand Up @@ -51,12 +53,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",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-live": "3.2.0",
Expand Down

0 comments on commit dd97cf3

Please sign in to comment.