Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Storybook setup #110

Merged
merged 21 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions website/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const path = require("path");

module.exports = {
stories: [
"../src/components/**/*.stories.mdx",
"../src/components/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@chakra-ui/storybook-addon",
],
framework: "@storybook/react",
core: {
builder: "@storybook/builder-webpack5",
},
staticDirs: ["../public"],
// https://github.com/storybookjs/storybook/issues/15336#issuecomment-888528747
typescript: { reactDocgen: false },
// fix to make absolute imports working in storybook
webpackFinal: async (config, { configType }) => {
AbdBarho marked this conversation as resolved.
Show resolved Hide resolved
config.resolve.alias = {
...config.resolve.alias,
src: path.resolve(__dirname, "../src"),
};
return config;
},
features: {
emotionAlias: false,
AbdBarho marked this conversation as resolved.
Show resolved Hide resolved
},
};
22 changes: 22 additions & 0 deletions website/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import "!style-loader!css-loader!postcss-loader!tailwindcss/tailwind.css";
AbdBarho marked this conversation as resolved.
Show resolved Hide resolved

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};

// Hacky solution to get Images in next to work
// https://dev.to/jonasmerlin/how-to-use-the-next-js-image-component-in-storybook-1415
import * as NextImage from "next/image";

const OriginalNextImage = NextImage.default;

Object.defineProperty(NextImage, "default", {
configurable: true,
value: (props) => <OriginalNextImage {...props} unoptimized />,
});
AbdBarho marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ Whenever the website runs in development mode, you can use the debug credentials
1. Use the `Login` button in the top right to go to the login page.
1. You should see a section for debug credentials. Enter any username you wish, you will be logged in as that user.

### Using Storybook

To develop components using [Storybook](https://storybook.js.org/) run `npm run storybook`. Then navigate to in your browser to `http://localhost:6006`.

To create a new story create a file named `[componentName].stories.js`. An example how such a story could look like, see `Header.stories.jsx`.

## Code Layout

### React Code
Expand Down