|
| 1 | +/** @import { Args, Meta, StoryObj } from '@storybook/html' */ |
| 2 | +import './background.scss'; |
| 3 | + |
| 4 | +/** @param {Args} args */ |
| 5 | +const backgroundStory = (args) => { |
| 6 | + const classNames = [args.color || '']; |
| 7 | + const textColor = [args.text || '']; |
| 8 | + const className = classNames |
| 9 | + .map((segment) => (segment.length > 0 ? `u-bg-${segment}` : 'u-bg')) |
| 10 | + .join(' '); |
| 11 | + return `<div class="u-text-${textColor} ${className} u-pad-n1">${className}</div>`; |
| 12 | +}; |
| 13 | + |
| 14 | +/** @type {Meta} */ |
| 15 | +const meta = { |
| 16 | + title: 'Utilities/Background', |
| 17 | + argTypes: { |
| 18 | + color: { |
| 19 | + options: ['green', 'purple', 'fuchsia', 'orange', 'none'], |
| 20 | + type: { |
| 21 | + name: 'enum', |
| 22 | + value: ['green', 'purple', 'fuchsia', 'orange', 'none'], |
| 23 | + }, |
| 24 | + control: { type: 'inline-radio' }, |
| 25 | + }, |
| 26 | + text: { |
| 27 | + options: ['light', 'dark'], |
| 28 | + }, |
| 29 | + }, |
| 30 | + render: (args) => backgroundStory(args), |
| 31 | +}; |
| 32 | + |
| 33 | +export default meta; |
| 34 | + |
| 35 | +/** @type {StoryObj} */ |
| 36 | +export const Green = { |
| 37 | + args: { color: 'green', text: 'light' }, |
| 38 | +}; |
| 39 | + |
| 40 | +/** @type {StoryObj} */ |
| 41 | +export const Purple = { |
| 42 | + args: { color: 'purple', text: 'light' }, |
| 43 | +}; |
| 44 | + |
| 45 | +/** @type {StoryObj} */ |
| 46 | +export const Fuchsia = { |
| 47 | + args: { color: 'fuchsia', text: 'light' }, |
| 48 | +}; |
| 49 | + |
| 50 | +/** @type {StoryObj} */ |
| 51 | +export const Orange = { |
| 52 | + args: { color: 'orange', text: 'light' }, |
| 53 | +}; |
| 54 | + |
| 55 | +/** @type {StoryObj} */ |
| 56 | +export const None = { |
| 57 | + args: { color: 'none', text: 'dark' }, |
| 58 | +}; |
0 commit comments