@adobe-commerce/elsie 3.0.0-alpha-20261021202251 → 3.0.0-beta.0
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/CHANGELOG.md +1 -3
- package/package.json +5 -5
- package/src/components/index.ts +0 -1
- package/src/i18n/en_US.json +0 -9
- package/src/components/StarRating/StarRating.css +0 -87
- package/src/components/StarRating/StarRating.stories.tsx +0 -129
- package/src/components/StarRating/StarRating.tsx +0 -147
- package/src/components/StarRating/index.ts +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @adobe-commerce/elsie
|
|
2
2
|
|
|
3
|
-
## 3.0.0-
|
|
3
|
+
## 3.0.0-beta.0
|
|
4
4
|
|
|
5
5
|
### Major Changes
|
|
6
6
|
|
|
@@ -138,8 +138,6 @@
|
|
|
138
138
|
imports from Elsie's dependency tree so isolated consumers can run
|
|
139
139
|
`elsie storybook` and `elsie storybook build` without installing the Storybook
|
|
140
140
|
CLI themselves.
|
|
141
|
-
- 410f411: feat: add `StarRating` component that displays a 0-5 rating with
|
|
142
|
-
partial star fill, optional value, review count and accessible label
|
|
143
141
|
- 25ba0c5: Share the named `a11yTestRunnerConfig` Storybook configuration
|
|
144
142
|
through `@adobe-commerce/elsie/storybook/test-runner`. Consumers can replace
|
|
145
143
|
their duplicate `.storybook/test-runner.ts` hooks with an import and remove
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe-commerce/elsie",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"description": "Domain Package SDK",
|
|
6
6
|
"engines": {
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"./*": "./*"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@adobe-commerce/event-bus": "1.1.2-
|
|
68
|
-
"@adobe-commerce/fetch-graphql": "1.3.2-
|
|
69
|
-
"@adobe-commerce/recaptcha": "1.3.1-
|
|
70
|
-
"@adobe-commerce/storefront-design": "1.1.2-
|
|
67
|
+
"@adobe-commerce/event-bus": "~1.1.2-beta.0",
|
|
68
|
+
"@adobe-commerce/fetch-graphql": "~1.3.2-beta.0",
|
|
69
|
+
"@adobe-commerce/recaptcha": "1.3.1-beta.0",
|
|
70
|
+
"@adobe-commerce/storefront-design": "~1.1.2-beta.0",
|
|
71
71
|
"@chromatic-com/storybook": "^5",
|
|
72
72
|
"@preact/signals": "^2.3.1",
|
|
73
73
|
"@types/node": "^22.0.0",
|
package/src/components/index.ts
CHANGED
|
@@ -52,4 +52,3 @@ export * from '@adobe-commerce/elsie/components/InputFile';
|
|
|
52
52
|
export * from '@adobe-commerce/elsie/components/Table';
|
|
53
53
|
export * from '@adobe-commerce/elsie/components/MultiSelect';
|
|
54
54
|
export * from '@adobe-commerce/elsie/components/LiveRegion';
|
|
55
|
-
export * from '@adobe-commerce/elsie/components/StarRating';
|
package/src/i18n/en_US.json
CHANGED
|
@@ -187,15 +187,6 @@
|
|
|
187
187
|
"itemsSelectedDescription": "{count} item{s} selected: {labels}",
|
|
188
188
|
"noItemsSelected": "No items selected"
|
|
189
189
|
}
|
|
190
|
-
},
|
|
191
|
-
"StarRating": {
|
|
192
|
-
"label": "{{rating}} out of 5 stars",
|
|
193
|
-
"symbolLabel": "{{rating}} out of 5",
|
|
194
|
-
"valueLabel": "{{rating}} out of 5",
|
|
195
|
-
"compactCount": "({{count}})",
|
|
196
|
-
"zeroReviews": "No reviews",
|
|
197
|
-
"oneReview": "1 review",
|
|
198
|
-
"reviews": "{{count}} reviews"
|
|
199
190
|
}
|
|
200
191
|
}
|
|
201
192
|
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/********************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
3
|
-
* __________________
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2026 Adobe
|
|
6
|
-
* All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* NOTICE: All information contained herein is, and remains
|
|
9
|
-
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
-
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
-
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
-
* property laws, including trade secret and copyright laws.
|
|
13
|
-
* Dissemination of this information or reproduction of this material
|
|
14
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
-
* from Adobe.
|
|
16
|
-
*******************************************************************/
|
|
17
|
-
|
|
18
|
-
.dropin-star-rating {
|
|
19
|
-
display: inline-flex;
|
|
20
|
-
flex-wrap: wrap;
|
|
21
|
-
align-items: center;
|
|
22
|
-
gap: var(--spacing-small);
|
|
23
|
-
max-width: 100%;
|
|
24
|
-
color: var(--color-neutral-800);
|
|
25
|
-
font: var(--type-body-2-default-font);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.dropin-star-rating__stars {
|
|
29
|
-
display: inline-flex;
|
|
30
|
-
flex: 0 0 auto;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.dropin-star-rating__star {
|
|
34
|
-
position: relative;
|
|
35
|
-
flex: 0 0 auto;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.dropin-star-rating__star svg {
|
|
39
|
-
display: block;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.dropin-star-rating__star path {
|
|
43
|
-
fill: var(--color-neutral-400);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.dropin-star-rating__fill {
|
|
47
|
-
position: absolute;
|
|
48
|
-
inset-block-start: 0;
|
|
49
|
-
inset-inline-start: 0;
|
|
50
|
-
height: 100%;
|
|
51
|
-
overflow: hidden;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.dropin-star-rating__fill svg {
|
|
55
|
-
position: absolute;
|
|
56
|
-
inset-inline-start: 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.dropin-star-rating__fill svg path {
|
|
60
|
-
fill: currentcolor;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.dropin-star-rating__count {
|
|
64
|
-
color: var(--color-neutral-700);
|
|
65
|
-
overflow-wrap: anywhere;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.dropin-star-rating__value {
|
|
69
|
-
font: var(--type-body-2-strong-font);
|
|
70
|
-
overflow-wrap: anywhere;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.dropin-star-rating--stacked {
|
|
74
|
-
flex-direction: column;
|
|
75
|
-
align-items: flex-start;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.dropin-star-rating--stacked .dropin-star-rating__value {
|
|
79
|
-
order: -1;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.dropin-star-rating--inline.dropin-star-rating--divider
|
|
83
|
-
.dropin-star-rating__count {
|
|
84
|
-
padding-inline-start: var(--spacing-small);
|
|
85
|
-
border-inline-start: var(--shape-border-width-1) solid
|
|
86
|
-
var(--color-neutral-400);
|
|
87
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/********************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
3
|
-
* __________________
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2026 Adobe
|
|
6
|
-
* All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* NOTICE: All information contained herein is, and remains
|
|
9
|
-
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
-
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
-
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
-
* property laws, including trade secret and copyright laws.
|
|
13
|
-
* Dissemination of this information or reproduction of this material
|
|
14
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
-
* from Adobe.
|
|
16
|
-
*******************************************************************/
|
|
17
|
-
|
|
18
|
-
import type { Meta, StoryObj } from '@storybook/preact-vite';
|
|
19
|
-
import { expect } from '@adobe-commerce/elsie/storybook/tests';
|
|
20
|
-
import {
|
|
21
|
-
StarRating as component,
|
|
22
|
-
StarRatingProps,
|
|
23
|
-
} from '@adobe-commerce/elsie/components/StarRating';
|
|
24
|
-
|
|
25
|
-
const meta: Meta<StarRatingProps> = {
|
|
26
|
-
title: 'Components/StarRating',
|
|
27
|
-
component,
|
|
28
|
-
tags: ['autodocs'],
|
|
29
|
-
args: { rating: 4.5 },
|
|
30
|
-
argTypes: {
|
|
31
|
-
rating: { control: { type: 'range', min: 0, max: 5, step: 0.1 } },
|
|
32
|
-
reviewCount: { control: { type: 'number', min: 0 } },
|
|
33
|
-
showCount: { control: 'boolean' },
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default meta;
|
|
38
|
-
|
|
39
|
-
type Story = StoryObj<StarRatingProps>;
|
|
40
|
-
|
|
41
|
-
export const Fractional: Story = {};
|
|
42
|
-
export const Whole: Story = { args: { rating: 5 } };
|
|
43
|
-
export const WithCount: Story = { args: { reviewCount: 2, showCount: true } };
|
|
44
|
-
export const OneReview: Story = {
|
|
45
|
-
args: { rating: 4, reviewCount: 1, showCount: true },
|
|
46
|
-
};
|
|
47
|
-
export const ZeroReviews: Story = {
|
|
48
|
-
args: { rating: 0, reviewCount: 0, showCount: true },
|
|
49
|
-
};
|
|
50
|
-
export const CountInParentheses: Story = {
|
|
51
|
-
args: { reviewCount: 12, showCount: true, countDisplay: 'parentheses' },
|
|
52
|
-
};
|
|
53
|
-
export const CustomCountColor: Story = {
|
|
54
|
-
args: { reviewCount: 12, showCount: true, countDisplay: 'parentheses' },
|
|
55
|
-
decorators: [
|
|
56
|
-
(Story) => (
|
|
57
|
-
<div className="story-count-alert">
|
|
58
|
-
<style>{`.story-count-alert .dropin-star-rating__count { color: var(--color-alert-800); }`}</style>
|
|
59
|
-
<Story />
|
|
60
|
-
</div>
|
|
61
|
-
),
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
export const InlineWithValueAndCount: Story = {
|
|
65
|
-
args: {
|
|
66
|
-
rating: 4.3,
|
|
67
|
-
reviewCount: 12,
|
|
68
|
-
showCount: true,
|
|
69
|
-
valueDisplay: 'value',
|
|
70
|
-
countDisplay: 'parentheses',
|
|
71
|
-
layout: 'inline',
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
export const StackedOutOfFive: Story = {
|
|
75
|
-
args: {
|
|
76
|
-
rating: 4.3,
|
|
77
|
-
reviewCount: 12,
|
|
78
|
-
showCount: true,
|
|
79
|
-
valueDisplay: 'outOfFive',
|
|
80
|
-
countDisplay: 'text',
|
|
81
|
-
layout: 'stacked',
|
|
82
|
-
},
|
|
83
|
-
decorators: [
|
|
84
|
-
(Story) => (
|
|
85
|
-
<div className="story-count-positive">
|
|
86
|
-
<style>{`.story-count-positive .dropin-star-rating__count { color: var(--color-positive-800); }`}</style>
|
|
87
|
-
<Story />
|
|
88
|
-
</div>
|
|
89
|
-
),
|
|
90
|
-
],
|
|
91
|
-
};
|
|
92
|
-
export const HeartIcon: Story = {
|
|
93
|
-
args: {
|
|
94
|
-
icon: 'HeartFilled',
|
|
95
|
-
reviewCount: 12,
|
|
96
|
-
showCount: true,
|
|
97
|
-
countDisplay: 'parentheses',
|
|
98
|
-
style: { color: 'var(--color-alert-500)' },
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
// Regression test: URL-loaded icons render inside a <span>, so the empty
|
|
102
|
-
// (gray) star layer must be styled without relying on a direct <svg> child.
|
|
103
|
-
export const UrlIconEmptyStarsStayGray: Story = {
|
|
104
|
-
args: {
|
|
105
|
-
rating: 0,
|
|
106
|
-
icon: (props) => (
|
|
107
|
-
<span>
|
|
108
|
-
<svg {...props} viewBox="0 0 24 24">
|
|
109
|
-
<path
|
|
110
|
-
d="M12 2l3 7h7l-5.5 4.5L18 21l-6-4-6 4 1.5-7.5L2 9h7z"
|
|
111
|
-
fill="red"
|
|
112
|
-
/>
|
|
113
|
-
</svg>
|
|
114
|
-
</span>
|
|
115
|
-
),
|
|
116
|
-
},
|
|
117
|
-
play: async ({ canvasElement }) => {
|
|
118
|
-
const basePath = canvasElement.querySelector(
|
|
119
|
-
'.dropin-star-rating__star > span path',
|
|
120
|
-
) as SVGPathElement;
|
|
121
|
-
await expect(getComputedStyle(basePath).fill).not.toBe('rgb(255, 0, 0)');
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
export const CountHidden: Story = {
|
|
125
|
-
args: { reviewCount: 2, showCount: false },
|
|
126
|
-
};
|
|
127
|
-
export const RightToLeft: Story = {
|
|
128
|
-
args: { dir: 'rtl', reviewCount: 12, showCount: true },
|
|
129
|
-
};
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/********************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
3
|
-
* __________________
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2026 Adobe
|
|
6
|
-
* All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* NOTICE: All information contained herein is, and remains
|
|
9
|
-
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
-
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
-
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
-
* property laws, including trade secret and copyright laws.
|
|
13
|
-
* Dissemination of this information or reproduction of this material
|
|
14
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
-
* from Adobe.
|
|
16
|
-
*******************************************************************/
|
|
17
|
-
|
|
18
|
-
import { ComponentProps, FunctionComponent } from 'preact';
|
|
19
|
-
import { HTMLAttributes } from 'preact/compat';
|
|
20
|
-
import { classes } from '@adobe-commerce/elsie/lib';
|
|
21
|
-
import { Icon } from '@adobe-commerce/elsie/components/Icon';
|
|
22
|
-
import { Text, useText } from '@adobe-commerce/elsie/i18n';
|
|
23
|
-
import '@adobe-commerce/elsie/components/StarRating/StarRating.css';
|
|
24
|
-
|
|
25
|
-
export interface StarRatingProps extends Omit<
|
|
26
|
-
HTMLAttributes<HTMLDivElement>,
|
|
27
|
-
'children' | 'icon'
|
|
28
|
-
> {
|
|
29
|
-
rating: number;
|
|
30
|
-
reviewCount?: number;
|
|
31
|
-
showCount?: boolean;
|
|
32
|
-
valueDisplay?: 'hidden' | 'value' | 'outOfFive';
|
|
33
|
-
countDisplay?: 'text' | 'parentheses';
|
|
34
|
-
layout?: 'inline' | 'stacked';
|
|
35
|
-
showDivider?: boolean;
|
|
36
|
-
icon?: ComponentProps<typeof Icon>['source'];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const StarRating: FunctionComponent<StarRatingProps> = ({
|
|
40
|
-
className,
|
|
41
|
-
rating,
|
|
42
|
-
reviewCount,
|
|
43
|
-
showCount = false,
|
|
44
|
-
valueDisplay = 'hidden',
|
|
45
|
-
countDisplay = 'text',
|
|
46
|
-
layout = 'inline',
|
|
47
|
-
showDivider = false,
|
|
48
|
-
icon = 'Star',
|
|
49
|
-
...props
|
|
50
|
-
}) => {
|
|
51
|
-
const countKey =
|
|
52
|
-
reviewCount === 0
|
|
53
|
-
? 'zeroReviews'
|
|
54
|
-
: reviewCount === 1
|
|
55
|
-
? 'oneReview'
|
|
56
|
-
: 'reviews';
|
|
57
|
-
const displayRating = Number.isFinite(rating) ? rating.toFixed(1) : '';
|
|
58
|
-
const dictionary = useText({
|
|
59
|
-
ratingLabel: (
|
|
60
|
-
<Text
|
|
61
|
-
id={
|
|
62
|
-
icon === 'Star'
|
|
63
|
-
? 'Dropin.StarRating.label'
|
|
64
|
-
: 'Dropin.StarRating.symbolLabel'
|
|
65
|
-
}
|
|
66
|
-
fields={{ rating }}
|
|
67
|
-
/>
|
|
68
|
-
),
|
|
69
|
-
valueLabel: (
|
|
70
|
-
<Text
|
|
71
|
-
id="Dropin.StarRating.valueLabel"
|
|
72
|
-
fields={{ rating: displayRating }}
|
|
73
|
-
/>
|
|
74
|
-
),
|
|
75
|
-
compactCount: (
|
|
76
|
-
<Text
|
|
77
|
-
id="Dropin.StarRating.compactCount"
|
|
78
|
-
fields={{ count: reviewCount }}
|
|
79
|
-
/>
|
|
80
|
-
),
|
|
81
|
-
countLabel: (
|
|
82
|
-
<Text
|
|
83
|
-
id={`Dropin.StarRating.${countKey}`}
|
|
84
|
-
fields={{ count: reviewCount }}
|
|
85
|
-
/>
|
|
86
|
-
),
|
|
87
|
-
noReviews: 'Dropin.StarRating.zeroReviews',
|
|
88
|
-
});
|
|
89
|
-
if (
|
|
90
|
-
!Number.isFinite(rating) ||
|
|
91
|
-
rating < 0 ||
|
|
92
|
-
rating > 5 ||
|
|
93
|
-
(reviewCount !== undefined &&
|
|
94
|
-
(!Number.isSafeInteger(reviewCount) || reviewCount < 0))
|
|
95
|
-
) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
const hasCount = showCount && reviewCount !== undefined;
|
|
99
|
-
const label =
|
|
100
|
-
reviewCount === 0 ? dictionary.noReviews : dictionary.ratingLabel;
|
|
101
|
-
const accessibleLabel =
|
|
102
|
-
hasCount && reviewCount !== 0
|
|
103
|
-
? `${label}, ${dictionary.countLabel}`
|
|
104
|
-
: label;
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<div
|
|
108
|
-
{...props}
|
|
109
|
-
className={classes([
|
|
110
|
-
'dropin-star-rating',
|
|
111
|
-
`dropin-star-rating--${layout}`,
|
|
112
|
-
['dropin-star-rating--divider', showDivider && hasCount],
|
|
113
|
-
className,
|
|
114
|
-
])}
|
|
115
|
-
role="img"
|
|
116
|
-
aria-label={accessibleLabel}
|
|
117
|
-
>
|
|
118
|
-
<span className="dropin-star-rating__stars" aria-hidden="true">
|
|
119
|
-
{[0, 1, 2, 3, 4].map((index) => (
|
|
120
|
-
<span key={index} className="dropin-star-rating__star">
|
|
121
|
-
<Icon source={icon} size="24" aria-hidden="true" />
|
|
122
|
-
<span
|
|
123
|
-
className="dropin-star-rating__fill"
|
|
124
|
-
style={{
|
|
125
|
-
width: `${Math.round(Math.min(Math.max(rating - index, 0), 1) * 100)}%`,
|
|
126
|
-
}}
|
|
127
|
-
>
|
|
128
|
-
<Icon source={icon} size="24" aria-hidden="true" />
|
|
129
|
-
</span>
|
|
130
|
-
</span>
|
|
131
|
-
))}
|
|
132
|
-
</span>
|
|
133
|
-
{valueDisplay !== 'hidden' && reviewCount !== 0 && (
|
|
134
|
-
<span className="dropin-star-rating__value" aria-hidden="true">
|
|
135
|
-
{valueDisplay === 'outOfFive' ? dictionary.valueLabel : displayRating}
|
|
136
|
-
</span>
|
|
137
|
-
)}
|
|
138
|
-
{hasCount && (
|
|
139
|
-
<span className="dropin-star-rating__count" aria-hidden="true">
|
|
140
|
-
{countDisplay === 'parentheses' && reviewCount !== 0
|
|
141
|
-
? dictionary.compactCount
|
|
142
|
-
: dictionary.countLabel}
|
|
143
|
-
</span>
|
|
144
|
-
)}
|
|
145
|
-
</div>
|
|
146
|
-
);
|
|
147
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/********************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
3
|
-
* __________________
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2026 Adobe
|
|
6
|
-
* All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* NOTICE: All information contained herein is, and remains
|
|
9
|
-
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
-
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
-
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
-
* property laws, including trade secret and copyright laws.
|
|
13
|
-
* Dissemination of this information or reproduction of this material
|
|
14
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
-
* from Adobe.
|
|
16
|
-
*******************************************************************/
|
|
17
|
-
|
|
18
|
-
export * from '@adobe-commerce/elsie/components/StarRating/StarRating';
|
|
19
|
-
export { StarRating as default } from '@adobe-commerce/elsie/components/StarRating/StarRating';
|