-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DetailCell: Add variant stories (#2407)
## Summary: Add scenario and variant stories for DetailCell. This will help us confirm styling for different states with visual regression tests. For now, the color contrast issues haven't been addressed yet. Coordinating with design on what styling updates we want long term (see WB-1797 comments for more details!). Including these stories for now so we can have visual regression tests ready when we address the color issues! Issue: WB-1797 ## Test plan: - Review stories for: - All Variants (`?path=/docs/packages-cell-detailcell-all-variants--docs`) - Scenarios (`?path=/story/packages-cell-detailcell--scenarios`) Author: beaesguerra Reviewers: beaesguerra, marcysutton Required Reviewers: Approved By: marcysutton Checks: ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ⏭️ Publish npm snapshot, ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ⏭️ Chromatic - Skip on Release PR (changesets), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ⏭️ Chromatic - Skip on Release PR (changesets), ⏹️ [cancelled] Chromatic - Get results on regular PRs, ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ⌛ undefined Pull Request URL: #2407
- Loading branch information
1 parent
2ecdfb5
commit 3fbcb28
Showing
2 changed files
with
247 additions
and
0 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
__docs__/wonder-blocks-cell/detail-cell-variants.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import * as React from "react"; | ||
import {StyleSheet} from "aphrodite"; | ||
import type {Meta, StoryObj} from "@storybook/react"; | ||
|
||
import {PropsFor, View} from "@khanacademy/wonder-blocks-core"; | ||
import {spacing} from "@khanacademy/wonder-blocks-tokens"; | ||
import {DetailCell} from "@khanacademy/wonder-blocks-cell"; | ||
import {PhosphorIcon} from "@khanacademy/wonder-blocks-icon"; | ||
import {IconMappings} from "../wonder-blocks-icon/phosphor-icon.argtypes"; | ||
import {LabelSmall} from "@khanacademy/wonder-blocks-typography"; | ||
|
||
/** | ||
* The following stories are used to generate the pseudo states for the | ||
* DetailCell component. This is only used for visual testing in Chromatic. | ||
*/ | ||
export default { | ||
title: "Packages / Cell / DetailCell / All Variants", | ||
parameters: { | ||
docs: { | ||
autodocs: false, | ||
}, | ||
backgrounds: { | ||
default: "offWhite", | ||
}, | ||
}, | ||
} as Meta; | ||
|
||
type StoryComponentType = StoryObj<typeof DetailCell>; | ||
|
||
const states = [ | ||
{ | ||
label: "Default", | ||
props: {}, | ||
}, | ||
{ | ||
label: "Disabled", | ||
props: {disabled: true}, | ||
}, | ||
{ | ||
label: "Active", | ||
props: {active: true}, | ||
}, | ||
]; | ||
|
||
const defaultProps = { | ||
title: "Title for article item", | ||
subtitle1: "Subtitle 1 for article item", | ||
subtitle2: "Subtitle 2 for article item", | ||
leftAccessory: ( | ||
<PhosphorIcon icon={IconMappings.playCircle} size="medium" /> | ||
), | ||
rightAccessory: <PhosphorIcon icon={IconMappings.caretRight} />, | ||
}; | ||
|
||
const States = (props: {label: string} & PropsFor<typeof DetailCell>) => { | ||
return ( | ||
<View> | ||
<View style={[styles.scenarios]}> | ||
{states.map((scenario) => { | ||
return ( | ||
<View style={styles.scenario} key={scenario.label}> | ||
<LabelSmall> | ||
{props.label} ({scenario.label}) | ||
</LabelSmall> | ||
<DetailCell {...props} {...scenario.props} /> | ||
</View> | ||
); | ||
})} | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const AllVariants = () => ( | ||
<View style={{gap: spacing.large_24}}> | ||
<States label="Default" {...defaultProps} /> | ||
<States label="Clickable" {...defaultProps} onClick={() => {}} /> | ||
<States label="Link" {...defaultProps} href="/" /> | ||
</View> | ||
); | ||
|
||
export const Default: StoryComponentType = { | ||
render: AllVariants, | ||
}; | ||
|
||
export const Hover: StoryComponentType = { | ||
render: AllVariants, | ||
parameters: {pseudo: {hover: true}}, | ||
}; | ||
|
||
export const Focus: StoryComponentType = { | ||
render: AllVariants, | ||
parameters: {pseudo: {focusVisible: true}}, | ||
}; | ||
|
||
export const HoverFocus: StoryComponentType = { | ||
name: "Hover + Focus", | ||
render: AllVariants, | ||
parameters: {pseudo: {hover: true, focusVisible: true}}, | ||
}; | ||
|
||
export const Active: StoryComponentType = { | ||
render: AllVariants, | ||
parameters: {pseudo: {active: true}}, | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
statesContainer: { | ||
padding: spacing.medium_16, | ||
}, | ||
scenarios: { | ||
display: "flex", | ||
flexDirection: "row", | ||
alignItems: "center", | ||
gap: spacing.xxxLarge_64, | ||
flexWrap: "wrap", | ||
}, | ||
scenario: { | ||
gap: spacing.small_12, | ||
overflow: "hidden", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters