@adobe-commerce/elsie 1.0.0-alpha04071347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.elsie.js +21 -0
- package/.eslintrc.js +18 -0
- package/README.md +52 -0
- package/__mocks__/svg.js +11 -0
- package/bin/builders/build/index.js +20 -0
- package/bin/builders/generate/api/index.js +65 -0
- package/bin/builders/generate/api/templates/function.js +9 -0
- package/bin/builders/generate/api/templates/index.js +7 -0
- package/bin/builders/generate/api/templates/story.js +23 -0
- package/bin/builders/generate/api/templates/unit-test.js +15 -0
- package/bin/builders/generate/component/index.js +87 -0
- package/bin/builders/generate/component/templates/Component.js +43 -0
- package/bin/builders/generate/component/templates/css.js +24 -0
- package/bin/builders/generate/component/templates/index.js +8 -0
- package/bin/builders/generate/component/templates/stories.js +46 -0
- package/bin/builders/generate/component/templates/unit-test.js +19 -0
- package/bin/builders/generate/config/index.js +54 -0
- package/bin/builders/generate/config/templates/elsie.js +29 -0
- package/bin/builders/generate/container/index.js +65 -0
- package/bin/builders/generate/container/templates/Component.js +18 -0
- package/bin/builders/generate/container/templates/index.js +8 -0
- package/bin/builders/generate/container/templates/stories.js +34 -0
- package/bin/builders/generate/container/templates/unit-test.js +19 -0
- package/bin/builders/generate/index.js +283 -0
- package/bin/builders/gql/createOrClearDirectory.js +33 -0
- package/bin/builders/gql/getSchemaRef.js +25 -0
- package/bin/builders/gql/index.js +71 -0
- package/bin/builders/lint/index.js +5 -0
- package/bin/builders/serve/index.js +44 -0
- package/bin/builders/storybook/index.js +5 -0
- package/bin/builders/test/index.js +5 -0
- package/bin/index.js +26 -0
- package/bin/lib/cli.js +8 -0
- package/bin/lib/config.js +12 -0
- package/bin/lib/log-message.js +11 -0
- package/bin/lib/string.js +26 -0
- package/bin/lib/validate-typeof.js +28 -0
- package/bin/lib/write-file.js +30 -0
- package/bin/lib/write-parent-index.js +45 -0
- package/config/eslint.js +113 -0
- package/config/jest.js +90 -0
- package/config/prettier.js +16 -0
- package/config/setEnvVars.js +14 -0
- package/config/storybook/addon.js +130 -0
- package/config/storybook/components/FileTree/FileTree.jsx +192 -0
- package/config/storybook/components/FileTree/index.js +10 -0
- package/config/storybook/components/Flex/Flex.jsx +21 -0
- package/config/storybook/components/Flex/Flex.module.css +29 -0
- package/config/storybook/components/Flex/index.js +10 -0
- package/config/storybook/components/OptionsTable/OptionsTable.jsx +88 -0
- package/config/storybook/components/OptionsTable/OptionsTable.module.css +104 -0
- package/config/storybook/components/OptionsTable/index.js +10 -0
- package/config/storybook/components/Panel/Panel.module.css +56 -0
- package/config/storybook/components/Panel/Panel.tsx +46 -0
- package/config/storybook/components/Panel/index.ts +10 -0
- package/config/storybook/components/Screenshot/Screenshot.jsx +23 -0
- package/config/storybook/components/Screenshot/Screenshot.module.css +28 -0
- package/config/storybook/components/Screenshot/index.js +10 -0
- package/config/storybook/components/Steps/Steps.jsx +21 -0
- package/config/storybook/components/Steps/Steps.module.css +43 -0
- package/config/storybook/components/Steps/index.js +10 -0
- package/config/storybook/components/StoryWrapper/StoryWrapper.jsx +18 -0
- package/config/storybook/components/StoryWrapper/StoryWrapper.module.css +22 -0
- package/config/storybook/components/StoryWrapper/index.js +10 -0
- package/config/storybook/components/Summary/Summary.jsx +19 -0
- package/config/storybook/components/Summary/Summary.module.css +20 -0
- package/config/storybook/components/Summary/index.js +10 -0
- package/config/storybook/components/Variants/Variants.js +57 -0
- package/config/storybook/components/Variants/docs.css +48 -0
- package/config/storybook/components/Variants/index.js +10 -0
- package/config/storybook/components/video/index.jsx +28 -0
- package/config/storybook/manager.js +23 -0
- package/config/storybook/preview.jsx +88 -0
- package/config/storybook/theming/fonts.css +68 -0
- package/config/storybook/theming/logo.svg +19 -0
- package/config/storybook/theming/manager.css +63 -0
- package/config/storybook/theming/preview.css +93 -0
- package/config/storybook/theming/theme.js +61 -0
- package/config/tsconfig-base.json +16 -0
- package/config/tsconfig-preact.json +15 -0
- package/config/vite.mjs +306 -0
- package/package.json +113 -0
- package/post-release.sh +5 -0
- package/src/components/Accordion/Accordion.css +88 -0
- package/src/components/Accordion/Accordion.stories.tsx +582 -0
- package/src/components/Accordion/Accordion.tsx +177 -0
- package/src/components/Accordion/index.ts +11 -0
- package/src/components/ActionButton/ActionButton.css +100 -0
- package/src/components/ActionButton/ActionButton.stories.tsx +169 -0
- package/src/components/ActionButton/ActionButton.tsx +53 -0
- package/src/components/ActionButton/index.ts +10 -0
- package/src/components/ActionButtonGroup/ActionButtonGroup.css +77 -0
- package/src/components/ActionButtonGroup/ActionButtonGroup.stories.tsx +97 -0
- package/src/components/ActionButtonGroup/ActionButtonGroup.tsx +91 -0
- package/src/components/ActionButtonGroup/index.ts +10 -0
- package/src/components/AlertBanner/AlertBanner.css +144 -0
- package/src/components/AlertBanner/AlertBanner.stories.tsx +165 -0
- package/src/components/AlertBanner/AlertBanner.tsx +90 -0
- package/src/components/AlertBanner/index.ts +11 -0
- package/src/components/Breadcrumbs/Breadcrumbs.css +60 -0
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +195 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +71 -0
- package/src/components/Breadcrumbs/index.ts +11 -0
- package/src/components/Button/Button.css +213 -0
- package/src/components/Button/Button.mdx +133 -0
- package/src/components/Button/Button.stories.tsx +398 -0
- package/src/components/Button/Button.tsx +121 -0
- package/src/components/Button/index.ts +11 -0
- package/src/components/Card/Card.css +34 -0
- package/src/components/Card/Card.stories.tsx +76 -0
- package/src/components/Card/Card.tsx +34 -0
- package/src/components/Card/index.ts +10 -0
- package/src/components/CartItem/CartItem.css +509 -0
- package/src/components/CartItem/CartItem.stories.tsx +628 -0
- package/src/components/CartItem/CartItem.tsx +467 -0
- package/src/components/CartItem/CartItemSkeleton.tsx +38 -0
- package/src/components/CartItem/index.ts +12 -0
- package/src/components/CartList/CartList.css +35 -0
- package/src/components/CartList/CartList.stories.tsx +111 -0
- package/src/components/CartList/CartList.tsx +40 -0
- package/src/components/CartList/index.ts +11 -0
- package/src/components/Checkbox/Checkbox.css +255 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +290 -0
- package/src/components/Checkbox/Checkbox.tsx +138 -0
- package/src/components/Checkbox/index.ts +10 -0
- package/src/components/ColorSwatch/ColorSwatch.css +132 -0
- package/src/components/ColorSwatch/ColorSwatch.stories.tsx +274 -0
- package/src/components/ColorSwatch/ColorSwatch.tsx +127 -0
- package/src/components/ColorSwatch/index.ts +11 -0
- package/src/components/ContentGrid/ContentGrid.css +54 -0
- package/src/components/ContentGrid/ContentGrid.stories.tsx +137 -0
- package/src/components/ContentGrid/ContentGrid.tsx +57 -0
- package/src/components/ContentGrid/index.ts +11 -0
- package/src/components/Divider/Divider.css +22 -0
- package/src/components/Divider/Divider.stories.tsx +62 -0
- package/src/components/Divider/Divider.tsx +33 -0
- package/src/components/Divider/index.ts +11 -0
- package/src/components/Field/Field.css +83 -0
- package/src/components/Field/Field.stories.tsx +238 -0
- package/src/components/Field/Field.tsx +84 -0
- package/src/components/Field/index.ts +10 -0
- package/src/components/Header/Header.css +56 -0
- package/src/components/Header/Header.stories.tsx +180 -0
- package/src/components/Header/Header.tsx +81 -0
- package/src/components/Header/index.ts +11 -0
- package/src/components/Icon/Icon.css +26 -0
- package/src/components/Icon/Icon.stories.helpers.jsx +21 -0
- package/src/components/Icon/Icon.stories.tsx +98 -0
- package/src/components/Icon/Icon.tsx +112 -0
- package/src/components/Icon/index.ts +10 -0
- package/src/components/IllustratedMessage/IllustratedMessage.css +61 -0
- package/src/components/IllustratedMessage/IllustratedMessage.stories.tsx +126 -0
- package/src/components/IllustratedMessage/IllustratedMessage.tsx +78 -0
- package/src/components/IllustratedMessage/index.ts +11 -0
- package/src/components/Image/Image.css +52 -0
- package/src/components/Image/Image.stories.tsx +89 -0
- package/src/components/Image/Image.tsx +66 -0
- package/src/components/Image/index.ts +10 -0
- package/src/components/ImageSwatch/ImageSwatch.css +154 -0
- package/src/components/ImageSwatch/ImageSwatch.stories.tsx +310 -0
- package/src/components/ImageSwatch/ImageSwatch.tsx +123 -0
- package/src/components/ImageSwatch/index.ts +11 -0
- package/src/components/InLineAlert/InLineAlert.css +116 -0
- package/src/components/InLineAlert/InLineAlert.stories.tsx +326 -0
- package/src/components/InLineAlert/InLineAlert.tsx +128 -0
- package/src/components/InLineAlert/index.ts +11 -0
- package/src/components/Incrementer/Incrementer.css +165 -0
- package/src/components/Incrementer/Incrementer.stories.tsx +172 -0
- package/src/components/Incrementer/Incrementer.tsx +192 -0
- package/src/components/Incrementer/index.ts +10 -0
- package/src/components/Input/Input.css +304 -0
- package/src/components/Input/Input.stories.tsx +155 -0
- package/src/components/Input/Input.tsx +166 -0
- package/src/components/Input/index.ts +11 -0
- package/src/components/InputDate/InputDate.css +56 -0
- package/src/components/InputDate/InputDate.stories.tsx +117 -0
- package/src/components/InputDate/InputDate.tsx +120 -0
- package/src/components/InputDate/index.ts +11 -0
- package/src/components/InputPassword/InputPassword.css +31 -0
- package/src/components/InputPassword/InputPassword.stories.tsx +148 -0
- package/src/components/InputPassword/InputPassword.tsx +135 -0
- package/src/components/InputPassword/PasswordStatusIndicator/PasswordStatusIndicator.css +31 -0
- package/src/components/InputPassword/PasswordStatusIndicator/PasswordStatusIndicator.tsx +96 -0
- package/src/components/InputPassword/PasswordStatusIndicator/index.ts +11 -0
- package/src/components/InputPassword/index.ts +11 -0
- package/src/components/Modal/Modal.css +125 -0
- package/src/components/Modal/Modal.stories.tsx +250 -0
- package/src/components/Modal/Modal.tsx +157 -0
- package/src/components/Modal/index.ts +10 -0
- package/src/components/Pagination/Pagination.css +95 -0
- package/src/components/Pagination/Pagination.stories.tsx +117 -0
- package/src/components/Pagination/Pagination.tsx +149 -0
- package/src/components/Pagination/index.ts +11 -0
- package/src/components/Picker/Picker.css +220 -0
- package/src/components/Picker/Picker.stories.tsx +318 -0
- package/src/components/Picker/Picker.tsx +203 -0
- package/src/components/Picker/index.ts +10 -0
- package/src/components/Price/Price.css +57 -0
- package/src/components/Price/Price.stories.tsx +110 -0
- package/src/components/Price/Price.tsx +75 -0
- package/src/components/Price/index.ts +10 -0
- package/src/components/PriceRange/PriceRange.css +66 -0
- package/src/components/PriceRange/PriceRange.stories.tsx +240 -0
- package/src/components/PriceRange/PriceRange.tsx +248 -0
- package/src/components/PriceRange/index.ts +11 -0
- package/src/components/ProgressSpinner/ProgressSpinner.css +91 -0
- package/src/components/ProgressSpinner/ProgressSpinner.stories.tsx +300 -0
- package/src/components/ProgressSpinner/ProgressSpinner.tsx +86 -0
- package/src/components/ProgressSpinner/index.ts +11 -0
- package/src/components/RadioButton/RadioButton.css +134 -0
- package/src/components/RadioButton/RadioButton.stories.tsx +126 -0
- package/src/components/RadioButton/RadioButton.tsx +86 -0
- package/src/components/RadioButton/index.ts +11 -0
- package/src/components/Skeleton/Skeleton.css +145 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +265 -0
- package/src/components/Skeleton/Skeleton.tsx +133 -0
- package/src/components/Skeleton/index.ts +10 -0
- package/src/components/Tag/Tag.css +26 -0
- package/src/components/Tag/Tag.stories.tsx +103 -0
- package/src/components/Tag/Tag.tsx +38 -0
- package/src/components/Tag/index.ts +11 -0
- package/src/components/TextArea/TextArea.css +140 -0
- package/src/components/TextArea/TextArea.stories.tsx +130 -0
- package/src/components/TextArea/TextArea.tsx +89 -0
- package/src/components/TextArea/index.ts +11 -0
- package/src/components/TextSwatch/TextSwatch.css +152 -0
- package/src/components/TextSwatch/TextSwatch.stories.tsx +277 -0
- package/src/components/TextSwatch/TextSwatch.tsx +131 -0
- package/src/components/TextSwatch/index.ts +11 -0
- package/src/components/ToggleButton/ToggleButton.css +95 -0
- package/src/components/ToggleButton/ToggleButton.stories.tsx +190 -0
- package/src/components/ToggleButton/ToggleButton.tsx +75 -0
- package/src/components/ToggleButton/index.ts +11 -0
- package/src/components/UIProvider/UIProvider.css +140 -0
- package/src/components/UIProvider/UIProvider.tsx +61 -0
- package/src/components/UIProvider/debugger.css +47 -0
- package/src/components/UIProvider/index.ts +10 -0
- package/src/components/UIProvider/normalize.css +26 -0
- package/src/components/index.ts +49 -0
- package/src/docs/API/event-bus.mdx +52 -0
- package/src/docs/API/graphql.mdx +214 -0
- package/src/docs/API/initializer.mdx +119 -0
- package/src/docs/API/render.mdx +125 -0
- package/src/docs/Design/colors.mdx +202 -0
- package/src/docs/Design/designBlocks.jsx +87 -0
- package/src/docs/Design/getTokenData.ts +28 -0
- package/src/docs/Design/grid.mdx +365 -0
- package/src/docs/Design/overview.mdx +69 -0
- package/src/docs/Design/shapes.mdx +100 -0
- package/src/docs/Design/spacing.mdx +22 -0
- package/src/docs/Design/typography.mdx +126 -0
- package/src/docs/Utilities/classList.mdx +52 -0
- package/src/docs/Utilities/debounce.mdx +49 -0
- package/src/docs/Utilities/deepmerge.mdx +12 -0
- package/src/docs/Utilities/getFormErrors.mdx +41 -0
- package/src/docs/Utilities/getFormValues.mdx +38 -0
- package/src/docs/assets/Banner.png +0 -0
- package/src/docs/assets/Colors.png +0 -0
- package/src/docs/assets/DropinBanner.png +0 -0
- package/src/docs/assets/ShapeStyles.png +0 -0
- package/src/docs/assets/Spacing.png +0 -0
- package/src/docs/assets/Typography.png +0 -0
- package/src/docs/cli-usage.mdx +181 -0
- package/src/docs/components/overview.mdx +124 -0
- package/src/docs/quick-start.mdx +245 -0
- package/src/docs/slots.mdx +211 -0
- package/src/docs/welcome.mdx +52 -0
- package/src/i18n/en_US.json +146 -0
- package/src/i18n/index.ts +26 -0
- package/src/icons/Add.svg +9 -0
- package/src/icons/AddressBook.svg +3 -0
- package/src/icons/Bulk.svg +24 -0
- package/src/icons/Burger.svg +5 -0
- package/src/icons/Card.svg +7 -0
- package/src/icons/Cart.svg +11 -0
- package/src/icons/Check.svg +8 -0
- package/src/icons/CheckWithCircle.svg +4 -0
- package/src/icons/ChevronDown.svg +3 -0
- package/src/icons/ChevronRight.svg +8 -0
- package/src/icons/ChevronUp.svg +3 -0
- package/src/icons/Close.svg +4 -0
- package/src/icons/Coupon.svg +3 -0
- package/src/icons/Date.svg +4 -0
- package/src/icons/Delivery.svg +11 -0
- package/src/icons/EmptyBox.svg +3 -0
- package/src/icons/Eye.svg +3 -0
- package/src/icons/EyeClose.svg +3 -0
- package/src/icons/Gift.svg +3 -0
- package/src/icons/GiftCard.svg +3 -0
- package/src/icons/Heart.svg +3 -0
- package/src/icons/HeartFilled.svg +3 -0
- package/src/icons/InfoFilled.svg +3 -0
- package/src/icons/Locker.svg +11 -0
- package/src/icons/Minus.svg +3 -0
- package/src/icons/Order.svg +6 -0
- package/src/icons/OrderError.svg +15 -0
- package/src/icons/OrderSuccess.svg +15 -0
- package/src/icons/PaymentError.svg +16 -0
- package/src/icons/Placeholder.svg +3 -0
- package/src/icons/PlaceholderFilled.svg +4 -0
- package/src/icons/Search.svg +9 -0
- package/src/icons/SearchFilled.svg +10 -0
- package/src/icons/Sort.svg +12 -0
- package/src/icons/Star.svg +8 -0
- package/src/icons/Trash.svg +7 -0
- package/src/icons/User.svg +5 -0
- package/src/icons/View.svg +14 -0
- package/src/icons/Wallet.svg +6 -0
- package/src/icons/Warning.svg +12 -0
- package/src/icons/WarningFilled.svg +3 -0
- package/src/icons/WarningWithCircle.svg +4 -0
- package/src/icons/index.ts +42 -0
- package/src/lib/classes.ts +34 -0
- package/src/lib/config.ts +24 -0
- package/src/lib/debounce.ts +16 -0
- package/src/lib/deepmerge.ts +45 -0
- package/src/lib/deviceUtils.ts +16 -0
- package/src/lib/form-values.ts +31 -0
- package/src/lib/i18n.ts +18 -0
- package/src/lib/image-params-keymap.ts +36 -0
- package/src/lib/index.ts +24 -0
- package/src/lib/initializer.ts +134 -0
- package/src/lib/is-number.ts +12 -0
- package/src/lib/render.tsx +138 -0
- package/src/lib/resolve-image.ts +101 -0
- package/src/lib/signals.ts +11 -0
- package/src/lib/slot.tsx +434 -0
- package/src/lib/tests.tsx +47 -0
- package/src/lib/types.ts +16 -0
- package/src/lib/vcomponent.tsx +42 -0
- package/static/assets/images/Card.png +0 -0
- package/static/assets/images/example.jpg +0 -0
- package/static/assets/images/index.ts +11 -0
- package/static/dropin.png +0 -0
- package/static/favicon.svg +14 -0
- package/storybook-stories.js +21 -0
- package/tests/__mocks__/browserMocks.ts +28 -0
- package/tests/__mocks__/fileMocks.ts +12 -0
- package/tests/__mocks__/styleMock.ts +0 -0
- package/types/icons.d.ts +18 -0
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* Copyright 2024 Adobe
|
|
3
|
+
* All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* NOTICE: Adobe permits you to use, modify, and distribute this
|
|
6
|
+
* file in accordance with the terms of the Adobe license agreement
|
|
7
|
+
* accompanying it.
|
|
8
|
+
*******************************************************************/
|
|
9
|
+
|
|
10
|
+
// https://storybook.js.org/docs/7.0/preact/writing-stories/introduction
|
|
11
|
+
import type { Meta, StoryObj } from '@storybook/preact';
|
|
12
|
+
import {
|
|
13
|
+
Accordion,
|
|
14
|
+
AccordionProps,
|
|
15
|
+
AccordionSection,
|
|
16
|
+
AccordionSectionProps,
|
|
17
|
+
} from '@adobe-commerce/elsie/components/Accordion';
|
|
18
|
+
import { Price, Card, Image, CartItem } from '..';
|
|
19
|
+
import { expect, within, userEvent } from '@storybook/test';
|
|
20
|
+
import * as Icons from '@adobe-commerce/elsie/icons';
|
|
21
|
+
|
|
22
|
+
const meta: Meta<AccordionProps & AccordionSectionProps> = {
|
|
23
|
+
title: 'Components/Accordion',
|
|
24
|
+
component: Accordion,
|
|
25
|
+
tags: ['autodocs'],
|
|
26
|
+
parameters: {
|
|
27
|
+
layout: 'centered', // centered | fullscreen
|
|
28
|
+
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
actionIconPosition: {
|
|
31
|
+
description: 'Position of the action icon',
|
|
32
|
+
options: ['left', 'right'],
|
|
33
|
+
control: {
|
|
34
|
+
type: 'select',
|
|
35
|
+
},
|
|
36
|
+
defaultValue: 'left',
|
|
37
|
+
},
|
|
38
|
+
iconOpen: {
|
|
39
|
+
description: 'Icon for open button (svg)',
|
|
40
|
+
options: Object.keys(Icons),
|
|
41
|
+
mapping: Icons,
|
|
42
|
+
control: {
|
|
43
|
+
type: 'select',
|
|
44
|
+
},
|
|
45
|
+
defaultValue: 'Minus',
|
|
46
|
+
},
|
|
47
|
+
iconClose: {
|
|
48
|
+
description: 'Icon for close button (svg)',
|
|
49
|
+
options: Object.keys(Icons),
|
|
50
|
+
mapping: Icons,
|
|
51
|
+
control: {
|
|
52
|
+
type: 'select',
|
|
53
|
+
},
|
|
54
|
+
defaultValue: 'Minus',
|
|
55
|
+
},
|
|
56
|
+
iconLeft: {
|
|
57
|
+
description: 'Optional icon on left side (svg)',
|
|
58
|
+
options: Object.keys(Icons),
|
|
59
|
+
mapping: Icons,
|
|
60
|
+
control: {
|
|
61
|
+
type: 'select',
|
|
62
|
+
},
|
|
63
|
+
defaultValue: 'Minus',
|
|
64
|
+
},
|
|
65
|
+
showIconLeft: {
|
|
66
|
+
description: 'Whether or not the display the leftIcon',
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
defaultValue: {
|
|
69
|
+
summary: false,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
defaultOpen: {
|
|
73
|
+
description:
|
|
74
|
+
'The defaultOpen prop determines the initial state of the accordion, specifying whether it starts as open or closed. Default is false',
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
defaultValue: {
|
|
77
|
+
summary: false,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
secondaryText: {
|
|
81
|
+
description: 'Add text to the button.',
|
|
82
|
+
type: 'string',
|
|
83
|
+
defaultValue: '',
|
|
84
|
+
control: 'text',
|
|
85
|
+
},
|
|
86
|
+
ariaLabelTitle: {
|
|
87
|
+
description:
|
|
88
|
+
'Aria label for the title. Useful for screen readers when the title is not a string',
|
|
89
|
+
type: 'string',
|
|
90
|
+
defaultValue: '',
|
|
91
|
+
control: 'text',
|
|
92
|
+
},
|
|
93
|
+
renderContentWhenClosed: {
|
|
94
|
+
description: 'Render content when closed',
|
|
95
|
+
type: 'boolean',
|
|
96
|
+
defaultValue: {
|
|
97
|
+
summary: true,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
onStateChange: {
|
|
101
|
+
description: 'Callback function when the state changes',
|
|
102
|
+
action: 'onStateChange',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default meta;
|
|
108
|
+
|
|
109
|
+
type Story = StoryObj<AccordionProps>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { Accordion, AccordionSection } from '@adobe-commerce/elsie/components/Accordion';
|
|
114
|
+
*
|
|
115
|
+
* <Accordion>
|
|
116
|
+
* <AccordionSection title={"Title"}><p>Short product details should be kept to 6 lines maximum.</p></AccordionSection>
|
|
117
|
+
* </Accordion>
|
|
118
|
+
*
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export const SingleSection: Story = {
|
|
122
|
+
args: {
|
|
123
|
+
actionIconPosition: 'right',
|
|
124
|
+
iconOpen: Icons.Add,
|
|
125
|
+
iconClose: Icons.Minus,
|
|
126
|
+
},
|
|
127
|
+
render: ({ actionIconPosition, iconOpen, iconClose }) => (
|
|
128
|
+
<div>
|
|
129
|
+
<h2
|
|
130
|
+
style={{
|
|
131
|
+
font: 'var(--type-body-1-strong-font)',
|
|
132
|
+
color: 'var(--color-neutral-800)',
|
|
133
|
+
letterSpacing: 'var(--type-body-1-strong-letter-spacing)',
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
This is the Accordion Component, this title will be longer in order to
|
|
137
|
+
increase width of the story
|
|
138
|
+
</h2>
|
|
139
|
+
|
|
140
|
+
<Accordion
|
|
141
|
+
actionIconPosition={actionIconPosition}
|
|
142
|
+
iconOpen={iconOpen}
|
|
143
|
+
iconClose={iconClose}
|
|
144
|
+
>
|
|
145
|
+
<AccordionSection title={'Title'}>
|
|
146
|
+
<p>Short product details should be kept to 6 lines maximum.</p>
|
|
147
|
+
</AccordionSection>
|
|
148
|
+
</Accordion>
|
|
149
|
+
</div>
|
|
150
|
+
),
|
|
151
|
+
play: async () => {
|
|
152
|
+
const canvasElement = document.querySelector(
|
|
153
|
+
'#storybook-root'
|
|
154
|
+
) as HTMLElement;
|
|
155
|
+
const canvas = within(canvasElement);
|
|
156
|
+
|
|
157
|
+
const loaderIcon = document.querySelector(
|
|
158
|
+
'div[class*="dropin-accordion"]'
|
|
159
|
+
) as HTMLElement;
|
|
160
|
+
await expect(loaderIcon).toBeVisible();
|
|
161
|
+
const header = document.querySelector(
|
|
162
|
+
'.dropin-accordion-section__heading'
|
|
163
|
+
) as HTMLElement;
|
|
164
|
+
await expect(header).toHaveTextContent('Title');
|
|
165
|
+
|
|
166
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
167
|
+
const content = document.querySelector(
|
|
168
|
+
'.dropin-accordion-section__content-container'
|
|
169
|
+
) as HTMLElement;
|
|
170
|
+
await expect(content).toBeVisible();
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const SingleSectionWithLeftIcon: Story = {
|
|
175
|
+
args: {
|
|
176
|
+
actionIconPosition: 'right',
|
|
177
|
+
iconOpen: Icons.Add,
|
|
178
|
+
iconClose: Icons.Minus,
|
|
179
|
+
iconLeft: Icons.Card,
|
|
180
|
+
showIconLeft: true,
|
|
181
|
+
},
|
|
182
|
+
render: ({
|
|
183
|
+
actionIconPosition,
|
|
184
|
+
iconOpen,
|
|
185
|
+
iconClose,
|
|
186
|
+
iconLeft,
|
|
187
|
+
showIconLeft,
|
|
188
|
+
}) => (
|
|
189
|
+
<div>
|
|
190
|
+
<h2
|
|
191
|
+
style={{
|
|
192
|
+
font: 'var(--type-body-1-strong-font)',
|
|
193
|
+
color: 'var(--color-neutral-800)',
|
|
194
|
+
letterSpacing: 'var(--type-body-1-strong-letter-spacing)',
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
This is the Accordion Component, this title will be longer in order to
|
|
198
|
+
increase width of the story
|
|
199
|
+
</h2>
|
|
200
|
+
|
|
201
|
+
<Accordion
|
|
202
|
+
actionIconPosition={actionIconPosition}
|
|
203
|
+
iconOpen={iconOpen}
|
|
204
|
+
iconClose={iconClose}
|
|
205
|
+
>
|
|
206
|
+
<AccordionSection
|
|
207
|
+
title={'Title'}
|
|
208
|
+
secondaryText={'Optional Text'}
|
|
209
|
+
iconLeft={iconLeft}
|
|
210
|
+
showIconLeft={showIconLeft}
|
|
211
|
+
>
|
|
212
|
+
<p>Short product details should be kept to 6 lines maximum.</p>
|
|
213
|
+
</AccordionSection>
|
|
214
|
+
</Accordion>
|
|
215
|
+
</div>
|
|
216
|
+
),
|
|
217
|
+
play: async () => {
|
|
218
|
+
const loaderIcon = document.querySelector(
|
|
219
|
+
'div[class*="dropin-accordion"]'
|
|
220
|
+
) as HTMLElement;
|
|
221
|
+
await expect(loaderIcon).toBeVisible();
|
|
222
|
+
const leftHeader = document.querySelector(
|
|
223
|
+
'.dropin-accordion-section__title-container'
|
|
224
|
+
) as HTMLElement;
|
|
225
|
+
await expect(leftHeader).toBeVisible();
|
|
226
|
+
await expect(leftHeader).toContainHTML('<svg');
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const SingleSectionWithOptionalText: Story = {
|
|
231
|
+
args: {
|
|
232
|
+
actionIconPosition: 'right',
|
|
233
|
+
iconOpen: Icons.Add,
|
|
234
|
+
iconClose: Icons.Minus,
|
|
235
|
+
iconLeft: Icons.Card,
|
|
236
|
+
secondaryText: 'Optional Text',
|
|
237
|
+
},
|
|
238
|
+
render: ({
|
|
239
|
+
actionIconPosition,
|
|
240
|
+
iconOpen,
|
|
241
|
+
iconClose,
|
|
242
|
+
iconLeft,
|
|
243
|
+
secondaryText,
|
|
244
|
+
}) => (
|
|
245
|
+
<div>
|
|
246
|
+
<h2
|
|
247
|
+
style={{
|
|
248
|
+
font: 'var(--type-body-1-strong-font)',
|
|
249
|
+
color: 'var(--color-neutral-800)',
|
|
250
|
+
letterSpacing: 'var(--type-body-1-strong-letter-spacing)',
|
|
251
|
+
}}
|
|
252
|
+
>
|
|
253
|
+
This is the Accordion Component, this title will be longer in order to
|
|
254
|
+
increase width of the story
|
|
255
|
+
</h2>
|
|
256
|
+
|
|
257
|
+
<Accordion
|
|
258
|
+
actionIconPosition={actionIconPosition}
|
|
259
|
+
iconOpen={iconOpen}
|
|
260
|
+
iconClose={iconClose}
|
|
261
|
+
>
|
|
262
|
+
<AccordionSection
|
|
263
|
+
title={'Title'}
|
|
264
|
+
secondaryText={secondaryText}
|
|
265
|
+
iconLeft={iconLeft}
|
|
266
|
+
>
|
|
267
|
+
<p>Short product details should be kept to 6 lines maximum.</p>
|
|
268
|
+
</AccordionSection>
|
|
269
|
+
</Accordion>
|
|
270
|
+
</div>
|
|
271
|
+
),
|
|
272
|
+
play: async () => {
|
|
273
|
+
const loaderIcon = document.querySelector(
|
|
274
|
+
'div[class*="dropin-accordion"]'
|
|
275
|
+
) as HTMLElement;
|
|
276
|
+
await expect(loaderIcon).toBeVisible();
|
|
277
|
+
const secondaryText = document.querySelector(
|
|
278
|
+
'.dropin-accordion-section__secondary-text'
|
|
279
|
+
) as HTMLElement;
|
|
280
|
+
await expect(secondaryText).toBeVisible();
|
|
281
|
+
await expect(secondaryText).toHaveTextContent('Optional Text');
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export const SingleSectionWithPrice: Story = {
|
|
286
|
+
args: {
|
|
287
|
+
actionIconPosition: 'right',
|
|
288
|
+
iconOpen: Icons.Add,
|
|
289
|
+
iconClose: Icons.Minus,
|
|
290
|
+
iconLeft: Icons.Card,
|
|
291
|
+
},
|
|
292
|
+
render: ({ actionIconPosition, iconOpen, iconClose, iconLeft }) => (
|
|
293
|
+
<div>
|
|
294
|
+
<h2
|
|
295
|
+
style={{
|
|
296
|
+
font: 'var(--type-body-1-strong-font)',
|
|
297
|
+
color: 'var(--color-neutral-800)',
|
|
298
|
+
letterSpacing: 'var(--type-body-1-strong-letter-spacing)',
|
|
299
|
+
}}
|
|
300
|
+
>
|
|
301
|
+
This is the Accordion Component, this title will be longer in order to
|
|
302
|
+
increase width of the story
|
|
303
|
+
</h2>
|
|
304
|
+
|
|
305
|
+
<Accordion
|
|
306
|
+
actionIconPosition={actionIconPosition}
|
|
307
|
+
iconOpen={iconOpen}
|
|
308
|
+
iconClose={iconClose}
|
|
309
|
+
>
|
|
310
|
+
<AccordionSection
|
|
311
|
+
title={'Title'}
|
|
312
|
+
iconLeft={iconLeft}
|
|
313
|
+
secondaryText={<Price amount={9.99} />}
|
|
314
|
+
>
|
|
315
|
+
<p>Short product details should be kept to 6 lines maximum.</p>
|
|
316
|
+
</AccordionSection>
|
|
317
|
+
</Accordion>
|
|
318
|
+
</div>
|
|
319
|
+
),
|
|
320
|
+
play: async () => {
|
|
321
|
+
const loaderIcon = document.querySelector(
|
|
322
|
+
'div[class*="dropin-accordion"]'
|
|
323
|
+
) as HTMLElement;
|
|
324
|
+
await expect(loaderIcon).toBeVisible();
|
|
325
|
+
const secondaryText = document.querySelector(
|
|
326
|
+
'.dropin-accordion-section__secondary-text'
|
|
327
|
+
) as HTMLElement;
|
|
328
|
+
await expect(secondaryText).toBeVisible();
|
|
329
|
+
await expect(secondaryText).toHaveTextContent('$9.99');
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export const SingleSectionWithLinkAndCartItem: Story = {
|
|
334
|
+
args: {
|
|
335
|
+
actionIconPosition: 'left',
|
|
336
|
+
iconOpen: Icons.ChevronDown,
|
|
337
|
+
iconClose: Icons.ChevronUp,
|
|
338
|
+
},
|
|
339
|
+
render: ({ actionIconPosition, iconOpen, iconClose }) => (
|
|
340
|
+
<div>
|
|
341
|
+
<h2
|
|
342
|
+
style={{
|
|
343
|
+
font: 'var(--type-body-1-strong-font)',
|
|
344
|
+
color: 'var(--color-neutral-800)',
|
|
345
|
+
letterSpacing: 'var(--type-body-1-strong-letter-spacing)',
|
|
346
|
+
}}
|
|
347
|
+
>
|
|
348
|
+
This is the Accordion Component, this title will be longer in order to
|
|
349
|
+
increase width of the story
|
|
350
|
+
</h2>
|
|
351
|
+
|
|
352
|
+
<Accordion
|
|
353
|
+
actionIconPosition={actionIconPosition}
|
|
354
|
+
iconOpen={iconOpen}
|
|
355
|
+
iconClose={iconClose}
|
|
356
|
+
>
|
|
357
|
+
<AccordionSection
|
|
358
|
+
title={'Title'}
|
|
359
|
+
secondaryText={
|
|
360
|
+
<a rel="noreferrer" href="/cart">
|
|
361
|
+
Edit
|
|
362
|
+
</a>
|
|
363
|
+
}
|
|
364
|
+
>
|
|
365
|
+
<CartItem
|
|
366
|
+
key={'uuid'}
|
|
367
|
+
title={<div>Short Name</div>}
|
|
368
|
+
description={
|
|
369
|
+
<div>
|
|
370
|
+
Secondary product information such as brand name, description,
|
|
371
|
+
etc.
|
|
372
|
+
</div>
|
|
373
|
+
}
|
|
374
|
+
sku={<div>SKU: 59YK7</div>}
|
|
375
|
+
quantity={1}
|
|
376
|
+
image={
|
|
377
|
+
<Image
|
|
378
|
+
src="https://picsum.photos/132/184"
|
|
379
|
+
width="132"
|
|
380
|
+
height="184"
|
|
381
|
+
alt="Some alternative text"
|
|
382
|
+
loading="lazy"
|
|
383
|
+
/>
|
|
384
|
+
}
|
|
385
|
+
price={
|
|
386
|
+
<Price
|
|
387
|
+
amount={53.99}
|
|
388
|
+
style={{ fontWeight: 'inherit', color: 'inherit' }}
|
|
389
|
+
/>
|
|
390
|
+
}
|
|
391
|
+
total={
|
|
392
|
+
<>
|
|
393
|
+
<Price amount={59.98} variant="strikethrough" />
|
|
394
|
+
<Price amount={55.95} sale />
|
|
395
|
+
</>
|
|
396
|
+
}
|
|
397
|
+
/>
|
|
398
|
+
</AccordionSection>
|
|
399
|
+
</Accordion>
|
|
400
|
+
</div>
|
|
401
|
+
),
|
|
402
|
+
play: async () => {
|
|
403
|
+
const accordionElement = document.querySelector(
|
|
404
|
+
'.dropin-accordion'
|
|
405
|
+
) as HTMLElement;
|
|
406
|
+
const link = accordionElement.querySelector('.dropin-accordion a');
|
|
407
|
+
|
|
408
|
+
await expect(accordionElement).toBeVisible();
|
|
409
|
+
await expect(link).toHaveTextContent('Edit');
|
|
410
|
+
await expect(link).toHaveAttribute('href', '/cart');
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
export const MultipleSection: Story = {
|
|
415
|
+
args: {
|
|
416
|
+
actionIconPosition: 'right',
|
|
417
|
+
iconOpen: Icons.ChevronDown,
|
|
418
|
+
iconClose: Icons.ChevronUp,
|
|
419
|
+
iconLeft: Icons.Card,
|
|
420
|
+
showIconLeft: false,
|
|
421
|
+
},
|
|
422
|
+
argTypes: {
|
|
423
|
+
showIconLeft: {
|
|
424
|
+
table: {
|
|
425
|
+
disable: true,
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
iconLeft: {
|
|
429
|
+
table: {
|
|
430
|
+
disable: true,
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
render: ({ actionIconPosition, iconOpen, iconClose }) => (
|
|
435
|
+
<div>
|
|
436
|
+
<h2
|
|
437
|
+
style={{
|
|
438
|
+
font: 'var(--type-body-1-strong-font)',
|
|
439
|
+
color: 'var(--color-neutral-800)',
|
|
440
|
+
letterSpacing: 'var(--type-body-1-strong-letter-spacing)',
|
|
441
|
+
}}
|
|
442
|
+
>
|
|
443
|
+
This is the Accordion Component, this title will be longer in order to
|
|
444
|
+
increase width of the story
|
|
445
|
+
</h2>
|
|
446
|
+
|
|
447
|
+
<Accordion
|
|
448
|
+
actionIconPosition={actionIconPosition}
|
|
449
|
+
iconOpen={iconOpen}
|
|
450
|
+
iconClose={iconClose}
|
|
451
|
+
>
|
|
452
|
+
<AccordionSection
|
|
453
|
+
title={'Cart summary'}
|
|
454
|
+
iconLeft={Icons.Cart}
|
|
455
|
+
showIconLeft={true}
|
|
456
|
+
renderContentWhenClosed={false}
|
|
457
|
+
>
|
|
458
|
+
<Card>
|
|
459
|
+
<h2 style={{ font: 'var(--type-headline-2-strong-font)' }}>
|
|
460
|
+
Title
|
|
461
|
+
</h2>
|
|
462
|
+
<p style={{ font: 'var(--type-body-2-default-font)' }}>
|
|
463
|
+
This is a short description of the item and should be kept to two
|
|
464
|
+
or three lines as maximum.
|
|
465
|
+
</p>
|
|
466
|
+
</Card>
|
|
467
|
+
</AccordionSection>
|
|
468
|
+
<AccordionSection
|
|
469
|
+
title={'Card info'}
|
|
470
|
+
iconLeft={Icons.Card}
|
|
471
|
+
showIconLeft={true}
|
|
472
|
+
secondaryText={'Optional Text'}
|
|
473
|
+
renderContentWhenClosed={false}
|
|
474
|
+
>
|
|
475
|
+
<p>
|
|
476
|
+
Short product details should be kept to 6 lines maximum.
|
|
477
|
+
<br />
|
|
478
|
+
Short product details should be kept to 6 lines maximum.
|
|
479
|
+
<br />
|
|
480
|
+
Short product details should be kept to 6 lines maximum.
|
|
481
|
+
<br />
|
|
482
|
+
Short product details should be kept to 6 lines maximum.
|
|
483
|
+
<br />
|
|
484
|
+
Short product details should be kept to 6 lines maximum.
|
|
485
|
+
<br />
|
|
486
|
+
</p>
|
|
487
|
+
</AccordionSection>
|
|
488
|
+
<AccordionSection
|
|
489
|
+
title={'Wallet'}
|
|
490
|
+
iconLeft={Icons.Wallet}
|
|
491
|
+
showIconLeft={true}
|
|
492
|
+
>
|
|
493
|
+
<p>Short product details should be kept to 6 lines maximum.</p>
|
|
494
|
+
</AccordionSection>
|
|
495
|
+
<AccordionSection
|
|
496
|
+
title={'Shipping'}
|
|
497
|
+
iconLeft={Icons.Delivery}
|
|
498
|
+
showIconLeft={true}
|
|
499
|
+
>
|
|
500
|
+
<p>Short product details should be kept to 6 lines maximum.</p>
|
|
501
|
+
</AccordionSection>
|
|
502
|
+
<AccordionSection
|
|
503
|
+
title={'Notes'}
|
|
504
|
+
iconLeft={Icons.Delivery}
|
|
505
|
+
showIconLeft={false}
|
|
506
|
+
>
|
|
507
|
+
<p>Short product details should be kept to 6 lines maximum.</p>
|
|
508
|
+
</AccordionSection>
|
|
509
|
+
</Accordion>
|
|
510
|
+
</div>
|
|
511
|
+
),
|
|
512
|
+
play: async () => {
|
|
513
|
+
const loaderIcon = document.querySelector(
|
|
514
|
+
'div[class*="dropin-accordion"]'
|
|
515
|
+
) as HTMLElement;
|
|
516
|
+
await expect(loaderIcon).toBeVisible();
|
|
517
|
+
const section = document.querySelector(
|
|
518
|
+
'.dropin-accordion-section'
|
|
519
|
+
) as HTMLElement;
|
|
520
|
+
await expect(section).toBeVisible();
|
|
521
|
+
const divider = document.querySelector('.dropin-divider') as HTMLElement;
|
|
522
|
+
await expect(divider).toBeVisible();
|
|
523
|
+
},
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
export const SingleSection_ToggleBehavior: Story = {
|
|
527
|
+
args: {
|
|
528
|
+
actionIconPosition: 'right',
|
|
529
|
+
iconOpen: Icons.Add,
|
|
530
|
+
iconClose: Icons.Minus,
|
|
531
|
+
iconLeft: Icons.Card,
|
|
532
|
+
defaultOpen: true,
|
|
533
|
+
},
|
|
534
|
+
render: ({
|
|
535
|
+
actionIconPosition,
|
|
536
|
+
iconOpen,
|
|
537
|
+
iconClose,
|
|
538
|
+
iconLeft,
|
|
539
|
+
defaultOpen,
|
|
540
|
+
}) => (
|
|
541
|
+
<div>
|
|
542
|
+
<h2
|
|
543
|
+
style={{
|
|
544
|
+
font: 'var(--type-body-1-strong-font)',
|
|
545
|
+
color: 'var(--color-neutral-800)',
|
|
546
|
+
letterSpacing: 'var(--type-body-1-strong-letter-spacing)',
|
|
547
|
+
}}
|
|
548
|
+
>
|
|
549
|
+
This is the Accordion Component, this title will be longer in order to
|
|
550
|
+
increase width of the story
|
|
551
|
+
</h2>
|
|
552
|
+
|
|
553
|
+
<Accordion
|
|
554
|
+
key={defaultOpen}
|
|
555
|
+
actionIconPosition={actionIconPosition}
|
|
556
|
+
iconOpen={iconOpen}
|
|
557
|
+
iconClose={iconClose}
|
|
558
|
+
>
|
|
559
|
+
<AccordionSection
|
|
560
|
+
title={'Title'}
|
|
561
|
+
iconLeft={iconLeft}
|
|
562
|
+
secondaryText={<Price amount={9.99} />}
|
|
563
|
+
renderContentWhenClosed={false}
|
|
564
|
+
defaultOpen={defaultOpen}
|
|
565
|
+
>
|
|
566
|
+
<p>Short product details should be kept to 6 lines maximum.</p>
|
|
567
|
+
</AccordionSection>
|
|
568
|
+
</Accordion>
|
|
569
|
+
</div>
|
|
570
|
+
),
|
|
571
|
+
play: async () => {
|
|
572
|
+
const loaderIcon = document.querySelector(
|
|
573
|
+
'div[class*="dropin-accordion"]'
|
|
574
|
+
) as HTMLElement;
|
|
575
|
+
await expect(loaderIcon).toBeVisible();
|
|
576
|
+
const secondaryText = document.querySelector(
|
|
577
|
+
'.dropin-accordion-section__secondary-text'
|
|
578
|
+
) as HTMLElement;
|
|
579
|
+
await expect(secondaryText).toBeVisible();
|
|
580
|
+
await expect(secondaryText).toHaveTextContent('$9.99');
|
|
581
|
+
},
|
|
582
|
+
};
|