@bytebrand/fe-ui-core-autobahn 1.0.211 → 1.0.213
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/cards/CarCard.tsx +51 -13
- package/cards/CarRow.tsx +5 -1
- package/cards/cardParts.tsx +11 -1
- package/constants/app.ts +11 -1
- package/constants/core.ts +12 -1
- package/locales/de/autobahn.json +11 -1
- package/locales/en/autobahn.json +11 -1
- package/package.json +30 -30
- package/theme/md3.css +135 -185
- package/ui/Stars.tsx +36 -18
- package/vdp/VdpModules.tsx +135 -621
- package/vdp/index.ts +6 -3
- package/vdp/types.ts +20 -10
package/ui/Stars.tsx
CHANGED
|
@@ -3,27 +3,45 @@ import React from 'react';
|
|
|
3
3
|
import Icon from './Icon';
|
|
4
4
|
|
|
5
5
|
export interface StarsProps {
|
|
6
|
-
/** rating value 0–5; each star fills
|
|
6
|
+
/** rating value 0–5; each star fills by its exact share (4,52 → four full stars + 52 % of the fifth). */
|
|
7
7
|
value: number;
|
|
8
8
|
size?: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
11
|
+
const FILLED = '#F2A900';
|
|
12
|
+
const EMPTY = '#D8D6DC';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 5-star row filled to the exact value: a grey star with the gold one clipped to the star's
|
|
16
|
+
* share on top, so a site rating of 4,5 shows four and a half stars (whole-number review
|
|
17
|
+
* ratings render exactly as before).
|
|
18
|
+
*/
|
|
19
|
+
const Stars: React.FunctionComponent<StarsProps> = ({ value, size = 16 }) => {
|
|
20
|
+
const v = Math.max(0, Math.min(5, Number(value) || 0));
|
|
21
|
+
return (
|
|
22
|
+
<span
|
|
23
|
+
role="img"
|
|
24
|
+
aria-label={`${v.toLocaleString('de-DE', { maximumFractionDigits: 1 })} von 5 Sternen`}
|
|
25
|
+
style={{ display: 'inline-flex', gap: 1 }}
|
|
26
|
+
>
|
|
27
|
+
{[0, 1, 2, 3, 4].map((i) => {
|
|
28
|
+
const share = Math.max(0, Math.min(1, v - i));
|
|
29
|
+
return (
|
|
30
|
+
<span key={i} style={{ position: 'relative', display: 'inline-flex', flex: 'none' }}>
|
|
31
|
+
<Icon name="star" size={size} color={EMPTY} style={{ fill: EMPTY }} />
|
|
32
|
+
{share > 0 && (
|
|
33
|
+
<span
|
|
34
|
+
aria-hidden="true"
|
|
35
|
+
style={{ position: 'absolute', top: 0, left: 0, bottom: 0, width: `${share * 100}%`, overflow: 'hidden', display: 'flex' }}
|
|
36
|
+
>
|
|
37
|
+
<Icon name="star" size={size} color={FILLED} style={{ fill: FILLED, flex: 'none' }} />
|
|
38
|
+
</span>
|
|
39
|
+
)}
|
|
40
|
+
</span>
|
|
41
|
+
);
|
|
42
|
+
})}
|
|
43
|
+
</span>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
28
46
|
|
|
29
47
|
export default Stars;
|