Skip to content

Commit

Permalink
Added support for react-redux components. Added withRedux storybook d…
Browse files Browse the repository at this point in the history
…ecorator. Added stories for CreateUser, SignIn, SignOut.
  • Loading branch information
patcon committed Sep 23, 2024
1 parent 6121ffa commit 3980ddc
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 4 deletions.
16 changes: 13 additions & 3 deletions .storybook/decorators.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import React from 'react'
import { ThemeProvider } from 'theme-ui'
import theme from '../polis/client-admin/src/theme'
import { Provider as ReduxProvider } from 'react-redux'
import configureStore from '../polis/client-admin/src/store'

const store = configureStore()

export const withThemeUi = (Story) => (
<ThemeProvider theme={theme}>
<Story />
</ThemeProvider>
<ThemeProvider theme={theme}>
<Story />
</ThemeProvider>
)

export const withRedux = (Story) => (
<ReduxProvider store={store}>
<Story />
</ReduxProvider>
)
65 changes: 65 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"jquery": "~2.1.4",
"@chromatic-com/storybook": "^1.9.0",
"@storybook/addon-essentials": "^8.3.2",
"@storybook/addon-interactions": "^8.3.2",
Expand All @@ -24,6 +25,8 @@
"prop-types": "^15.8.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-redux": "7.2.2",
"redux-thunk": "~2.3.0",
"storybook": "^8.3.2",
"storybook-addon-remix-react-router": "^3.0.0"
},
Expand Down
19 changes: 19 additions & 0 deletions stories/client-admin/CreateUser.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import CreateUser from '../../polis/client-admin/src/components/landers/createuser'
import { withThemeUi, withRedux } from '../../.storybook/decorators'
import { withRouter, reactRouterParameters } from 'storybook-addon-remix-react-router'

export default {
title: 'Client-Admin/CreateUser',
component: CreateUser,
decorators: [withThemeUi, withRedux, withRouter],
}

const Template = (args) => <CreateUser {...args} />

export const Default = Template.bind({})
Default.args = {
location: {
pathname: '/createuser',
}
}
19 changes: 19 additions & 0 deletions stories/client-admin/SignIn.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import SignIn from '../../polis/client-admin/src/components/landers/signin'
import { withThemeUi, withRedux } from '../../.storybook/decorators'
import { withRouter } from 'storybook-addon-remix-react-router'

export default {
title: 'Client-Admin/SignIn',
component: SignIn,
decorators: [withThemeUi, withRedux, withRouter],
}

const Template = (args) => <SignIn {...args} />

export const Default = Template.bind({})
Default.args = {
location: {
pathname: '/signin',
}
}
19 changes: 19 additions & 0 deletions stories/client-admin/SignOut.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import SignOut from '../../polis/client-admin/src/components/landers/signout'
import { withThemeUi, withRedux } from '../../.storybook/decorators'
import { withRouter } from 'storybook-addon-remix-react-router'

export default {
title: 'Client-Admin/SignOut',
component: SignOut,
decorators: [withThemeUi, withRedux, withRouter],
}

const Template = (args) => <SignOut {...args} />

export const Default = Template.bind({})
Default.args = {
location: {
pathname: '/signin',
}
}

0 comments on commit 3980ddc

Please sign in to comment.