Skip to content

Commit

Permalink
Add storybook with example
Browse files Browse the repository at this point in the history
  • Loading branch information
vin0401 committed Jan 19, 2024
1 parent cbca7a2 commit c8844cb
Show file tree
Hide file tree
Showing 13 changed files with 13,400 additions and 4,260 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = {
},
"extends": [
"standard-with-typescript",
"plugin:react/recommended"
"plugin:react/recommended",
"plugin:storybook/recommended"
],
"overrides": [
{
Expand Down
23 changes: 23 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { StorybookConfig } from "@storybook/react-webpack5";

const config: StorybookConfig = {
stories: ["../assets/js/**/*.mdx", "../assets/js/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-webpack5",
options: {
builder: {
useSWC: true,
},
},
},
docs: {
autodocs: "tag",
},
};
export default config;
15 changes: 15 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Preview } from "@storybook/react";

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

export default preview;
2 changes: 1 addition & 1 deletion assets/js/app/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const injectSliceWithState = (newSlice: AnySliceLike): CombinedSliceReduc
return rootReducer
}

export type AppStore = typeof store
export type AppDispatch = typeof store.dispatch
export type RootState = ReturnType<typeof rootReducer>

export type AppStore = typeof store
export const useAppDispatch: () => AppDispatch = useDispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
15 changes: 15 additions & 0 deletions assets/js/components/example/example.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { Meta } from '@storybook/react';

import { Example as ExampleComponent } from './example';

export default {
title: 'Pimcore workbench/Example',
component: ExampleComponent,
parameters: {
layout: 'centered'
},
tags: ['autodocs']
} as Meta;

export const _default = {}
5 changes: 3 additions & 2 deletions assets/js/components/example/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import React from 'react'

interface ExampleProps {
value: string
prefix?: string
}

export const Example = ({ value }: ExampleProps): React.JSX.Element => {
export const Example = ({ value, prefix }: ExampleProps): React.JSX.Element => {
return (
<div>
<h1>Hello, {value}!</h1>
<h1>Hello, {prefix} {value}!</h1>
</div>
)
}
2 changes: 1 addition & 1 deletion assets/js/modules/app/utils/app-runner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react'
import React from 'react'
import { createRoot } from 'react-dom/client'
import { App } from '../components/app'

Expand Down
Loading

0 comments on commit c8844cb

Please sign in to comment.