@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,21 @@
|
|
|
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
|
+
import * as Icons from '@adobe-commerce/elsie/icons';
|
|
11
|
+
import { Icon } from './Icon';
|
|
12
|
+
|
|
13
|
+
const iconNames = Object.keys(Icons);
|
|
14
|
+
|
|
15
|
+
export const IconsList = iconNames.reduce(
|
|
16
|
+
(acc, name) => {
|
|
17
|
+
acc[name] = <Icon key={name} source={Icons[name]} size="24" stroke="1" />;
|
|
18
|
+
return acc;
|
|
19
|
+
},
|
|
20
|
+
{ none: null }
|
|
21
|
+
);
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
import type { Meta, StoryObj } from '@storybook/preact';
|
|
11
|
+
import { Icon, IconProps } from '@adobe-commerce/elsie/components/Icon';
|
|
12
|
+
import { Cart } from '@adobe-commerce/elsie/icons/index';
|
|
13
|
+
import * as Icons from '@adobe-commerce/elsie/icons';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Use Icons as symbols or metaphors to communicate and enhance the user experience.
|
|
17
|
+
*/
|
|
18
|
+
const meta: Meta<IconProps> = {
|
|
19
|
+
title: 'Components/Icon',
|
|
20
|
+
component: Icon,
|
|
21
|
+
argTypes: {
|
|
22
|
+
source: {
|
|
23
|
+
options: Object.keys(Icons),
|
|
24
|
+
mapping: Icons,
|
|
25
|
+
control: {
|
|
26
|
+
type: 'select',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
size: {
|
|
30
|
+
control: 'select',
|
|
31
|
+
options: ['12', '16', '24', '32', '64', '80'],
|
|
32
|
+
},
|
|
33
|
+
stroke: {
|
|
34
|
+
control: 'select',
|
|
35
|
+
options: ['1', '2', '3', '4'],
|
|
36
|
+
},
|
|
37
|
+
title: {
|
|
38
|
+
control: 'text',
|
|
39
|
+
description: 'Title for the icon',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default meta;
|
|
45
|
+
|
|
46
|
+
type Story = StoryObj<IconProps>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { Icon } from '@adobe-commerce/elsie/components/Icon';
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
export const Primary: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
source: Cart,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const Lazy: Story = {
|
|
61
|
+
argTypes: {
|
|
62
|
+
source: {
|
|
63
|
+
mapping: Object.keys(Icons),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
args: {
|
|
67
|
+
source: 'Cart',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const AllIcons: Story = {
|
|
72
|
+
argTypes: {
|
|
73
|
+
style: Object
|
|
74
|
+
},
|
|
75
|
+
args: {
|
|
76
|
+
style: {
|
|
77
|
+
color: 'blue'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
render: (props) => (
|
|
81
|
+
<div
|
|
82
|
+
style={{
|
|
83
|
+
display: 'grid',
|
|
84
|
+
gridTemplateColumns: 'repeat(4, 1fr)',
|
|
85
|
+
gap: '1rem',
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
{Object.keys(Icons).map((icon) => (
|
|
89
|
+
// eslint-disable-next-line
|
|
90
|
+
<>
|
|
91
|
+
<span key={icon}>{icon}</span>
|
|
92
|
+
{/* @ts-ignore */}
|
|
93
|
+
<Icon {...props} source={Icons[icon]} />
|
|
94
|
+
</>
|
|
95
|
+
))}
|
|
96
|
+
</div>
|
|
97
|
+
),
|
|
98
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
import { FunctionComponent } from 'preact';
|
|
11
|
+
import { classes } from '@adobe-commerce/elsie/lib/classes';
|
|
12
|
+
import { lazy, Suspense, SVGProps } from 'preact/compat';
|
|
13
|
+
|
|
14
|
+
import '@adobe-commerce/elsie/components/Icon/Icon.css';
|
|
15
|
+
|
|
16
|
+
export type IconType = keyof typeof import('@adobe-commerce/elsie/icons');
|
|
17
|
+
|
|
18
|
+
const lazyIcons = {
|
|
19
|
+
Add: lazy(() => import('@adobe-commerce/elsie/icons/Add.svg')),
|
|
20
|
+
Bulk: lazy(() => import('@adobe-commerce/elsie/icons/Bulk.svg')),
|
|
21
|
+
Burger: lazy(() => import('@adobe-commerce/elsie/icons/Burger.svg')),
|
|
22
|
+
Cart: lazy(() => import('@adobe-commerce/elsie/icons/Cart.svg')),
|
|
23
|
+
Check: lazy(() => import('@adobe-commerce/elsie/icons/Check.svg')),
|
|
24
|
+
ChevronDown: lazy(() => import('@adobe-commerce/elsie/icons/ChevronDown.svg')),
|
|
25
|
+
ChevronUp: lazy(() => import('@adobe-commerce/elsie/icons/ChevronUp.svg')),
|
|
26
|
+
ChevronRight: lazy(() => import('@adobe-commerce/elsie/icons/ChevronRight.svg')),
|
|
27
|
+
Close: lazy(() => import('@adobe-commerce/elsie/icons/Close.svg')),
|
|
28
|
+
Heart: lazy(() => import('@adobe-commerce/elsie/icons/Heart.svg')),
|
|
29
|
+
Minus: lazy(() => import('@adobe-commerce/elsie/icons/Minus.svg')),
|
|
30
|
+
Placeholder: lazy(() => import('@adobe-commerce/elsie/icons/Placeholder.svg')),
|
|
31
|
+
PlaceholderFilled: lazy(
|
|
32
|
+
() => import('@adobe-commerce/elsie/icons/PlaceholderFilled.svg')
|
|
33
|
+
),
|
|
34
|
+
Search: lazy(() => import('@adobe-commerce/elsie/icons/Search.svg')),
|
|
35
|
+
SearchFilled: lazy(() => import('@adobe-commerce/elsie/icons/SearchFilled.svg')),
|
|
36
|
+
Sort: lazy(() => import('@adobe-commerce/elsie/icons/Sort.svg')),
|
|
37
|
+
Star: lazy(() => import('@adobe-commerce/elsie/icons/Star.svg')),
|
|
38
|
+
View: lazy(() => import('@adobe-commerce/elsie/icons/View.svg')),
|
|
39
|
+
User: lazy(() => import('@adobe-commerce/elsie/icons/User.svg')),
|
|
40
|
+
Warning: lazy(() => import('@adobe-commerce/elsie/icons/Warning.svg')),
|
|
41
|
+
Locker: lazy(() => import('@adobe-commerce/elsie/icons/Locker.svg')),
|
|
42
|
+
Wallet: lazy(() => import('@adobe-commerce/elsie/icons/Wallet.svg')),
|
|
43
|
+
Card: lazy(() => import('@adobe-commerce/elsie/icons/Card.svg')),
|
|
44
|
+
Order: lazy(() => import('@adobe-commerce/elsie/icons/Order.svg')),
|
|
45
|
+
Delivery: lazy(() => import('@adobe-commerce/elsie/icons/Delivery.svg')),
|
|
46
|
+
OrderError: lazy(() => import('@adobe-commerce/elsie/icons/OrderError.svg')),
|
|
47
|
+
OrderSuccess: lazy(() => import('@adobe-commerce/elsie/icons/OrderSuccess.svg')),
|
|
48
|
+
PaymentError: lazy(() => import('@adobe-commerce/elsie/icons/PaymentError.svg')),
|
|
49
|
+
CheckWithCircle: lazy(() => import('@adobe-commerce/elsie/icons/CheckWithCircle.svg')),
|
|
50
|
+
WarningWithCircle: lazy(
|
|
51
|
+
() => import('@adobe-commerce/elsie/icons/WarningWithCircle.svg')
|
|
52
|
+
),
|
|
53
|
+
WarningFilled: lazy(() => import('@adobe-commerce/elsie/icons/WarningFilled.svg')),
|
|
54
|
+
InfoFilled: lazy(() => import('@adobe-commerce/elsie/icons/InfoFilled.svg')),
|
|
55
|
+
HeartFilled: lazy(() => import('@adobe-commerce/elsie/icons/HeartFilled.svg')),
|
|
56
|
+
Trash: lazy(() => import('@adobe-commerce/elsie/icons/Trash.svg')),
|
|
57
|
+
Eye: lazy(() => import('@adobe-commerce/elsie/icons/Eye.svg')),
|
|
58
|
+
EyeClose: lazy(() => import('@adobe-commerce/elsie/icons/EyeClose.svg')),
|
|
59
|
+
Date: lazy(() => import('@adobe-commerce/elsie/icons/Date.svg')),
|
|
60
|
+
AddressBook: lazy(() => import('@adobe-commerce/elsie/icons/AddressBook.svg')),
|
|
61
|
+
EmptyBox: lazy(() => import('@adobe-commerce/elsie/icons/EmptyBox.svg')),
|
|
62
|
+
Coupon: lazy(() => import('@adobe-commerce/elsie/icons/Coupon.svg')),
|
|
63
|
+
Gift: lazy(() => import('@adobe-commerce/elsie/icons/Gift.svg')),
|
|
64
|
+
GiftCard: lazy(() => import('@adobe-commerce/elsie/icons/GiftCard.svg')),
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'size'> {
|
|
68
|
+
source:
|
|
69
|
+
| FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>
|
|
70
|
+
| IconType;
|
|
71
|
+
size?: '12' | '16' | '24' | '32' | '64' | '80';
|
|
72
|
+
stroke?: '1' | '2' | '3' | '4';
|
|
73
|
+
className?: string;
|
|
74
|
+
title?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type IconNode = FunctionComponent<
|
|
78
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
79
|
+
>;
|
|
80
|
+
|
|
81
|
+
export function Icon({
|
|
82
|
+
source: Source,
|
|
83
|
+
size = '24',
|
|
84
|
+
stroke = '2',
|
|
85
|
+
viewBox = '0 0 24 24',
|
|
86
|
+
className,
|
|
87
|
+
...props
|
|
88
|
+
}: IconProps) {
|
|
89
|
+
const LazyIcon = typeof Source === 'string' ? lazyIcons[Source] : null;
|
|
90
|
+
|
|
91
|
+
const defaultProps = {
|
|
92
|
+
className: classes([
|
|
93
|
+
'dropin-icon',
|
|
94
|
+
`dropin-icon--shape-stroke-${stroke}`,
|
|
95
|
+
className,
|
|
96
|
+
]),
|
|
97
|
+
width: size,
|
|
98
|
+
height: size,
|
|
99
|
+
viewBox,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<Suspense fallback={<svg {...props} {...defaultProps} />}>
|
|
104
|
+
{LazyIcon ? (
|
|
105
|
+
<LazyIcon {...props} {...defaultProps} />
|
|
106
|
+
) : (
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
<Source {...props} {...defaultProps} />
|
|
109
|
+
)}
|
|
110
|
+
</Suspense>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export * from '@adobe-commerce/elsie/components/Icon/Icon';
|
|
@@ -0,0 +1,61 @@
|
|
|
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://cssguidelin.es/#bem-like-naming */
|
|
11
|
+
|
|
12
|
+
.dropin-illustrated-message {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
text-align: center;
|
|
18
|
+
height: 100%;
|
|
19
|
+
row-gap: var(--spacing-small);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dropin-illustrated-message .dropin-card {
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.dropin-illustrated-message__icon {
|
|
27
|
+
color: var(--color-neutral-400);
|
|
28
|
+
margin: 0 auto var(--spacing-medium) auto;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.dropin-illustrated-message__heading {
|
|
32
|
+
color: var(--color-neutral-800);
|
|
33
|
+
font: var(--type-headline-2-strong-font);
|
|
34
|
+
letter-spacing: var(--type-headline-2-strong-letter-spacing);
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dropin-illustrated-message__message {
|
|
39
|
+
color: var(--color-neutral-800);
|
|
40
|
+
font: var(--type-body-2-default-font);
|
|
41
|
+
letter-spacing: var(--type-body-2-default-letter-spacing);
|
|
42
|
+
text-align: center;
|
|
43
|
+
margin: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.dropin-illustrated-message .dropin-illustrated-message__action {
|
|
47
|
+
justify-self: center;
|
|
48
|
+
align-self: center;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Medium (portrait tablets and large phones, 768px and up) */
|
|
52
|
+
/* @media only screen and (min-width: 768px) { } */
|
|
53
|
+
|
|
54
|
+
/* Large (landscape tablets, 1024px and up) */
|
|
55
|
+
/* @media only screen and (min-width: 1024px) { } */
|
|
56
|
+
|
|
57
|
+
/* XLarge (laptops/desktops, 1366px and up) */
|
|
58
|
+
/* @media only screen and (min-width: 1366px) { } */
|
|
59
|
+
|
|
60
|
+
/* XXlarge (large laptops and desktops, 1920px and up) */
|
|
61
|
+
/* @media only screen and (min-width: 1920px) { } */
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
IllustratedMessage as component,
|
|
14
|
+
IllustratedMessageProps,
|
|
15
|
+
} from '@adobe-commerce/elsie/components/IllustratedMessage';
|
|
16
|
+
import { Placeholder } from '@adobe-commerce/elsie/icons';
|
|
17
|
+
import { Button, Icon } from '@adobe-commerce/elsie/components';
|
|
18
|
+
import { expect } from '@storybook/test';
|
|
19
|
+
import { IconsList } from '@adobe-commerce/elsie/components/Icon/Icon.stories.helpers';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Use IllustratedMessages to display an illustration and a message, usually for an empty state or an error page.
|
|
23
|
+
*/
|
|
24
|
+
const meta: Meta<IllustratedMessageProps> = {
|
|
25
|
+
title: 'Components/IllustratedMessage',
|
|
26
|
+
component,
|
|
27
|
+
argTypes: {
|
|
28
|
+
icon: {
|
|
29
|
+
description: 'Icon to display in the IllustratedMessage.',
|
|
30
|
+
table: {
|
|
31
|
+
type: { summary: 'FunctionComponent' },
|
|
32
|
+
},
|
|
33
|
+
options: Object.keys(IconsList),
|
|
34
|
+
mapping: IconsList,
|
|
35
|
+
control: { type: 'select', defaultValue: 'Placeholder' },
|
|
36
|
+
},
|
|
37
|
+
heading: {
|
|
38
|
+
description: 'Heading text to display in the IllustratedMessage.',
|
|
39
|
+
control: { type: 'text' },
|
|
40
|
+
type: { name: 'string', required: false },
|
|
41
|
+
},
|
|
42
|
+
headingLevel: {
|
|
43
|
+
description: 'Heading level to display in the IllustratedMessage.',
|
|
44
|
+
control: { type: 'select', default: 2 },
|
|
45
|
+
options: [1, 2, 3, 4, 5, 6],
|
|
46
|
+
type: { name: 'string', required: false },
|
|
47
|
+
},
|
|
48
|
+
message: {
|
|
49
|
+
description: 'Message to display in the IllustratedMessage.',
|
|
50
|
+
options: ['Short', 'Long'],
|
|
51
|
+
mapping: {
|
|
52
|
+
Short: <div>Short message</div>,
|
|
53
|
+
Long: (
|
|
54
|
+
<div>
|
|
55
|
+
Illustrated message with an extremely extremely long message
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
control: {
|
|
60
|
+
type: 'select',
|
|
61
|
+
labels: {
|
|
62
|
+
Short: 'Short message',
|
|
63
|
+
Long: 'Long message',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
table: {
|
|
67
|
+
type: { summary: 'FunctionComponent' },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
action: {
|
|
71
|
+
description: 'Action to display in the IllustratedMessage.',
|
|
72
|
+
control: false,
|
|
73
|
+
table: {
|
|
74
|
+
type: { summary: 'FunctionComponent' },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
variant: {
|
|
78
|
+
description: 'Variant to display in the IllustratedMessage.',
|
|
79
|
+
control: { type: 'radio', default: 'secondary' },
|
|
80
|
+
options: ['primary', 'secondary'],
|
|
81
|
+
type: { name: 'string', required: false },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default meta;
|
|
87
|
+
|
|
88
|
+
type Story = StoryObj<IllustratedMessageProps>;
|
|
89
|
+
|
|
90
|
+
export const IllustratedMessage: Story = {
|
|
91
|
+
args: {
|
|
92
|
+
icon: <Icon source={Placeholder} size="80" />,
|
|
93
|
+
heading: 'Illustrated Message heading',
|
|
94
|
+
headingLevel: 3,
|
|
95
|
+
message: <p>Illustrated Message text content</p>,
|
|
96
|
+
action: <Button>Illustrated Message action</Button>,
|
|
97
|
+
variant: 'secondary',
|
|
98
|
+
},
|
|
99
|
+
play: async () => {
|
|
100
|
+
const illustratedMessage = document.querySelector(
|
|
101
|
+
'div[class*="dropin-illustrated-message"]'
|
|
102
|
+
) as HTMLElement;
|
|
103
|
+
|
|
104
|
+
await expect(illustratedMessage).toBeVisible();
|
|
105
|
+
|
|
106
|
+
const icon = illustratedMessage.querySelector(
|
|
107
|
+
'.dropin-illustrated-message__icon'
|
|
108
|
+
);
|
|
109
|
+
await expect(icon).toBeVisible();
|
|
110
|
+
|
|
111
|
+
const heading = illustratedMessage.querySelector(
|
|
112
|
+
'.dropin-illustrated-message__heading'
|
|
113
|
+
);
|
|
114
|
+
await expect(heading).toBeVisible();
|
|
115
|
+
|
|
116
|
+
const message = illustratedMessage.querySelector(
|
|
117
|
+
'.dropin-illustrated-message__message'
|
|
118
|
+
);
|
|
119
|
+
await expect(message).toBeVisible();
|
|
120
|
+
|
|
121
|
+
const action = illustratedMessage.querySelector(
|
|
122
|
+
'.dropin-illustrated-message__action'
|
|
123
|
+
);
|
|
124
|
+
await expect(action).toBeVisible();
|
|
125
|
+
},
|
|
126
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
import { FunctionComponent, VNode } from 'preact';
|
|
11
|
+
import { HTMLAttributes, JSX } from 'preact/compat';
|
|
12
|
+
import { classes, VComponent } from '@adobe-commerce/elsie/lib';
|
|
13
|
+
import '@adobe-commerce/elsie/components/IllustratedMessage/IllustratedMessage.css';
|
|
14
|
+
import { Card } from '@adobe-commerce/elsie/components';
|
|
15
|
+
|
|
16
|
+
export interface IllustratedMessageProps
|
|
17
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'icon' | 'action'> {
|
|
18
|
+
icon?: VNode<HTMLAttributes<SVGSVGElement>>;
|
|
19
|
+
heading?: string;
|
|
20
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
21
|
+
message?: VNode<HTMLAttributes<HTMLElement>>;
|
|
22
|
+
action?: VNode;
|
|
23
|
+
variant?: 'primary' | 'secondary';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const IllustratedMessage: FunctionComponent<IllustratedMessageProps> = ({
|
|
27
|
+
className,
|
|
28
|
+
icon,
|
|
29
|
+
heading,
|
|
30
|
+
headingLevel = 2,
|
|
31
|
+
message,
|
|
32
|
+
action,
|
|
33
|
+
variant = 'secondary',
|
|
34
|
+
...props
|
|
35
|
+
}) => {
|
|
36
|
+
const Heading =
|
|
37
|
+
headingLevel >= 1 && headingLevel <= 6
|
|
38
|
+
? (`h${headingLevel}` as keyof JSX.IntrinsicElements)
|
|
39
|
+
: 'h2';
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
{...props}
|
|
44
|
+
className={classes(['dropin-illustrated-message', className])}
|
|
45
|
+
>
|
|
46
|
+
<Card variant={variant}>
|
|
47
|
+
{icon && (
|
|
48
|
+
<VComponent
|
|
49
|
+
node={icon}
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
size="80"
|
|
52
|
+
className="dropin-illustrated-message__icon"
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
|
|
56
|
+
{heading && (
|
|
57
|
+
<Heading className="dropin-illustrated-message__heading">
|
|
58
|
+
{heading}
|
|
59
|
+
</Heading>
|
|
60
|
+
)}
|
|
61
|
+
|
|
62
|
+
{message && (
|
|
63
|
+
<VComponent
|
|
64
|
+
node={message}
|
|
65
|
+
className="dropin-illustrated-message__message"
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
{action && (
|
|
70
|
+
<VComponent
|
|
71
|
+
node={action}
|
|
72
|
+
className="dropin-illustrated-message__action"
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
</Card>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export * from '@adobe-commerce/elsie/components/IllustratedMessage/IllustratedMessage';
|
|
11
|
+
export { IllustratedMessage as default } from '@adobe-commerce/elsie/components/IllustratedMessage/IllustratedMessage';
|
|
@@ -0,0 +1,52 @@
|
|
|
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://cssguidelin.es/#bem-like-naming */
|
|
11
|
+
|
|
12
|
+
.dropin-image {
|
|
13
|
+
background: var(--color-neutral-300)
|
|
14
|
+
linear-gradient(
|
|
15
|
+
to right,
|
|
16
|
+
var(--color-neutral-300) 0%,
|
|
17
|
+
var(--color-neutral-100) 20%,
|
|
18
|
+
var(--color-neutral-300) 40%,
|
|
19
|
+
var(--color-neutral-300) 100%
|
|
20
|
+
)
|
|
21
|
+
no-repeat;
|
|
22
|
+
animation: imageShimmer infinite 1.2s linear;
|
|
23
|
+
border-radius: var(--shape-border-radius-2);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Loaded */
|
|
27
|
+
.dropin-image--loaded {
|
|
28
|
+
background: unset;
|
|
29
|
+
border-radius: unset;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@keyframes imageShimmer {
|
|
33
|
+
0% {
|
|
34
|
+
background-position: -600px 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
100% {
|
|
38
|
+
background-position: 600px 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Medium (portrait tablets and large phones, 768px and up) */
|
|
43
|
+
/* @media only screen and (min-width: 768px) { } */
|
|
44
|
+
|
|
45
|
+
/* Large (landscape tablets, 1024px and up) */
|
|
46
|
+
/* @media only screen and (min-width: 1024px) { } */
|
|
47
|
+
|
|
48
|
+
/* XLarge (laptops/desktops, 1366px and up) */
|
|
49
|
+
/* @media only screen and (min-width: 1366px) { } */
|
|
50
|
+
|
|
51
|
+
/* XXlarge (large laptops and desktops, 1920px and up) */
|
|
52
|
+
/* @media only screen and (min-width: 1920px) { } */
|
|
@@ -0,0 +1,89 @@
|
|
|
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 { Image, ImageProps } from '@adobe-commerce/elsie/components/Image';
|
|
13
|
+
import { expect, waitFor } from '@storybook/test';
|
|
14
|
+
|
|
15
|
+
import { Image as ExampleImage } from '@adobe-commerce/elsie/static/assets/images';
|
|
16
|
+
|
|
17
|
+
const defaultWidth = 384;
|
|
18
|
+
const defaultHeight = 288;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Use Images to display visual content like photos and illustrations.
|
|
22
|
+
*/
|
|
23
|
+
const meta: Meta<ImageProps> = {
|
|
24
|
+
title: 'Components/Image',
|
|
25
|
+
component: Image,
|
|
26
|
+
argTypes: {
|
|
27
|
+
width: {
|
|
28
|
+
description: 'Image width',
|
|
29
|
+
type: 'number',
|
|
30
|
+
},
|
|
31
|
+
height: {
|
|
32
|
+
description: 'Image height',
|
|
33
|
+
type: 'number',
|
|
34
|
+
},
|
|
35
|
+
loading: {
|
|
36
|
+
description: 'Loading strategy',
|
|
37
|
+
type: 'string',
|
|
38
|
+
table: {
|
|
39
|
+
defaultValue: {
|
|
40
|
+
summary: 'lazy',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
options: ['lazy', 'eager'],
|
|
44
|
+
},
|
|
45
|
+
params: {
|
|
46
|
+
description: 'Parameters appened to the image URL',
|
|
47
|
+
type: { name: 'other', value: 'object' },
|
|
48
|
+
},
|
|
49
|
+
onLoad: {
|
|
50
|
+
description: 'Callback when image is loaded',
|
|
51
|
+
action: 'loaded',
|
|
52
|
+
},
|
|
53
|
+
src: {
|
|
54
|
+
description: 'Image URL',
|
|
55
|
+
type: 'string',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default meta;
|
|
61
|
+
|
|
62
|
+
type Story = StoryObj<ImageProps>;
|
|
63
|
+
|
|
64
|
+
export const Primary: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
src: ExampleImage,
|
|
67
|
+
alt: 'Some alternative text',
|
|
68
|
+
loading: 'eager',
|
|
69
|
+
width: defaultWidth,
|
|
70
|
+
height: defaultHeight,
|
|
71
|
+
},
|
|
72
|
+
play: async () => {
|
|
73
|
+
const elem = document.querySelector('.dropin-image') as HTMLElement;
|
|
74
|
+
await expect(elem).toBeVisible();
|
|
75
|
+
|
|
76
|
+
await waitFor(() => expect(elem).toHaveClass('dropin-image--loaded'));
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const WithParams: Story = {
|
|
81
|
+
args: {
|
|
82
|
+
src: ExampleImage,
|
|
83
|
+
params: { width: defaultWidth },
|
|
84
|
+
alt: 'Some alternative text',
|
|
85
|
+
loading: 'lazy',
|
|
86
|
+
width: defaultWidth,
|
|
87
|
+
height: defaultHeight,
|
|
88
|
+
},
|
|
89
|
+
};
|