|
| 1 | +import { |
| 2 | + EditorialMessage, |
| 3 | + EditorialMessageProps, |
| 4 | + type EditorialMessageType, |
| 5 | +} from "@axa-fr/canopee-react/distributeur"; |
| 6 | + |
| 7 | +import accessibilityIcon from "@material-symbols/svg-700/outlined/accessibility_new-fill.svg"; |
| 8 | +import eco from "@material-symbols/svg-700/outlined/eco-fill.svg"; |
| 9 | +import promotionIcon from "@material-symbols/svg-700/outlined/percent-fill.svg"; |
| 10 | +import { Meta, StoryObj } from "@storybook/react"; |
| 11 | +import { InputType } from "storybook/internal/types"; |
| 12 | + |
| 13 | +const TYPES = ["green", "information", "promotion"] as EditorialMessageType[]; |
| 14 | +const iconNames = [ |
| 15 | + "accessibility_new-fill", |
| 16 | + "eco-fill", |
| 17 | + "percent-fill", |
| 18 | +] as const; |
| 19 | + |
| 20 | +const typeInputType: InputType = { |
| 21 | + options: TYPES, |
| 22 | + control: { |
| 23 | + type: "inline-radio", |
| 24 | + }, |
| 25 | + table: { |
| 26 | + type: { |
| 27 | + summary: "string", |
| 28 | + }, |
| 29 | + category: "Style", |
| 30 | + }, |
| 31 | + description: |
| 32 | + "Type of the editorial message. Used to determine the icon and style.", |
| 33 | +}; |
| 34 | + |
| 35 | +/** |
| 36 | + * Visual component used to highlight information about accessibility, promotions, eco-design, etc. |
| 37 | + * Its display is not triggered by user interaction. |
| 38 | + */ |
| 39 | +const meta = { |
| 40 | + title: "Components/EditorialMessage", |
| 41 | + component: EditorialMessage, |
| 42 | + argTypes: { |
| 43 | + type: typeInputType, |
| 44 | + children: { |
| 45 | + control: { type: "text" }, |
| 46 | + description: |
| 47 | + "Content of the editorial message. Either children or title must be provided.", |
| 48 | + table: { |
| 49 | + category: "Content", |
| 50 | + type: { |
| 51 | + summary: "string", |
| 52 | + }, |
| 53 | + }, |
| 54 | + }, |
| 55 | + title: { |
| 56 | + control: { type: "text" }, |
| 57 | + description: |
| 58 | + "Title of the message. Either title or children must be provided.", |
| 59 | + table: { |
| 60 | + category: "Content", |
| 61 | + type: { |
| 62 | + summary: "string", |
| 63 | + }, |
| 64 | + }, |
| 65 | + }, |
| 66 | + icon: { |
| 67 | + control: { type: "inline-radio" }, |
| 68 | + options: iconNames, |
| 69 | + description: "Icon displayed in the editorial message, as a URI.", |
| 70 | + table: { |
| 71 | + category: "Style", |
| 72 | + }, |
| 73 | + mapping: { |
| 74 | + "accessibility_new-fill": accessibilityIcon, |
| 75 | + "eco-fill": eco, |
| 76 | + "percent-fill": promotionIcon, |
| 77 | + }, |
| 78 | + }, |
| 79 | + }, |
| 80 | + render: (args) => <EditorialMessage {...args} icon={args.icon} />, |
| 81 | +} satisfies Meta<EditorialMessageProps>; |
| 82 | + |
| 83 | +export default meta; |
| 84 | + |
| 85 | +type Story = StoryObj<EditorialMessageProps>; |
| 86 | + |
| 87 | +export const Green: Story = { |
| 88 | + args: { |
| 89 | + type: "green", |
| 90 | + title: "Eco-conception", |
| 91 | + icon: "eco-fill", |
| 92 | + children: |
| 93 | + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", |
| 94 | + }, |
| 95 | +}; |
| 96 | + |
| 97 | +export const Information: Story = { |
| 98 | + args: { |
| 99 | + type: "information", |
| 100 | + title: "Accessibility", |
| 101 | + icon: "accessibility_new-fill", |
| 102 | + children: |
| 103 | + "This service is designed to be accessible to everyone, including people with disabilities.", |
| 104 | + }, |
| 105 | +}; |
| 106 | + |
| 107 | +export const Promotion: Story = { |
| 108 | + args: { |
| 109 | + type: "promotion", |
| 110 | + title: "Promotion", |
| 111 | + icon: "percent-fill", |
| 112 | + children: |
| 113 | + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", |
| 114 | + }, |
| 115 | +}; |
| 116 | + |
| 117 | +export const NoContent: Story = { |
| 118 | + name: "No content (title only)", |
| 119 | + args: { |
| 120 | + type: "green", |
| 121 | + title: "This application was built with eco-design in mind.", |
| 122 | + icon: "eco-fill", |
| 123 | + }, |
| 124 | + argTypes: { |
| 125 | + children: { control: false }, |
| 126 | + }, |
| 127 | +}; |
| 128 | + |
| 129 | +export const NoTitle: Story = { |
| 130 | + name: "No Title (content only)", |
| 131 | + args: { |
| 132 | + type: "green", |
| 133 | + children: ( |
| 134 | + <> |
| 135 | + <p> |
| 136 | + This application was built following eco-design best practices, |
| 137 | + minimizing its environmental impact through optimized code, reduced |
| 138 | + resource consumption, and sustainable development principles. |
| 139 | + </p> |
| 140 | + <p> |
| 141 | + We prioritize energy efficiency, limit data transfers, and implement |
| 142 | + green hosting solutions to ensure our digital footprint remains as |
| 143 | + small as possible while delivering exceptional user experience. |
| 144 | + </p> |
| 145 | + </> |
| 146 | + ), |
| 147 | + icon: "eco-fill", |
| 148 | + }, |
| 149 | + argTypes: { |
| 150 | + children: { control: false }, |
| 151 | + title: { control: false }, |
| 152 | + }, |
| 153 | +}; |
0 commit comments