Skip to content

Commit

Permalink
πŸ“– POC Proposal preview page stories (#4420)
Browse files Browse the repository at this point in the history
* Mock Apollo client

* Add some stories for the `ProposalPreview` page

* Fix scroll

* Mock the api

* Mock the api in the ProposalPreview story

* Add utilities to clarify mock data

* Rename the query node mock file

* Mock Accounts, Balances, and Membership providers

* Add members to the stories

* Fix the query node mock

* Simplify chain mocks

* Fix the isCouncilMember case

* Mock discussion whitelist

* Mock all the story environment in one function

* Mock proposalStatusUpdates

* Mock discussionThread posts

* Mock votes

* Move proposalDetailsMap out of the stories file

* Fix storybook styles without affecting the app

* Fix newly failing stories

* Fix proposal component stories

* Move related stories inside "ProposalPreview"
  • Loading branch information
thesan committed Jun 13, 2023
1 parent f7918ff commit e1b9bba
Show file tree
Hide file tree
Showing 23 changed files with 997 additions and 182 deletions.
1 change: 1 addition & 0 deletions packages/ui/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
{
alias: {
'@/common/utils/crypto/worker$': path.resolve(__dirname, '../src/common/utils/crypto'),
'@apollo/client$': path.resolve(__dirname, '../src/mocks/providers/query-node'),
},
},
shared.resolve
Expand Down
74 changes: 0 additions & 74 deletions packages/ui/.storybook/preview.jsx

This file was deleted.

97 changes: 97 additions & 0 deletions packages/ui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { Decorator } from '@storybook/react'
import React from 'react'
import { I18nextProvider } from 'react-i18next'
import { useForm, FormProvider } from 'react-hook-form'
import { MemoryRouter, Redirect, Route, Switch } from 'react-router'
import { createGlobalStyle } from 'styled-components'

import { NotFound } from '../src/app/pages/NotFound'
import { GlobalStyle } from '../src/app/providers/GlobalStyle'
import { Colors } from '../src/common/constants'
import { MockProvidersDecorator } from '../src/mocks/providers'
import { i18next } from '../src/services/i18n'

const stylesWrapperDecorator: Decorator = (Story) => (
<>
<GlobalStyle />
<StoryStyles />
{Story()}
</>
)
const StoryStyles = createGlobalStyle`
body, html {
overflow: visible
}
`

const i18nextDecorator: Decorator = (Story) => (
<React.Suspense fallback="Missing i18next config">
<I18nextProvider i18n={i18next}>
<Story />
</I18nextProvider>
</React.Suspense>
)

const RHFDecorator: Decorator = (Story) => {
const form = useForm()
return (
<React.Suspense fallback="Loading RHF context">
<FormProvider {...form}>
<Story />
</FormProvider>
</React.Suspense>
)
}

const RouterDecorator: Decorator = (Story, { parameters }) => (
<MemoryRouter initialEntries={[`/story/${parameters.router?.href ?? ''}`]}>
<Switch>
<Route component={Story} path={`/story/${parameters.router?.path ?? ''}`} />
<Route exact path="/404" component={NotFound} />
<Redirect from="*" to="/404" />
</Switch>
</MemoryRouter>
)

export const decorators = [
stylesWrapperDecorator,
i18nextDecorator,
RHFDecorator,
MockProvidersDecorator,
RouterDecorator,
]

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
backgrounds: {
default: 'White',
values: [
{
name: 'White',
value: Colors.White,
},
{
name: 'Black',
value: Colors.Black[900],
},
{
name: 'Modal',
value: Colors.Black[50],
},
{
name: 'Disabled',
value: Colors.Black[75],
},
{
name: 'Around modal glass',
value: Colors.Black[700.85],
},
],
},
options: {
storySort: {
method: 'alphabetical',
order: ['Common'],
},
},
}
Loading

2 comments on commit e1b9bba

@vercel
Copy link

@vercel vercel bot commented on e1b9bba Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pioneer-2-storybook – ./

pioneer-2-storybook.vercel.app
pioneer-2-storybook-joystream.vercel.app
pioneer-2-storybook-git-dev-joystream.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e1b9bba Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pioneer-2 – ./

pioneer-2-git-dev-joystream.vercel.app
pioneer-2-joystream.vercel.app
pioneer-2.vercel.app

Please sign in to comment.