-
Notifications
You must be signed in to change notification settings - Fork 0
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 #18 from sendOwlOrganization/feature/LAB-39/linaria
🔧 리나리아, 스토리북 설정
- Loading branch information
Showing
17 changed files
with
5,040 additions
and
6,583 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import type { StorybookConfig } from "@storybook/nextjs"; | ||
import MiniCssExtractPlugin, { Configuration } from "mini-css-extract-plugin"; | ||
|
||
const withLinaria = (config: Configuration) => { | ||
// Replace TSX loader | ||
// @ts-ignore | ||
const tsxRule = config.module.rules.findIndex((rule) => rule.test.toString().includes("tsx")); | ||
// @ts-ignore | ||
config.module.rules[tsxRule] = { | ||
// @ts-ignore | ||
test: config.module.rules[tsxRule].test, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: "babel-loader", | ||
options: { | ||
presets: ["@babel/preset-env", "@babel/preset-typescript", ["@babel/preset-react", { runtime: "automatic" }]] | ||
} | ||
}, | ||
{ | ||
loader: "@linaria/webpack-loader", | ||
options: { | ||
sourceMap: true, | ||
babelOptions: { | ||
presets: [ | ||
"@babel/preset-env", | ||
"@babel/preset-typescript", | ||
["@babel/preset-react", { runtime: "automatic" }], | ||
"@linaria/babel-preset" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
}; | ||
|
||
// @ts-ignore | ||
config.plugins.push( | ||
new MiniCssExtractPlugin({ | ||
filename: "styles.css" | ||
}) | ||
); | ||
// Replace CSS loader | ||
// @ts-ignore | ||
const cssKey = config.module.rules.findIndex((rule) => rule.test.toString() === "/\\.css$/"); | ||
// @ts-ignore | ||
config.module.rules[cssKey] = { | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: MiniCssExtractPlugin.loader | ||
}, | ||
{ | ||
loader: "css-loader", | ||
options: { sourceMap: true } | ||
} | ||
] | ||
}; | ||
|
||
return config; | ||
}; | ||
|
||
const config: StorybookConfig = { | ||
stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"], | ||
staticDirs: ["../public"], | ||
addons: [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-interactions", | ||
"storybook-dark-mode", | ||
"@storybook/addon-a11y" | ||
], | ||
framework: { | ||
name: "@storybook/nextjs", | ||
options: {} | ||
}, | ||
webpackFinal: async (config) => { | ||
return withLinaria(config); | ||
}, | ||
docs: { | ||
autodocs: true | ||
} | ||
}; | ||
|
||
export default config; |
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,32 @@ | ||
import "@/mds/style.linaria.global"; | ||
import { Preview } from "@storybook/react"; | ||
import { useEffect } from "react"; | ||
import { useDarkMode } from "storybook-dark-mode"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/ | ||
} | ||
} | ||
}, | ||
decorators: [ | ||
(Story) => { | ||
const isDark = useDarkMode(); | ||
|
||
useEffect(() => { | ||
const html = document.querySelector("html"); | ||
if (!html) return; | ||
html.classList.toggle("light", !isDark); | ||
html.classList.toggle("dark", isDark); | ||
}, [isDark]); | ||
|
||
return <Story />; | ||
} | ||
] | ||
}; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use client"; | ||
|
||
// FIXME: temporary solution | ||
export const ThemeSwitcher = () => { | ||
const toggleTheme = () => { | ||
const html = document.querySelector("html"); | ||
if (!html) return; | ||
|
||
const isDark = html.classList.contains("light"); | ||
html.classList.toggle("light", !isDark); | ||
html.classList.toggle("dark", isDark); | ||
}; | ||
|
||
return <button onClick={() => toggleTheme()}>theme</button>; | ||
}; |
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
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.