|
| 1 | +import { FeedImage, themeClass, typography, vars } from '@comma/design-system'; |
| 2 | +import type { Meta, StoryObj } from '@storybook/react-vite'; |
| 3 | + |
| 4 | +type FeedImageStoryArgs = { |
| 5 | + heart: boolean; |
| 6 | + imageSrc?: string; |
| 7 | +}; |
| 8 | + |
| 9 | +const meta = { |
| 10 | + title: 'Design System/FeedImage', |
| 11 | + argTypes: { |
| 12 | + heart: { |
| 13 | + control: 'boolean' |
| 14 | + }, |
| 15 | + imageSrc: { |
| 16 | + control: 'text' |
| 17 | + } |
| 18 | + }, |
| 19 | + args: { |
| 20 | + heart: false |
| 21 | + } |
| 22 | +} satisfies Meta<FeedImageStoryArgs>; |
| 23 | + |
| 24 | +export default meta; |
| 25 | + |
| 26 | +type Story = StoryObj<FeedImageStoryArgs>; |
| 27 | + |
| 28 | +const storySurfaceStyle: React.CSSProperties = { |
| 29 | + minHeight: 620, |
| 30 | + display: 'grid', |
| 31 | + placeItems: 'center', |
| 32 | + padding: 32, |
| 33 | + background: vars.color.backgroundPrimary, |
| 34 | + fontFamily: vars.font.body |
| 35 | +}; |
| 36 | + |
| 37 | +const variantsSurfaceStyle: React.CSSProperties = { |
| 38 | + minHeight: 620, |
| 39 | + display: 'grid', |
| 40 | + alignContent: 'center', |
| 41 | + gap: 16, |
| 42 | + padding: 32, |
| 43 | + background: vars.color.backgroundPrimary, |
| 44 | + fontFamily: vars.font.body |
| 45 | +}; |
| 46 | + |
| 47 | +const variantGridStyle: React.CSSProperties = { |
| 48 | + display: 'grid', |
| 49 | + gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 393px))', |
| 50 | + gap: 16 |
| 51 | +}; |
| 52 | + |
| 53 | +const labelStyle: React.CSSProperties = { |
| 54 | + margin: 0, |
| 55 | + color: vars.color.textTertiary, |
| 56 | + ...typography.captionB |
| 57 | +}; |
| 58 | + |
| 59 | +export const HeartOff: Story = { |
| 60 | + render: ({ heart, imageSrc }) => ( |
| 61 | + <div className={themeClass} style={storySurfaceStyle}> |
| 62 | + <FeedImage heart={heart} imageSrc={imageSrc} /> |
| 63 | + </div> |
| 64 | + ) |
| 65 | +}; |
| 66 | + |
| 67 | +export const HeartOn: Story = { |
| 68 | + args: { |
| 69 | + heart: true |
| 70 | + }, |
| 71 | + render: ({ heart, imageSrc }) => ( |
| 72 | + <div className={themeClass} style={storySurfaceStyle}> |
| 73 | + <FeedImage heart={heart} imageSrc={imageSrc} /> |
| 74 | + </div> |
| 75 | + ) |
| 76 | +}; |
| 77 | + |
| 78 | +export const Variants: Story = { |
| 79 | + render: () => ( |
| 80 | + <div className={themeClass} style={variantsSurfaceStyle}> |
| 81 | + <div style={variantGridStyle}> |
| 82 | + <div style={{ display: 'grid', gap: 8 }}> |
| 83 | + <h3 style={labelStyle}>heart off</h3> |
| 84 | + <FeedImage /> |
| 85 | + </div> |
| 86 | + <div style={{ display: 'grid', gap: 8 }}> |
| 87 | + <h3 style={labelStyle}>heart on</h3> |
| 88 | + <FeedImage heart /> |
| 89 | + </div> |
| 90 | + </div> |
| 91 | + </div> |
| 92 | + ) |
| 93 | +}; |
0 commit comments