Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

WIP: Refactor Refactor Refactor Refactor #202

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .storybook/addons.js

This file was deleted.

24 changes: 0 additions & 24 deletions .storybook/config.js

This file was deleted.

51 changes: 51 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const path = require("path")
const toPath = (_path) => path.join(process.cwd(), _path)

module.exports = {
stories: ['../src/components/**/*.stories.mdx', '../src/components/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
{
name: '@storybook/addon-docs',
options: {
sourceLoaderOptions: {
parser: 'typescript',
injectStoryParameters: false,
},
},
},
],
typescript: {
check: true,
checkOptions: {},
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => ['label', 'disabled'].includes(prop.name),
// propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
},
},
webpackFinal: async (config) => {
config.module.rules.push({
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader"],
include: path.resolve(__dirname, "../")
});

config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve("babel-loader"),
options: {
presets: [["react-app", { flow: false, typescript: true }]]
}
});
config.resolve.extensions.push(".ts", ".tsx");
config.resolve.alias = {
"@emotion/core": toPath("node_modules/@emotion/react"),
"emotion-theming": toPath("node_modules/@emotion/react"),
}

return config;
}
};
8 changes: 0 additions & 8 deletions .storybook/presets.js

This file was deleted.

62 changes: 62 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {
ChakraProvider,
extendTheme,
Flex,
IconButton,
useColorMode,
useColorModeValue,
} from "@chakra-ui/react"
import * as React from "react"
import { FaMoon, FaSun } from "react-icons/fa"
import { withPerformance } from "storybook-addon-performance"

/**
* Add global context for RTL-LTR switching
*/
export const globalTypes = {
direction: {
name: "Direction",
description: "Direction for layout",
defaultValue: "LTR",
toolbar: {
icon: "globe",
items: ["LTR", "RTL"],
},
},
}

const ColorModeToggleBar = () => {
const { toggleColorMode } = useColorMode()
const SwitchIcon = useColorModeValue(FaMoon, FaSun)
const nextMode = useColorModeValue("dark", "light")

return (
<Flex justify="flex-end" mb={4}>
<IconButton
size="md"
fontSize="lg"
aria-label={`Switch to ${nextMode} mode`}
variant="ghost"
color="current"
marginLeft="2"
onClick={toggleColorMode}
icon={<SwitchIcon />}
/>
</Flex>
)
}

const withChakra = (StoryFn, context) => {
const { direction } = context.globals
const dir = direction.toLowerCase()
return (
<ChakraProvider theme={extendTheme({ direction: dir })}>
<div dir={dir} id="story-wrapper" style={{ minHeight: "100vh" }}>
<ColorModeToggleBar />
<StoryFn />
</div>
</ChakraProvider>
)
}

export const decorators = [withChakra, withPerformance]
22 changes: 0 additions & 22 deletions .storybook/webpack.config.js

This file was deleted.

Loading