-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated project structure based on official addon-kit from storybook due to issues with vite builder #35
- Loading branch information
Showing
56 changed files
with
9,422 additions
and
31,641 deletions.
There are no files selected for viewing
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
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,5 +1,6 @@ | ||
node_modules | ||
dist | ||
yarn-error.log | ||
.cache | ||
example-old | ||
dist/ | ||
node_modules/ | ||
storybook-static/ | ||
build-storybook.log | ||
.DS_Store | ||
.env |
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 @@ | ||
dist |
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 @@ | ||
{} |
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,15 @@ | ||
/** | ||
* to load the built addon in this test Storybook | ||
*/ | ||
function previewAnnotations(entry = []) { | ||
return [...entry, require.resolve("../dist/preview.mjs")]; | ||
} | ||
|
||
function managerEntries(entry = []) { | ||
return [...entry, require.resolve("../dist/manager.mjs")]; | ||
} | ||
|
||
module.exports = { | ||
managerEntries, | ||
previewAnnotations, | ||
}; |
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,15 @@ | ||
import type { StorybookConfig } from "@storybook/react-vite"; | ||
|
||
const config: StorybookConfig = { | ||
stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"], | ||
addons: ["./local-preset.js"], | ||
framework: { | ||
name: "@storybook/react-vite", | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
}; | ||
|
||
export default config; |
6 changes: 5 additions & 1 deletion
6
example/.storybook/preview-head.html → .storybook/preview-head.html
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,2 +1,6 @@ | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Hepta+Slab:[email protected]&display=swap" /> | ||
<script> | ||
window.global = window; | ||
</script> | ||
|
||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Crimson+Pro:[email protected]&display=swap" /> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:[email protected]&display=swap" /> |
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,139 @@ | ||
import React from "react"; | ||
import type { Preview } from "@storybook/react"; | ||
|
||
import { ThemeProvider, createGlobalStyle } from "styled-components"; | ||
|
||
const GlobalStyles = createGlobalStyle` | ||
body { | ||
background: ${(props) => props.theme.color.background}; | ||
color: ${(props) => props.theme.color.foreground}; | ||
margin: 0; | ||
font-family: ${(props) => props.theme.copy.fontFamily}; | ||
} | ||
`; | ||
|
||
const themes = [ | ||
{ | ||
name: "Default Theme", | ||
theme: { | ||
color: { | ||
primary: "#00ffa2", | ||
secondary: "#004466", | ||
background: "#fff", | ||
foreground: "#000", | ||
}, | ||
headline: { | ||
fontFamily: "'Inter', serif", | ||
fontWeight: 700, | ||
fontSize: "52px", | ||
}, | ||
copy: { | ||
fontFamily: "'Crimson Pro', sans-serif", | ||
fontWeight: 200, | ||
fontSize: "20px", | ||
}, | ||
spacings: [40, 80, 120, 160], | ||
rectangle: { | ||
width: "40px", | ||
height: "20px", | ||
margin: { | ||
top: 60, | ||
bottom: 60, | ||
left: 20, | ||
right: 20, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Another Theme", | ||
theme: { | ||
color: { | ||
primary: "indigo", | ||
secondary: "honeydew", | ||
background: "#fff", | ||
foreground: "#000", | ||
}, | ||
headline: { | ||
fontFamily: "'Crimson Pro', serif", | ||
fontWeight: 900, | ||
fontSize: "32px", | ||
}, | ||
copy: { | ||
fontFamily: "'Inter', sans-serif", | ||
fontWeight: 400, | ||
fontSize: "14px", | ||
}, | ||
spacings: [20, 40, 60, 90], | ||
rectangle: { | ||
width: "100px", | ||
height: "100px", | ||
margin: { | ||
top: 20, | ||
bottom: 20, | ||
left: 20, | ||
right: 20, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
backgrounds: { | ||
default: "light", | ||
}, | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
themePlayground: { | ||
theme: themes, | ||
provider: ({ children, theme, name }) => { | ||
console.log("Current theme is: ", name); | ||
return ( | ||
<ThemeProvider theme={theme}> | ||
<GlobalStyles /> | ||
{children} | ||
</ThemeProvider> | ||
); | ||
}, | ||
controls: { | ||
"headline.fontWeight": { | ||
type: "range", | ||
max: 900, | ||
min: 1, | ||
description: "Define the font weight of the variable font", | ||
}, | ||
"copy.fontWeight": { | ||
type: "range", | ||
max: 900, | ||
min: 1, | ||
description: "Define the font weight of the variable font", | ||
}, | ||
"headline.fontFamily": { | ||
type: "select", | ||
options: [ | ||
{ value: "'Crimson Pro', serif", label: "Crimson Pro" }, | ||
{ value: "'Inter', sans-serif", label: "Inter" }, | ||
], | ||
description: "Select the headline font family", | ||
}, | ||
"copy.fontFamily": { | ||
type: "select", | ||
options: [ | ||
{ value: "'Crimson Pro', serif", label: "Crimson Pro" }, | ||
{ value: "'Inter', sans-serif", label: "Inter" }, | ||
], | ||
description: "Select the copy font family", | ||
}, | ||
}, | ||
}, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
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
Oops, something went wrong.