|
| 1 | +import type { Meta, StoryObj, StoryContext } from "@storybook/react"; |
| 2 | +import Card from "@mui/material/Card"; |
| 3 | +import CardActions from "@mui/material/CardActions"; |
| 4 | +import CardContent from "@mui/material/CardContent"; |
| 5 | +import Button from "@mui/material/Button"; |
| 6 | +import Typography from "@mui/material/Typography"; |
| 7 | +import Box from "@mui/material/Box"; |
| 8 | +import { argChildren, argProps } from "./utils/formatArgs"; |
| 9 | + |
| 10 | +// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction |
| 11 | +const meta: Meta<typeof Card> = { |
| 12 | + title: "SURFACES/Card", |
| 13 | + component: Card, |
| 14 | + parameters: { |
| 15 | + docs: { |
| 16 | + source: { language: "tsx", format: true, type: "dynamic" }, |
| 17 | + description: { |
| 18 | + component: |
| 19 | + "The value must be chosen from a predefined set of allowed values.", |
| 20 | + }, |
| 21 | + canvas: { sourceState: "shown" }, |
| 22 | + }, |
| 23 | + layout: "centered", |
| 24 | + }, |
| 25 | + tags: ["autodocs"], |
| 26 | + argTypes: { |
| 27 | + raised: { |
| 28 | + control: { type: "boolean" }, |
| 29 | + description: "If `true`, the card will use raised styling.", |
| 30 | + defaultValue: false, |
| 31 | + }, |
| 32 | + }, |
| 33 | +}; |
| 34 | + |
| 35 | +export default meta; |
| 36 | +type Story = StoryObj<typeof Card>; |
| 37 | + |
| 38 | +const bull = ( |
| 39 | + <Box |
| 40 | + component="span" |
| 41 | + sx={{ display: "inline-block", mx: "2px", transform: "scale(0.8)" }} |
| 42 | + > |
| 43 | + • |
| 44 | + </Box> |
| 45 | +); |
| 46 | + |
| 47 | +// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args |
| 48 | +export const Cards: Story = { |
| 49 | + args: { |
| 50 | + children: ( |
| 51 | + <> |
| 52 | + <CardContent> |
| 53 | + <Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom> |
| 54 | + Word of the Day |
| 55 | + </Typography> |
| 56 | + <Typography variant="h5" component="div"> |
| 57 | + be{bull}nev{bull}o{bull}lent |
| 58 | + </Typography> |
| 59 | + <Typography sx={{ mb: 1.5 }} color="text.secondary"> |
| 60 | + adjective |
| 61 | + </Typography> |
| 62 | + <Typography variant="body2"> |
| 63 | + well meaning and kindly. |
| 64 | + <br /> |
| 65 | + {'"a benevolent smile"'} |
| 66 | + </Typography> |
| 67 | + </CardContent> |
| 68 | + <CardActions> |
| 69 | + <Button size="small">Learn More</Button> |
| 70 | + </CardActions> |
| 71 | + </> |
| 72 | + ), |
| 73 | + }, |
| 74 | + parameters: { |
| 75 | + docs: { |
| 76 | + source: { |
| 77 | + transform: (code: string, storyContext: StoryContext): string => ` |
| 78 | +import Card from '@mui/material/Card'; |
| 79 | +import CardActions from '@mui/material/CardActions'; |
| 80 | +import CardContent from '@mui/material/CardContent'; |
| 81 | +import Button from '@mui/material/Button'; |
| 82 | +import Typography from '@mui/material/Typography'; |
| 83 | +import Box from '@mui/material/Box'; |
| 84 | +
|
| 85 | +const bull = ( |
| 86 | + <Box |
| 87 | + component="span" |
| 88 | + sx={{ display: "inline-block", mx: "2px", transform: "scale(0.8)" }} |
| 89 | + > |
| 90 | + • |
| 91 | + </Box> |
| 92 | +); |
| 93 | +
|
| 94 | +<Card ${argProps(storyContext)}> |
| 95 | + <CardContent> |
| 96 | + <Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom> |
| 97 | + Word of the Day |
| 98 | + </Typography> |
| 99 | + <Typography variant="h5" component="div"> |
| 100 | + be{bull}nev{bull}o{bull}lent |
| 101 | + </Typography> |
| 102 | + <Typography sx={{ mb: 1.5 }} color="text.secondary"> |
| 103 | + adjective |
| 104 | + </Typography> |
| 105 | + <Typography variant="body2"> |
| 106 | + well meaning and kindly. |
| 107 | + <br /> |
| 108 | + {'"a benevolent smile"'} |
| 109 | + </Typography> |
| 110 | + </CardContent> |
| 111 | + <CardActions> |
| 112 | + <Button size="small">Learn More</Button> |
| 113 | + </CardActions> |
| 114 | +</Card> |
| 115 | + `, |
| 116 | + }, |
| 117 | + }, |
| 118 | + }, |
| 119 | +}; |
0 commit comments