@orangesk/orange-design-system 3.1.0 → 3.3.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/build/components/Avatar/style.css +2 -0
- package/build/components/Avatar/style.css.map +1 -0
- package/build/components/BodyBanner/style.css +1 -1
- package/build/components/BodyBanner/style.css.map +1 -1
- package/build/components/Carousel/style.css +1 -1
- package/build/components/Carousel/style.css.map +1 -1
- package/build/components/Countdown/style.css +2 -0
- package/build/components/Countdown/style.css.map +1 -0
- package/build/components/DocumentationSidebar/style.css +1 -1
- package/build/components/DocumentationSidebar/style.css.map +1 -1
- package/build/components/Footer/style.css +1 -1
- package/build/components/Footer/style.css.map +1 -1
- package/build/components/List/style.css +1 -1
- package/build/components/List/style.css.map +1 -1
- package/build/components/Megamenu/style.css +1 -1
- package/build/components/Megamenu/style.css.map +1 -1
- package/build/components/Pill/style.css +1 -1
- package/build/components/Pill/style.css.map +1 -1
- package/build/components/Preview/style.css +1 -1
- package/build/components/Preview/style.css.map +1 -1
- package/build/components/StarRating/style.css +2 -0
- package/build/components/StarRating/style.css.map +1 -0
- package/build/components/index.js +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/tsconfig.tsbuildinfo +1 -1
- package/build/components/types/index.d.ts +65 -15
- package/build/components/types/src/components/Avatar/Avatar.d.ts +7 -0
- package/build/components/types/src/components/Avatar/index.d.ts +2 -0
- package/build/components/types/src/components/Carousel/Carousel.d.ts +10 -3
- package/build/components/types/src/components/Carousel/constants.d.ts +2 -0
- package/build/components/types/src/components/Countdown/Countdown.d.ts +10 -0
- package/build/components/types/src/components/Countdown/Countdown.react.d.ts +8 -0
- package/build/components/types/src/components/Countdown/Countdown.shared.d.ts +54 -0
- package/build/components/types/src/components/Countdown/Countdown.static.d.ts +21 -0
- package/build/components/types/src/components/Countdown/CountdownTag.d.ts +9 -0
- package/build/components/types/src/components/Countdown/CountdownTag.static.d.ts +16 -0
- package/build/components/types/src/components/Countdown/constants.d.ts +28 -0
- package/build/components/types/src/components/Countdown/index.d.ts +3 -0
- package/build/components/types/src/components/DocumentationSidebar/DocumentationSidebar.d.ts +1 -0
- package/build/components/types/src/components/Preview/PreviewGenerator.d.ts +1 -0
- package/build/components/types/src/components/PromoBanner/PromoBanner.d.ts +5 -1
- package/build/components/types/src/components/StarRating/StarRating.d.ts +9 -0
- package/build/components/types/src/components/StarRating/index.d.ts +1 -0
- package/build/components/types/src/components/index.d.ts +5 -3
- package/build/components/types/src/scripts/index.d.ts +10 -0
- package/build/components/types/src/styles/export/color.d.ts +2 -0
- package/build/lib/base.css +1 -1
- package/build/lib/base.css.map +1 -1
- package/build/lib/components.css +1 -1
- package/build/lib/components.css.map +1 -1
- package/build/lib/footer.css +1 -1
- package/build/lib/footer.css.map +1 -1
- package/build/lib/megamenu.css +1 -1
- package/build/lib/megamenu.css.map +1 -1
- package/build/lib/scripts.js +1 -1
- package/build/lib/scripts.js.map +1 -1
- package/build/lib/style.css +1 -1
- package/build/lib/style.css.map +1 -1
- package/build/lib/tsconfig.tsbuildinfo +1 -1
- package/build/lib/utilities.css +1 -1
- package/build/lib/utilities.css.map +1 -1
- package/build/sprite.svg +1 -1
- package/package.json +30 -29
- package/src/assets/icons/add.svg +4 -1
- package/src/assets/icons/close.svg +3 -3
- package/src/assets/icons/menu.svg +4 -1
- package/src/assets/icons/pause.svg +3 -3
- package/src/assets/icons/play.svg +2 -2
- package/src/assets/icons/quote.svg +1 -1
- package/src/assets/icons/remove.svg +4 -1
- package/src/assets/icons/search.svg +4 -1
- package/src/assets/icons/star-empty-thin.svg +4 -0
- package/src/components/Avatar/Avatar.tsx +36 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Avatar/styles/config.scss +11 -0
- package/src/components/Avatar/styles/mixins.scss +53 -0
- package/src/components/Avatar/styles/style.scss +20 -0
- package/src/components/Avatar/tests/Avatar.conformance.test.jsx +23 -0
- package/src/components/Avatar/tests/Avatar.unit.test.jsx +45 -0
- package/src/components/BodyBanner/styles/mixins.scss +5 -1
- package/src/components/Carousel/Carousel.static.ts +17 -3
- package/src/components/Carousel/Carousel.tsx +55 -32
- package/src/components/Carousel/constants.ts +2 -0
- package/src/components/Carousel/styles/config.scss +5 -8
- package/src/components/Carousel/styles/mixins.scss +48 -78
- package/src/components/Carousel/styles/style.scss +8 -21
- package/src/components/Carousel/tests/Carousel.unit.test.jsx +77 -5
- package/src/components/Countdown/Countdown.react.ts +67 -0
- package/src/components/Countdown/Countdown.shared.ts +228 -0
- package/src/components/Countdown/Countdown.static.ts +201 -0
- package/src/components/Countdown/Countdown.tsx +105 -0
- package/src/components/Countdown/CountdownTag.static.ts +140 -0
- package/src/components/Countdown/CountdownTag.tsx +99 -0
- package/src/components/Countdown/constants.ts +36 -0
- package/src/components/Countdown/index.ts +3 -0
- package/src/components/Countdown/styles/config.scss +17 -0
- package/src/components/Countdown/styles/mixins.scss +193 -0
- package/src/components/Countdown/styles/style.scss +82 -0
- package/src/components/{Testimonial/tests/Testimonial.conformance.test.jsx → Countdown/tests/Countdown.conformance.test.jsx} +7 -2
- package/src/components/Countdown/tests/Countdown.static.test.jsx +117 -0
- package/src/components/Countdown/tests/Countdown.unit.test.jsx +101 -0
- package/src/components/Countdown/tests/CountdownTag.conformance.test.jsx +21 -0
- package/src/components/Countdown/tests/CountdownTag.static.test.jsx +30 -0
- package/src/components/Countdown/tests/CountdownTag.unit.test.jsx +67 -0
- package/src/components/DocumentationSidebar/DocumentationSidebar.tsx +14 -1
- package/src/components/DocumentationSidebar/styles/style.scss +11 -0
- package/src/components/Forms/Autocomplete/Autocomplete.static.ts +14 -1
- package/src/components/Forms/Autocomplete/styles/mixins.scss +3 -2
- package/src/components/Forms/Autocomplete/tests/Autocomplete.styles.unit.test.jsx +20 -0
- package/src/components/List/styles/config.scss +1 -1
- package/src/components/Pill/styles/style.scss +2 -1
- package/src/components/Preview/PreviewGenerator.tsx +137 -103
- package/src/components/Preview/styles/style.scss +15 -9
- package/src/components/PromoBanner/PromoBanner.tsx +24 -7
- package/src/components/PromoBanner/tests/PromoBanner.unit.test.jsx +31 -0
- package/src/components/StarRating/StarRating.tsx +52 -0
- package/src/components/StarRating/index.ts +1 -0
- package/src/components/StarRating/styles/style.scss +28 -0
- package/src/components/StarRating/tests/StarRating.unit.test.jsx +62 -0
- package/src/components/index.ts +9 -3
- package/src/styles/export/color.js +2 -0
- package/src/styles/tokens/color.scss +2 -0
- package/src/styles/typography/mixins.scss +4 -0
- package/src/styles/utilities/text.scss +9 -0
- package/build/components/Testimonial/style.css +0 -2
- package/build/components/Testimonial/style.css.map +0 -1
- package/build/components/types/src/components/Testimonial/Testimonial.d.ts +0 -10
- package/build/components/types/src/components/Testimonial/index.d.ts +0 -1
- package/build/search-index.json +0 -430
- package/src/components/Testimonial/Testimonial.tsx +0 -38
- package/src/components/Testimonial/index.ts +0 -1
- package/src/components/Testimonial/styles/config.scss +0 -42
- package/src/components/Testimonial/styles/mixins.scss +0 -44
- package/src/components/Testimonial/styles/style.scss +0 -16
- package/src/components/Testimonial/tests/Testimonial.unit.test.jsx +0 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orangesk/orange-design-system",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.x"
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
"./public/*": "./public/*"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"dev": "npm run build:scss-exports && npm run build:search-index && next dev",
|
|
28
|
-
"build": "npm run build:scss-exports && npm run build:search-index && next build && npm run sprite",
|
|
27
|
+
"dev": "npm run build:scss-exports && npm run build:search-index && npm run build:preview-iframe && next dev",
|
|
28
|
+
"build": "npm run build:scss-exports && npm run build:search-index && npm run build:preview-iframe && next build && npm run sprite",
|
|
29
29
|
"build:bundle": "npm run build:scss-exports && pnpm exec rollup -c && npm run build:megamenu && npm run build:footer",
|
|
30
|
+
"build:preview-iframe": "node scripts/build-preview-iframe-bundle.mjs",
|
|
30
31
|
"build:megamenu": "npm run build:scss-exports && pnpm exec rollup -c rollup.megamenu.config.mjs",
|
|
31
32
|
"dev:megamenu": "npm run build:scss-exports && pnpm exec rollup -c rollup.megamenu.config.mjs --watch",
|
|
32
33
|
"build:footer": "npm run build:scss-exports && pnpm exec rollup -c rollup.footer.config.mjs",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"@cloudfour/transition-hidden-element": "^2.0.2",
|
|
56
57
|
"@mdx-js/loader": "^3.1.1",
|
|
57
58
|
"@mdx-js/react": "^3.1.1",
|
|
58
|
-
"@next/mdx": "16.2.
|
|
59
|
+
"@next/mdx": "16.2.12",
|
|
59
60
|
"@orangesk/accessible-autocomplete": "3.2.2",
|
|
60
61
|
"@popperjs/core": "^2.11.8",
|
|
61
62
|
"@types/mdx": "^2.0.14",
|
|
@@ -63,24 +64,24 @@
|
|
|
63
64
|
"classnames": "^2.5.1",
|
|
64
65
|
"daypickr": "^0.3.4",
|
|
65
66
|
"diff2html": "^3.4.56",
|
|
66
|
-
"dompurify": "^3.4.
|
|
67
|
-
"html-react-parser": "6.1.
|
|
67
|
+
"dompurify": "^3.4.12",
|
|
68
|
+
"html-react-parser": "6.1.5",
|
|
68
69
|
"lorem-ipsum": "3.0.0",
|
|
69
70
|
"minisearch": "7.2.0",
|
|
70
|
-
"next": "16.2.
|
|
71
|
+
"next": "16.2.12",
|
|
71
72
|
"normalize.css": "^8.0.1",
|
|
72
73
|
"nouislider": "^15.8.1",
|
|
73
74
|
"prism-react-renderer": "^2.4.1",
|
|
74
|
-
"query-string": "^9.4.
|
|
75
|
-
"react": "^19.2.
|
|
76
|
-
"react-dom": "^19.2.
|
|
75
|
+
"query-string": "^9.4.1",
|
|
76
|
+
"react": "^19.2.8",
|
|
77
|
+
"react-dom": "^19.2.8",
|
|
77
78
|
"react-element-to-jsx-string": "^17.0.1",
|
|
78
|
-
"react-is": "^19.2.
|
|
79
|
+
"react-is": "^19.2.8",
|
|
79
80
|
"rehype-autolink-headings": "^7.1.0",
|
|
80
81
|
"rehype-slug": "^6.0.0",
|
|
81
82
|
"remark-gemoji": "^8.0.0",
|
|
82
83
|
"remark-gfm": "^4.0.1",
|
|
83
|
-
"swiper": "
|
|
84
|
+
"swiper": "14.0.7",
|
|
84
85
|
"tabbable": "^6.5.0",
|
|
85
86
|
"unescape-html": "^1.1.0",
|
|
86
87
|
"wnumb": "^1.2.0"
|
|
@@ -99,38 +100,38 @@
|
|
|
99
100
|
"@rollup/plugin-terser": "1.0.0",
|
|
100
101
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
101
102
|
"@rollup/plugin-url": "^8.0.2",
|
|
102
|
-
"@rollup/rollup-darwin-arm64": "^4.62.
|
|
103
|
+
"@rollup/rollup-darwin-arm64": "^4.62.3",
|
|
103
104
|
"@testing-library/dom": "^10.4.1",
|
|
104
|
-
"@testing-library/jest-dom": "
|
|
105
|
+
"@testing-library/jest-dom": "7.0.0",
|
|
105
106
|
"@testing-library/react": "^16.3.2",
|
|
106
107
|
"@testing-library/user-event": "^14.6.1",
|
|
107
|
-
"@types/node": "26.
|
|
108
|
+
"@types/node": "26.1.2",
|
|
108
109
|
"@types/react": "19.2.17",
|
|
109
110
|
"@types/react-dom": "19.2.3",
|
|
110
111
|
"@types/wnumb": "^1.2.3",
|
|
111
|
-
"@vitejs/plugin-react": "6.0.
|
|
112
|
-
"@vitest/browser": "^4.1.
|
|
113
|
-
"@vitest/browser-playwright": "^4.1.
|
|
114
|
-
"@vitest/coverage-v8": "^4.1.
|
|
115
|
-
"@vitest/ui": "^4.1.
|
|
112
|
+
"@vitejs/plugin-react": "6.0.4",
|
|
113
|
+
"@vitest/browser": "^4.1.10",
|
|
114
|
+
"@vitest/browser-playwright": "^4.1.10",
|
|
115
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
116
|
+
"@vitest/ui": "^4.1.10",
|
|
116
117
|
"canvas": "^3.2.3",
|
|
117
|
-
"fs-extra": "^11.
|
|
118
|
+
"fs-extra": "^11.4.0",
|
|
118
119
|
"glob": "13.0.6",
|
|
119
|
-
"html-validate": "11.
|
|
120
|
+
"html-validate": "11.6.0",
|
|
120
121
|
"husky": "^9.1.7",
|
|
121
122
|
"identity-obj-proxy": "^3.0.0",
|
|
122
|
-
"jsdom": "
|
|
123
|
-
"lint-staged": "17.0
|
|
124
|
-
"playwright": "^1.
|
|
125
|
-
"prettier": "^3.
|
|
126
|
-
"rollup": "^4.62.
|
|
123
|
+
"jsdom": "30.0.1",
|
|
124
|
+
"lint-staged": "17.2.0",
|
|
125
|
+
"playwright": "^1.62.0",
|
|
126
|
+
"prettier": "^3.9.6",
|
|
127
|
+
"rollup": "^4.62.3",
|
|
127
128
|
"rollup-plugin-copy": "^3.5.0",
|
|
128
129
|
"rollup-plugin-dts": "^6.4.1",
|
|
129
130
|
"rollup-plugin-postcss": "^4.0.2",
|
|
130
|
-
"sass": "^1.
|
|
131
|
+
"sass": "^1.102.0",
|
|
131
132
|
"svg-sprite": "^2.0.4",
|
|
132
133
|
"typescript": "6.0.3",
|
|
133
|
-
"vitest": "^4.1.
|
|
134
|
+
"vitest": "^4.1.10",
|
|
134
135
|
"vitest-axe": "^0.1.0",
|
|
135
136
|
"vitest-browser-react": "^2.2.0"
|
|
136
137
|
},
|
package/src/assets/icons/add.svg
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none"
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M27 21H40V27H27V40H21V27H8V21H21V8H27V21Z" fill="currentColor"/>
|
|
4
|
+
</svg>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none"
|
|
2
2
|
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
-
<path d="
|
|
4
|
-
<path d="
|
|
3
|
+
<path d="M36 40L20 24L36 8L40 12L28 24L40 36L36 40Z" fill="currentColor"/>
|
|
4
|
+
<path d="M12 8L28 24L12 40L8 36L20 24L8 12L12 8Z" fill="currentColor"/>
|
|
5
5
|
</svg>
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
<svg
|
|
1
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none"
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M6 8H42V13.9998H6V8ZM6 21H42V27H6V21ZM6 34.0002H42V40H6V34.0002Z" fill="currentColor"/>
|
|
4
|
+
</svg>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none"
|
|
2
2
|
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
-
<path d="
|
|
4
|
-
<path d="
|
|
3
|
+
<path d="M33 11L33 37H27L27 11L33 11Z" fill="currentColor"/>
|
|
4
|
+
<path d="M21 11L21 37H15L15 11L21 11Z" fill="currentColor"/>
|
|
5
5
|
</svg>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none"
|
|
2
2
|
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
-
<path d="
|
|
3
|
+
<path d="M37 24.0003L16 36.1247L16 11.876L37 24.0003Z" fill="currentColor"/>
|
|
4
4
|
</svg>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
<svg width="80" height="80" viewBox="0 0 80 80" fill="none"
|
|
2
2
|
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
-
<path d="
|
|
3
|
+
<path d="M31.8256 67.9366H8.3335V44.4446C8.3335 40.2118 8.75685 36.2612 9.60341 32.5927C10.5911 28.7832 12.002 25.4675 13.8362 22.6457C15.8115 19.8238 18.2807 17.5663 21.2436 15.8732C24.2066 14.1801 27.6633 13.3335 31.6139 13.3335V23.9155C29.2153 23.9155 27.24 24.5504 25.688 25.8203C24.136 26.949 22.8662 28.501 21.8785 30.4763C20.8909 32.4517 20.1854 34.7091 19.7621 37.2488C19.4799 39.6474 19.3388 42.046 19.3388 44.4446H31.8256V67.9366ZM70.5557 67.9366H47.0637V44.4446C47.0637 40.2118 47.4869 36.2612 48.3335 32.5927C49.3212 28.7832 50.7321 25.4675 52.5663 22.6457C54.5416 19.8238 57.0108 17.5663 59.9737 15.8732C62.9367 14.1801 66.3935 13.3335 70.3441 13.3335V23.9155C67.9455 23.9155 65.9701 24.5504 64.4181 25.8203C62.8661 26.949 61.5963 28.501 60.6086 30.4763C59.621 32.4517 58.9155 34.7091 58.4922 37.2488C58.21 39.6474 58.0689 42.046 58.0689 44.4446H70.5557V67.9366Z" fill="currentColor"/>
|
|
4
4
|
</svg>
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none"
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M8 21H40V27H8V21Z" fill="currentColor"/>
|
|
4
|
+
</svg>
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
<svg width="
|
|
1
|
+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none"
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M22 5C31.3888 5 39 12.6112 39 22C39 25.6106 37.8725 28.9569 35.9531 31.71L43.8496 39.6064L39.6064 43.8496L31.7109 35.9531C28.9578 37.8728 25.6109 39 22 39C12.6112 39 5 31.3888 5 22C5 12.6112 12.6112 5 22 5ZM22 11C15.9249 11 11 15.9249 11 22C11 28.0751 15.9249 33 22 33C28.0751 33 33 28.0751 33 22C33 15.9249 28.0751 11 22 11Z" fill="currentColor"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="32" height="32" viewBox="0 0 32 32" fill="none"
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M19.5175 11.5451L19.6298 11.7785L19.8857 11.8215L28.454 13.2482L22.0361 18.9543L21.8095 19.1555L21.8827 19.4494L24.0058 27.9426L16.2079 23.6887L15.9677 23.5588L15.7284 23.6887L7.92961 27.9426L10.0536 19.4494L10.1269 19.1555L9.90031 18.9543L3.48137 13.2482L12.0507 11.8215L12.3066 11.7785L12.4189 11.5451L15.9677 4.16132L19.5175 11.5451Z" stroke="currentColor"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import cx from "classnames";
|
|
2
|
+
import React, { HTMLAttributes } from "react";
|
|
3
|
+
|
|
4
|
+
import { Icon } from "../Icon";
|
|
5
|
+
|
|
6
|
+
const CLASS_ROOT = "avatar";
|
|
7
|
+
|
|
8
|
+
export interface AvatarProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
alt?: string;
|
|
10
|
+
iconName?: string;
|
|
11
|
+
src: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const Avatar: React.FC<AvatarProps> = ({
|
|
15
|
+
alt = "",
|
|
16
|
+
className,
|
|
17
|
+
iconName,
|
|
18
|
+
src,
|
|
19
|
+
...other
|
|
20
|
+
}) => {
|
|
21
|
+
const hasDecoration = Boolean(iconName);
|
|
22
|
+
const classes = cx(CLASS_ROOT, className);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className={classes} {...other}>
|
|
26
|
+
{hasDecoration && (
|
|
27
|
+
<span className={`${CLASS_ROOT}__icon`} aria-hidden="true">
|
|
28
|
+
<Icon name={iconName!} size="small" />
|
|
29
|
+
</span>
|
|
30
|
+
)}
|
|
31
|
+
<img className={`${CLASS_ROOT}__image`} src={src} alt={alt} />
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Avatar.displayName = "Avatar";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@use "sass:math";
|
|
2
|
+
@use "../../../styles/tools/convert";
|
|
3
|
+
|
|
4
|
+
$avatar-size: convert.to-rem(64px);
|
|
5
|
+
$badge-size: convert.to-rem(24px);
|
|
6
|
+
$badge-offset: convert.to-rem(4px);
|
|
7
|
+
$badge-top: -$badge-offset;
|
|
8
|
+
$badge-right: -$badge-offset;
|
|
9
|
+
$badge-anchor-x: math.div($badge-size, 2) - $badge-offset;
|
|
10
|
+
$badge-anchor-y: math.div($badge-size, 2) - $badge-offset;
|
|
11
|
+
$badge-cutout-radius: convert.to-rem(12px);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@use "./config";
|
|
2
|
+
|
|
3
|
+
@mixin base {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
width: config.$avatar-size;
|
|
7
|
+
height: config.$avatar-size;
|
|
8
|
+
flex-shrink: 0;
|
|
9
|
+
vertical-align: top;
|
|
10
|
+
border-radius: 50%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@mixin image {
|
|
14
|
+
display: block;
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
border-radius: 50%;
|
|
18
|
+
object-fit: cover;
|
|
19
|
+
object-position: center;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@mixin image-with-decoration {
|
|
23
|
+
-webkit-mask-image: radial-gradient(
|
|
24
|
+
circle at calc(100% - #{config.$badge-anchor-x}) #{config.$badge-anchor-y},
|
|
25
|
+
transparent #{config.$badge-cutout-radius},
|
|
26
|
+
black calc(#{config.$badge-cutout-radius} + 1px)
|
|
27
|
+
);
|
|
28
|
+
mask-image: radial-gradient(
|
|
29
|
+
circle at calc(100% - #{config.$badge-anchor-x}) #{config.$badge-anchor-y},
|
|
30
|
+
transparent #{config.$badge-cutout-radius},
|
|
31
|
+
black calc(#{config.$badge-cutout-radius} + 1px)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@mixin icon {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
width: config.$badge-size;
|
|
40
|
+
height: config.$badge-size;
|
|
41
|
+
background-color: transparent;
|
|
42
|
+
color: var(--color-icon-default);
|
|
43
|
+
line-height: 1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@mixin badge {
|
|
47
|
+
position: absolute;
|
|
48
|
+
top: config.$badge-top;
|
|
49
|
+
right: config.$badge-right;
|
|
50
|
+
z-index: 1;
|
|
51
|
+
width: config.$badge-size;
|
|
52
|
+
height: config.$badge-size;
|
|
53
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@use "./mixins";
|
|
2
|
+
|
|
3
|
+
@layer components {
|
|
4
|
+
.avatar {
|
|
5
|
+
@include mixins.base;
|
|
6
|
+
|
|
7
|
+
&__image {
|
|
8
|
+
@include mixins.image;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&__icon {
|
|
12
|
+
@include mixins.icon;
|
|
13
|
+
@include mixins.badge;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&__icon ~ &__image {
|
|
17
|
+
@include mixins.image-with-decoration;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { axe } from "vitest-axe";
|
|
3
|
+
|
|
4
|
+
import { Avatar } from "../";
|
|
5
|
+
|
|
6
|
+
const example = (
|
|
7
|
+
<Avatar
|
|
8
|
+
className="surface-secondary"
|
|
9
|
+
src="/avatar.png"
|
|
10
|
+
alt="Person avatar"
|
|
11
|
+
iconName="quote"
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
it("is valid html", () => {
|
|
16
|
+
const { container } = render(example);
|
|
17
|
+
expect(container).toHTMLValidate();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("is accessible", async () => {
|
|
21
|
+
const { container } = render(example);
|
|
22
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
23
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
|
|
3
|
+
import { Avatar } from "../Avatar";
|
|
4
|
+
|
|
5
|
+
describe("rendering Avatar", () => {
|
|
6
|
+
it("has default avatar class", () => {
|
|
7
|
+
const { getByTestId } = render(
|
|
8
|
+
<Avatar src="/avatar.png" alt="Person avatar" data-testid="test-id" />,
|
|
9
|
+
);
|
|
10
|
+
expect(getByTestId("test-id")).toHaveClass("avatar");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("renders image when src is set", () => {
|
|
14
|
+
const { getByAltText } = render(
|
|
15
|
+
<Avatar src="/avatar.png" alt="Person avatar" />,
|
|
16
|
+
);
|
|
17
|
+
expect(getByAltText("Person avatar")).toHaveAttribute("src", "/avatar.png");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("does not render decoration by default", () => {
|
|
21
|
+
const { container } = render(
|
|
22
|
+
<Avatar src="/avatar.png" alt="Person avatar" />,
|
|
23
|
+
);
|
|
24
|
+
expect(container.getElementsByClassName("avatar__icon").length).toBe(0);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("renders decoration when image and iconName are set", () => {
|
|
28
|
+
const { container } = render(
|
|
29
|
+
<Avatar src="/avatar.png" alt="Person avatar" iconName="quote" />,
|
|
30
|
+
);
|
|
31
|
+
expect(container.getElementsByClassName("avatar__icon").length).toBe(1);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("passes custom classes through", () => {
|
|
35
|
+
const { getByTestId } = render(
|
|
36
|
+
<Avatar
|
|
37
|
+
src="/avatar.png"
|
|
38
|
+
alt="Person avatar"
|
|
39
|
+
data-testid="test-id"
|
|
40
|
+
className="surface-secondary"
|
|
41
|
+
/>,
|
|
42
|
+
);
|
|
43
|
+
expect(getByTestId("test-id")).toHaveClass("surface-secondary");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
[style*="--color-fill"],
|
|
18
18
|
[style*="--color-surface"]
|
|
19
19
|
) {
|
|
20
|
-
border: 1px solid var(--color-border-
|
|
20
|
+
border: 1px solid var(--color-border-strong);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.background-accent {
|
|
24
|
+
border: 1px solid var(--color-border-accent);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
&.grid {
|
|
@@ -177,6 +177,19 @@ export default class Carousel {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
constructor(element: HTMLElement, config?: Partial<SwiperOptions>) {
|
|
180
|
+
const scrollbarEl = element.querySelector(
|
|
181
|
+
SELECTOR_SCROLLBAR,
|
|
182
|
+
) as HTMLElement | null;
|
|
183
|
+
const configScrollbar =
|
|
184
|
+
typeof config?.scrollbar === "object" && config.scrollbar !== null
|
|
185
|
+
? config.scrollbar
|
|
186
|
+
: undefined;
|
|
187
|
+
const defaultScrollbar =
|
|
188
|
+
typeof defaultConfig.scrollbar === "object" &&
|
|
189
|
+
defaultConfig.scrollbar !== null
|
|
190
|
+
? defaultConfig.scrollbar
|
|
191
|
+
: undefined;
|
|
192
|
+
|
|
180
193
|
this.element = element;
|
|
181
194
|
this.config = {
|
|
182
195
|
...defaultConfig,
|
|
@@ -184,9 +197,10 @@ export default class Carousel {
|
|
|
184
197
|
scrollbar: {
|
|
185
198
|
...((defaultConfig.scrollbar ?? {}) as object),
|
|
186
199
|
...((config?.scrollbar ?? {}) as object),
|
|
187
|
-
el:
|
|
188
|
-
|
|
189
|
-
|
|
200
|
+
el: scrollbarEl,
|
|
201
|
+
enabled: scrollbarEl
|
|
202
|
+
? (configScrollbar?.enabled ?? defaultScrollbar?.enabled)
|
|
203
|
+
: false,
|
|
190
204
|
},
|
|
191
205
|
};
|
|
192
206
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import cx from "classnames";
|
|
4
|
-
import React, { HTMLAttributes, ReactNode } from "react";
|
|
4
|
+
import React, { HTMLAttributes, ReactElement, ReactNode } from "react";
|
|
5
5
|
import { useStatic } from "@/utils/hooks";
|
|
6
|
-
import {
|
|
6
|
+
import { Controls } from "../Controls";
|
|
7
7
|
import CarouselStatic from "./Carousel.static";
|
|
8
8
|
import { CarouselItem } from "./CarouselItem";
|
|
9
9
|
import {
|
|
10
|
+
CLASS_CONTROLS,
|
|
10
11
|
CLASS_DOTS,
|
|
12
|
+
CLASS_NAVIGATION,
|
|
11
13
|
CLASS_NEXT,
|
|
12
14
|
CLASS_PREV,
|
|
13
15
|
CLASS_ROOT,
|
|
@@ -18,11 +20,15 @@ import {
|
|
|
18
20
|
CLASS_VIEWPORT_WRAPPER,
|
|
19
21
|
} from "./constants";
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
type CarouselRenderItem<T> = (item: T, index: number) => ReactNode;
|
|
24
|
+
|
|
25
|
+
interface CarouselProps<T = ReactNode> extends HTMLAttributes<HTMLDivElement> {
|
|
22
26
|
/** Swiper.js (https://swiperjs.com/) options object */
|
|
23
27
|
swiperOptions?: Record<string, any>;
|
|
24
28
|
/** Carousel items */
|
|
25
|
-
items:
|
|
29
|
+
items: T[];
|
|
30
|
+
/** Render carousel item content */
|
|
31
|
+
renderItems?: CarouselRenderItem<T>;
|
|
26
32
|
/** Always show scrollbar and hide dots */
|
|
27
33
|
showScrollbar?: boolean;
|
|
28
34
|
/** Make carousel bleed to the right edge of screen while keeping left aligned with container */
|
|
@@ -30,23 +36,37 @@ interface CarouselProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
30
36
|
className?: string;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
const
|
|
39
|
+
const isCarouselItemElement = (
|
|
40
|
+
item: ReactNode,
|
|
41
|
+
): item is ReactElement<React.ComponentProps<typeof CarouselItem>> =>
|
|
42
|
+
React.isValidElement(item) && item.type === CarouselItem;
|
|
43
|
+
|
|
44
|
+
const Carousel = <T,>({
|
|
34
45
|
className,
|
|
35
46
|
swiperOptions,
|
|
36
47
|
items,
|
|
48
|
+
renderItems,
|
|
37
49
|
showScrollbar = false,
|
|
38
50
|
bleedRight = false,
|
|
39
51
|
...other
|
|
40
|
-
}) => {
|
|
52
|
+
}: CarouselProps<T>) => {
|
|
41
53
|
const [carouselRef] = useStatic(CarouselStatic);
|
|
42
54
|
const { ["data-swiper-options"]: _dataSwiperOptionsAttr, ...domProps } =
|
|
43
55
|
other as HTMLAttributes<HTMLDivElement> & {
|
|
44
56
|
"data-swiper-options"?: string;
|
|
45
57
|
};
|
|
46
58
|
|
|
47
|
-
const carouselItems = items.map((item, i) =>
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
const carouselItems = items.map((item, i) => {
|
|
60
|
+
const content = renderItems ? renderItems(item, i) : (item as ReactNode);
|
|
61
|
+
|
|
62
|
+
if (isCarouselItemElement(content)) {
|
|
63
|
+
return React.cloneElement(content, {
|
|
64
|
+
key: content.key ?? i.toString(),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return <CarouselItem key={i.toString()}>{content}</CarouselItem>;
|
|
69
|
+
});
|
|
50
70
|
|
|
51
71
|
const classes = cx(CLASS_ROOT, className, {
|
|
52
72
|
[`${CLASS_ROOT}--scrollbar`]: showScrollbar,
|
|
@@ -54,9 +74,11 @@ const Carousel: React.FC<CarouselProps> = ({
|
|
|
54
74
|
});
|
|
55
75
|
|
|
56
76
|
const elementClasses = {
|
|
77
|
+
navigation: cx(CLASS_NAVIGATION),
|
|
78
|
+
controls: cx(CLASS_CONTROLS),
|
|
57
79
|
prev: cx(CLASS_PREV),
|
|
58
80
|
next: cx(CLASS_NEXT),
|
|
59
|
-
dots: cx(CLASS_DOTS
|
|
81
|
+
dots: cx(CLASS_DOTS),
|
|
60
82
|
};
|
|
61
83
|
|
|
62
84
|
const customSwiperOptions = showScrollbar
|
|
@@ -82,35 +104,36 @@ const Carousel: React.FC<CarouselProps> = ({
|
|
|
82
104
|
<div className={CLASS_VIEWPORT}>
|
|
83
105
|
<div className={CLASS_TRACK}>{carouselItems}</div>
|
|
84
106
|
</div>
|
|
85
|
-
{showScrollbar ? null : (
|
|
86
|
-
<>
|
|
87
|
-
<button
|
|
88
|
-
type="button"
|
|
89
|
-
aria-label="Naspäť"
|
|
90
|
-
className={elementClasses.prev}
|
|
91
|
-
>
|
|
92
|
-
<Icon size="medium" name="chevron-left" />
|
|
93
|
-
</button>
|
|
94
|
-
<button
|
|
95
|
-
type="button"
|
|
96
|
-
aria-label="Ďalej"
|
|
97
|
-
className={elementClasses.next}
|
|
98
|
-
>
|
|
99
|
-
<Icon size="medium" name="chevron-right" />
|
|
100
|
-
</button>
|
|
101
|
-
</>
|
|
102
|
-
)}
|
|
103
107
|
</div>
|
|
104
108
|
|
|
105
|
-
{!showScrollbar &&
|
|
109
|
+
{!showScrollbar && (
|
|
110
|
+
<div className={elementClasses.navigation}>
|
|
111
|
+
<div role="tablist" className={elementClasses.dots} />
|
|
112
|
+
<div className={elementClasses.controls}>
|
|
113
|
+
<Controls
|
|
114
|
+
className={elementClasses.prev}
|
|
115
|
+
icon="chevron-left"
|
|
116
|
+
aria-label="Naspäť"
|
|
117
|
+
/>
|
|
118
|
+
<Controls
|
|
119
|
+
className={elementClasses.next}
|
|
120
|
+
icon="chevron-right"
|
|
121
|
+
aria-label="Ďalej"
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
106
126
|
|
|
107
|
-
|
|
108
|
-
<div className={
|
|
109
|
-
|
|
127
|
+
{showScrollbar && (
|
|
128
|
+
<div className={CLASS_SCROLLBAR}>
|
|
129
|
+
<div className={CLASS_SCROLLBAR_DRAG} />
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
110
132
|
</div>
|
|
111
133
|
);
|
|
112
134
|
};
|
|
113
135
|
|
|
114
136
|
Carousel.displayName = "Carousel";
|
|
115
137
|
|
|
138
|
+
export type { CarouselProps };
|
|
116
139
|
export { Carousel };
|
|
@@ -9,6 +9,8 @@ export const CLASS_SLIDE_PREV = `${CLASS_ROOT}__slide-prev`;
|
|
|
9
9
|
export const CLASS_PREV = `${CLASS_ROOT}__prev`;
|
|
10
10
|
export const CLASS_NEXT = `${CLASS_ROOT}__next`;
|
|
11
11
|
export const CLASS_DOTS = `${CLASS_ROOT}__pagination`;
|
|
12
|
+
export const CLASS_NAVIGATION = `${CLASS_ROOT}__navigation`;
|
|
13
|
+
export const CLASS_CONTROLS = `${CLASS_ROOT}__controls`;
|
|
12
14
|
export const CLASS_DOT = `${CLASS_ROOT}__pagination-item`;
|
|
13
15
|
export const CLASS_SCROLLBAR = `${CLASS_ROOT}__scrollbar`;
|
|
14
16
|
export const CLASS_SCROLLBAR_HORIZONTAL = `${CLASS_ROOT}__scrollbar-horizontal`;
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
$space: space.get();
|
|
7
7
|
|
|
8
8
|
$dot-layout: (
|
|
9
|
-
width:
|
|
10
|
-
height:
|
|
11
|
-
margin:
|
|
9
|
+
width: convert.to-rem(10px),
|
|
10
|
+
height: convert.to-rem(10px),
|
|
11
|
+
margin: convert.to-rem(8px),
|
|
12
12
|
);
|
|
13
13
|
|
|
14
|
+
$navigation-gap: convert.to-rem(16px);
|
|
15
|
+
|
|
14
16
|
$dot: (
|
|
15
17
|
default: var(--color-icon-default),
|
|
16
18
|
hover: var(--color-icon-brand),
|
|
@@ -23,8 +25,3 @@ $breakout-buttons-breakpoints: (
|
|
|
23
25
|
(1340px, 1379px),
|
|
24
26
|
(1460px)
|
|
25
27
|
);
|
|
26
|
-
|
|
27
|
-
$viewport-horizontal-spacing: (
|
|
28
|
-
// button dimension + space - slide padding,
|
|
29
|
-
"md": convert.to-rem(50px)
|
|
30
|
-
);
|