-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from bensmithett/replace-storybook-with-ladle
Vite 3, React 18, MDX 2 and Ladle!
- Loading branch information
Showing
20 changed files
with
126 additions
and
11,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useMemo } from 'react' | ||
import { createRenderer as createFelaRenderer } from 'fela' | ||
import { RendererProvider as FelaRendererProvider } from 'react-fela' | ||
import cssReset from '../src/cssReset' | ||
|
||
export const Provider = ({ children, globalState }) => { | ||
// Reload Fela renderer when switching to/from iframe in Ladle | ||
// https://github.com/tajo/ladle/issues/207 | ||
const doc = getDocument(globalState.story) | ||
const renderer = useMemo(() => getFelaRenderer(), [doc]) | ||
|
||
return ( | ||
<FelaRendererProvider renderer={renderer} targetDocument={doc}> | ||
{children} | ||
</FelaRendererProvider> | ||
) | ||
} | ||
|
||
function getDocument(story) { | ||
const iframe = document.querySelector(`[title='Story ${story}']`) | ||
return iframe && iframe.contentDocument ? iframe.contentDocument : document | ||
} | ||
|
||
function getFelaRenderer() { | ||
const renderer = createFelaRenderer({ devMode: true }) | ||
cssReset(renderer) | ||
return renderer | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs 16.16.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
src/components/TropicalCodeBlock/TropicalCodeBlock.stories.mdx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 5 additions & 6 deletions
11
...s/TropicalCodeBlock/TropicalCodeBlock.jsx → ...mponents/tropical/CodeBlock/CodeBlock.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { CodeBlock } from './CodeBlock' | ||
|
||
export default { title: 'CodeBlock' } | ||
|
||
export const JS = () => ( | ||
<CodeBlock language='javascript'>{`function relax() { | ||
console.log('Welcome to Tropical') | ||
}`}</CodeBlock> | ||
) | ||
|
||
export const JSX = () => ( | ||
<CodeBlock language='jsx'>{`function Relax ({ drink = 'Singapore Sling' }) { | ||
return ( | ||
<div> | ||
<Cocktail drink={drink} /> | ||
</div> | ||
) | ||
}`}</CodeBlock> | ||
) | ||
|
||
export const Ruby = () => ( | ||
<CodeBlock language='ruby'>{`def relax (drink = 'Singapore Sling') | ||
puts "Welcome to Tropical! Enjoy a #{drink}." | ||
end`}</CodeBlock> | ||
) | ||
|
||
export const NoLanguage = () => ( | ||
<CodeBlock>{`This is | ||
not | ||
any particular | ||
language`}</CodeBlock> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './CodeBlock' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { defineConfig } from 'vite' | ||
import { dirname, resolve } from 'path' | ||
import { fileURLToPath } from 'url' | ||
import { plugins, build } from './vite.config.js' | ||
|
||
const dir = dirname(fileURLToPath(import.meta.url)) | ||
|
||
export default defineConfig({ | ||
plugins, | ||
build: { | ||
...build, | ||
rollupOptions: { | ||
input: { | ||
client: resolve(dir, 'index.html'), | ||
// We'll never actually use this JS bundle, but need it to build assets that are only referenced by SSR pages | ||
ssrAssetCollector: resolve(dir, 'src/entry-server.jsx') | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
import { defineConfig } from 'vite' | ||
import { dirname, resolve } from 'path' | ||
import { fileURLToPath } from 'url' | ||
import react from '@vitejs/plugin-react' | ||
import mdx from '@mdx-js/rollup' | ||
import rehypeSlug from 'rehype-slug' | ||
|
||
const dir = dirname(fileURLToPath(import.meta.url)) | ||
export const plugins = [ | ||
react(), | ||
mdx({ rehypePlugins: [rehypeSlug], providerImportSource: '@mdx-js/react' }) | ||
] | ||
|
||
export default defineConfig({ | ||
plugins: [react(), mdx({ rehypePlugins: [rehypeSlug], providerImportSource: '@mdx-js/react' })], | ||
build: { | ||
assetsInlineLimit: 0, | ||
rollupOptions: { | ||
input: { | ||
client: resolve(dir, 'index.html'), | ||
// We'll never actually use this bundle, but need it to build assets that are only referenced by SSR pages | ||
ssrAssetCollector: resolve(dir, 'src/entry-server.jsx') | ||
} | ||
} | ||
} | ||
}) | ||
export const build = { | ||
assetsInlineLimit: 0 | ||
} | ||
|
||
export default defineConfig({ plugins, build }) |
Oops, something went wrong.