-
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.
- Loading branch information
1 parent
60e7e65
commit 8ca2104
Showing
12 changed files
with
182 additions
and
5 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 @@ | ||
storybook-static |
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,75 @@ | ||
import type { StorybookConfig } from "@storybook/react-webpack5"; | ||
|
||
import { dirname, join, resolve } from "node:path"; | ||
|
||
// ? for monorepo support | ||
function getAbsolutePath(value: string): string { | ||
return dirname(require.resolve(join(value, "package.json"))); | ||
} | ||
|
||
// ? https://github.com/storybookjs/addon-react-native-web/issues/45 | ||
export default { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(ts|tsx)"], | ||
addons: [ | ||
getAbsolutePath("@storybook/addon-webpack5-compiler-babel"), | ||
getAbsolutePath("@storybook/addon-onboarding"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@chromatic-com/storybook"), | ||
getAbsolutePath("@storybook/addon-interactions"), | ||
{ | ||
name: getAbsolutePath("@storybook/addon-react-native-web"), | ||
options: { | ||
modulesToTranspile: [ | ||
"react-native-reanimated", | ||
"nativewind", | ||
"react-native-css-interop", | ||
], | ||
babelPresets: ["nativewind/babel"], | ||
babelPresetReactOptions: { jsxImportSource: "nativewind" }, | ||
babelPlugins: [ | ||
"react-native-reanimated/plugin", | ||
[ | ||
"@babel/plugin-transform-react-jsx", | ||
{ | ||
runtime: "automatic", | ||
importSource: "nativewind", | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
], | ||
framework: { | ||
name: getAbsolutePath("@storybook/react-webpack5"), | ||
options: { fastRefresh: true }, | ||
}, | ||
typescript: { | ||
check: false, | ||
checkOptions: {}, | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
webpackFinal: (config) => { | ||
if (config.module?.rules) { | ||
config.module.rules.push({ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: "postcss-loader", | ||
options: { | ||
postcssOptions: { | ||
plugins: [require("tailwindcss"), require("autoprefixer")], | ||
}, | ||
}, | ||
}, | ||
], | ||
include: resolve(__dirname, "../"), | ||
}); | ||
} | ||
|
||
return { | ||
...config, | ||
}; | ||
}, | ||
} satisfies StorybookConfig; |
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,16 @@ | ||
import type { Preview } from "@storybook/react"; | ||
|
||
import "../global.css"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
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,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
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 @@ | ||
/// <reference types="nativewind/types" /> |
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,34 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { View } from "react-native"; | ||
import MyButton from "./button"; | ||
|
||
const meta = { | ||
title: "MyButton", | ||
component: MyButton, | ||
argTypes: { | ||
onPress: { action: "pressed the button" }, | ||
}, | ||
args: { | ||
title: "Hello world", | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
<View style={{ padding: 16, alignItems: "flex-start" }}> | ||
<Story /> | ||
</View> | ||
), | ||
], | ||
} satisfies Meta<typeof MyButton>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; | ||
|
||
export const AnotherExample: Story = { | ||
args: { | ||
title: "Another example", | ||
}, | ||
}; |
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 { Text, TouchableOpacity } from "react-native"; | ||
|
||
export default function Button({ | ||
title, | ||
onPress, | ||
}: { title: string; onPress?: () => void }) { | ||
return ( | ||
<TouchableOpacity | ||
className="rounded-lg bg-blue-500 p-4" | ||
onPressIn={onPress} | ||
> | ||
<Text className="text-white">{title}</Text> | ||
</TouchableOpacity> | ||
); | ||
} |
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,10 @@ | ||
import type { Config } from "tailwindcss"; | ||
|
||
// @ts-expect-error - no types | ||
import nativewind from "nativewind/preset"; | ||
|
||
export default { | ||
content: ["src/**/*.{js,jsx,ts,tsx}"], | ||
presets: [nativewind], | ||
plugins: [], | ||
} satisfies Config; |
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,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": ["**/*.stories.tsx", "node_modules"] | ||
} |
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