Skip to content

Commit

Permalink
web: require enabling Chromatic snapshot for every story manually (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
valerybugakov authored and pietrorosa77 committed Feb 15, 2022
1 parent b5671ec commit 2afe131
Show file tree
Hide file tree
Showing 41 changed files with 187 additions and 135 deletions.
Expand Up @@ -12,6 +12,7 @@ const config: Meta = {
parameters: {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
},
}
Expand Down
Expand Up @@ -21,7 +21,6 @@ const decorator: DecoratorFn = story => <BrandedStory styles={brandedStyles}>{()
const config: Meta = {
title: 'browser/Options/OptionsPage',
decorators: [decorator],
parameters: { chromatic: { delay: 500, enableDarkMode: true } },
}

export default config
Expand Down Expand Up @@ -49,6 +48,14 @@ const OptionsPageWrapper: React.FunctionComponent<Partial<OptionsPageProps>> = p

export const Default: Story = () => <OptionsPageWrapper />

Default.parameters = {
chromatic: {
delay: 500,
enableDarkMode: true,
disableSnapshot: false,
},
}

export const Interactive: Story = () => {
const [isActivated, setIsActivated] = useState(false)
return <OptionsPageWrapper isActivated={isActivated} onToggleActivated={setIsActivated} />
Expand Down
Expand Up @@ -25,6 +25,7 @@ const config: Meta = {
parameters: {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions client/shared/src/actions/ActionItem.story.tsx
Expand Up @@ -70,6 +70,12 @@ export const CommandAction: Story = () => (
)

CommandAction.storyName = 'Command action'
CommandAction.parameters = {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
}

export const LinkAction: Story = () => (
<ActionItem
Expand Down
1 change: 1 addition & 0 deletions client/shared/src/components/CtaAlert.story.tsx
Expand Up @@ -15,6 +15,7 @@ const config: Meta = {
component: CtaAlert,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
},
}
Expand Down
Expand Up @@ -97,3 +97,9 @@ export const _14Completed: Story = () => (
)

_14Completed.storyName = '1/4 completed'
_14Completed.parameters = {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
}
1 change: 1 addition & 0 deletions client/shared/src/hover/HoverOverlay.story.tsx
Expand Up @@ -27,6 +27,7 @@ const config: Meta = {
parameters: {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions client/shared/src/notifications/NotificationItem.story.tsx
Expand Up @@ -77,3 +77,9 @@ export const WithProgress: Story = () => {
}

WithProgress.storyName = 'With progress'
WithProgress.parameters = {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
}
2 changes: 2 additions & 0 deletions client/storybook/src/preview.ts
Expand Up @@ -28,6 +28,8 @@ export const parameters = {
light: themeLight,
dark: themeDark,
},
// disables snapshotting for all stories by default
chromatic: { disableSnapshot: true },
}

configureActions({ depth: 100, limit: 20 })
Expand Down
Expand Up @@ -33,6 +33,10 @@ const { add } = storiesOf('web/WebHoverOverlay', module)
url:
'https://www.figma.com/file/NIsN34NH7lPu04olBzddTw/Design-Refresh-Systemization-source-of-truth?node-id=2877%3A35469',
},
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
})

add('Loading', () => (
Expand Down
3 changes: 3 additions & 0 deletions client/web/src/marketing/SurveyPage.story.tsx
Expand Up @@ -6,6 +6,7 @@ import { WebStory } from '@sourcegraph/web/src/components/WebStory'

import { SurveyPage } from './SurveyPage'
import { submitSurveyMock } from './SurveyPage.mocks'
import { SurveyToast } from './SurveyToast'

const decorator: DecoratorFn = story => <WebStory>{() => <div className="container mt-3">{story()}</div>}</WebStory>

Expand All @@ -21,3 +22,5 @@ export const Page: Story = () => (
<SurveyPage authenticatedUser={null} forceScore="10" />
</MockedStoryProvider>
)

export const Toast: Story = () => <SurveyToast forceVisible={true} />
17 changes: 0 additions & 17 deletions client/web/src/marketing/SurveyToast.story.tsx

This file was deleted.

11 changes: 9 additions & 2 deletions client/web/src/nav/Feedback/FeedbackPrompt.story.tsx
@@ -1,5 +1,5 @@
import { MockedResponse } from '@apollo/client/testing'
import { Meta } from '@storybook/react'
import { Meta, Story } from '@storybook/react'
import React from 'react'

import { BrandedStory } from '@sourcegraph/branded/src/components/BrandedStory'
Expand Down Expand Up @@ -32,6 +32,13 @@ const config: Meta = {
),
],
parameters: {
/**
* Uncomment this once Storybook is upgraded to v6.4.* and the `play` function
* is used to show the feedback prompt component.
*
* https://www.chromatic.com/docs/hoverfocus#javascript-triggered-hover-states
*/
// chromatic: { disableSnapshot: false },
component: FeedbackPrompt,
design: {
type: 'figma',
Expand All @@ -43,7 +50,7 @@ const config: Meta = {

export default config

export const FeedbackPromptExample = () => (
export const FeedbackPromptExample: Story = () => (
<>
<h1>This is a feedbackPrompt</h1>
<FeedbackPrompt routes={[]} />
Expand Down
1 change: 1 addition & 0 deletions client/wildcard/src/components/Alert/Alert.story.tsx
Expand Up @@ -30,6 +30,7 @@ const config: Meta = {
component: Alert,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
design: [
{
Expand Down
1 change: 1 addition & 0 deletions client/wildcard/src/components/Badge/Badge.story.tsx
Expand Up @@ -21,6 +21,7 @@ const config: Meta = {
component: Badge,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
design: {
type: 'figma',
Expand Down
Expand Up @@ -20,6 +20,7 @@ const config: Meta = {
component: ProductStatusBadge,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
design: {
type: 'figma',
Expand Down
11 changes: 8 additions & 3 deletions client/wildcard/src/components/Button/story/Button.story.tsx
Expand Up @@ -14,6 +14,7 @@ import { ButtonVariants } from './ButtonVariants'

const config: Meta = {
title: 'wildcard/Button',
component: Button,

decorators: [
story => (
Expand All @@ -23,9 +24,6 @@ const config: Meta = {

parameters: {
component: Button,
chromatic: {
enableDarkMode: true,
},
design: {
type: 'figma',
name: 'Figma',
Expand Down Expand Up @@ -106,3 +104,10 @@ export const AllButtons: Story = () => (
</Button>
</div>
)

AllButtons.parameters = {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
}
Expand Up @@ -23,6 +23,7 @@ const Config: Meta = {
component: ButtonLink,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
},
}
Expand Down
Expand Up @@ -5,11 +5,14 @@ import { BrandedStory } from '@sourcegraph/branded/src/components/BrandedStory'
import { Toggle } from '@sourcegraph/branded/src/components/Toggle'
import webStyles from '@sourcegraph/web/src/SourcegraphWebApp.scss'

import { Card, CardBody, CardFooter, CardHeader, CardSubtitle, CardText, CardTitle } from '..'
import { Button, Grid } from '../..'
import { Button } from '../Button'
import { Grid } from '../Grid'

import { Card, CardBody, CardFooter, CardHeader, CardSubtitle, CardText, CardTitle } from '.'

const config: Meta = {
title: 'wildcard/Card',
component: Card,

decorators: [
story => (
Expand All @@ -21,6 +24,7 @@ const config: Meta = {
component: Card,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
design: {
type: 'figma',
Expand Down
2 changes: 2 additions & 0 deletions client/wildcard/src/components/Container/Container.story.tsx
Expand Up @@ -15,6 +15,7 @@ const decorator: DecoratorFn = story => (

const config: Meta = {
title: 'wildcard/Container',
component: Container,
decorators: [decorator],
}

Expand Down Expand Up @@ -89,6 +90,7 @@ export const Overview: Story = () => (
Overview.parameters = {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
design: {
type: 'figma',
Expand Down
Expand Up @@ -19,6 +19,7 @@ const config: Meta = {
component: FeedbackBadge,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
},
}
Expand Down
Expand Up @@ -18,6 +18,7 @@ const config: Meta = {
component: FeedbackText,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
},
}
Expand Down
14 changes: 9 additions & 5 deletions client/wildcard/src/components/Form/Checkbox/Checkbox.story.tsx
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'
import { Meta, Story } from '@storybook/react'
import React, { useCallback } from 'react'

import { BrandedStory } from '@sourcegraph/branded/src/components/BrandedStory'
Expand All @@ -19,9 +19,6 @@ const config: Meta = {

parameters: {
component: Checkbox,
chromatic: {
enableDarkMode: true,
},
design: {
type: 'figma',
name: 'Figma',
Expand Down Expand Up @@ -54,7 +51,7 @@ const BaseCheckbox = ({ name, ...props }: { name: string } & Pick<CheckboxProps,
)
}

export const CheckboxExamples: React.FunctionComponent = () => (
export const CheckboxExamples: Story = () => (
<>
<h1>Checkbox</h1>
<Grid columnCount={4}>
Expand All @@ -77,3 +74,10 @@ export const CheckboxExamples: React.FunctionComponent = () => (
</Grid>
</>
)

CheckboxExamples.parameters = {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
}
1 change: 1 addition & 0 deletions client/wildcard/src/components/Form/Input/Input.story.tsx
Expand Up @@ -19,6 +19,7 @@ const Story: Meta = {
component: Input,
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
design: {
type: 'figma',
Expand Down
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'
import { Meta, Story } from '@storybook/react'
import React, { useCallback } from 'react'

import { BrandedStory } from '@sourcegraph/branded/src/components/BrandedStory'
Expand All @@ -19,9 +19,6 @@ const config: Meta = {

parameters: {
component: RadioButton,
chromatic: {
enableDarkMode: true,
},
design: {
type: 'figma',
name: 'Figma',
Expand Down Expand Up @@ -76,7 +73,7 @@ const BaseRadio = ({ name, ...props }: Pick<RadioButtonProps, 'name' | 'isValid'
)
}

export const RadioExamples: React.FunctionComponent = () => (
export const RadioExamples: Story = () => (
<>
<h1>Radio</h1>
<Grid columnCount={4}>
Expand All @@ -99,3 +96,10 @@ export const RadioExamples: React.FunctionComponent = () => (
</Grid>
</>
)

RadioExamples.parameters = {
chromatic: {
enableDarkMode: true,
disableSnapshot: false,
},
}

0 comments on commit 2afe131

Please sign in to comment.