@orangesk/orange-design-system 2.0.0-beta.46 → 2.0.0-beta.48
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/BlockAction/style.css +1 -1
- package/build/components/BlockAction/style.css.map +1 -1
- package/build/components/Breadcrumbs/style.css +1 -1
- package/build/components/Breadcrumbs/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/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/Icon/style.css +1 -1
- package/build/components/Icon/style.css.map +1 -1
- package/build/components/Link/style.css +1 -1
- package/build/components/Link/style.css.map +1 -1
- package/build/components/Loader/style.css +1 -1
- package/build/components/Loader/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/Pagination/style.css +1 -1
- package/build/components/Pagination/style.css.map +1 -1
- package/build/components/PromotionCard/style.css +1 -1
- package/build/components/PromotionCard/style.css.map +1 -1
- package/build/components/Section/style.css +1 -1
- package/build/components/Section/style.css.map +1 -1
- package/build/components/SocialButton/style.css +1 -1
- package/build/components/SocialButton/style.css.map +1 -1
- package/build/components/Stepbar/style.css +1 -1
- package/build/components/Stepbar/style.css.map +1 -1
- package/build/components/Table/style.css +1 -1
- package/build/components/Table/style.css.map +1 -1
- package/build/components/Tabs/style.css +1 -1
- package/build/components/Tabs/style.css.map +1 -1
- package/build/components/Tag/style.css +1 -1
- package/build/components/Tag/style.css.map +1 -1
- package/build/components/Tile/style.css +1 -1
- package/build/components/Tile/style.css.map +1 -1
- 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 +4 -15
- package/build/components/types/src/components/Carousel/Carousel.static.d.ts +4 -1
- package/build/components/types/src/components/Forms/Autocomplete/Autocomplete.static.d.ts +11 -0
- package/build/components/types/src/components/Forms/Group/Group.d.ts +1 -1
- package/build/components/types/src/components/Preview/CodeExample.d.ts +1 -0
- package/build/components/types/src/components/Preview/PreviewGenerator.d.ts +1 -0
- package/build/components/types/src/components/Preview/getElementDisplayName.d.ts +1 -0
- package/build/components/types/src/components/Tabs/Tabs.d.ts +0 -4
- package/build/components/types/src/components/Tabs/Tabs.static.d.ts +12 -0
- package/build/components/types/src/components/Tile/Tile.d.ts +3 -11
- 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/search-index.json +6 -6
- package/package.json +24 -24
- package/src/components/BlockAction/styles/style.scss +6 -4
- package/src/components/Breadcrumbs/styles/mixins.scss +15 -8
- package/src/components/Breadcrumbs/styles/style.scss +2 -1
- package/src/components/Carousel/Carousel.static.ts +29 -1
- package/src/components/Carousel/styles/mixins.scss +22 -2
- package/src/components/Carousel/tests/Carousel.static.test.jsx +50 -0
- package/src/components/DocumentationSidebar/DocumentationSidebar.tsx +21 -34
- package/src/components/DocumentationSidebar/styles/style.scss +0 -6
- package/src/components/Footer/styles/mixins.scss +2 -1
- package/src/components/Forms/Autocomplete/Autocomplete.static.ts +190 -14
- package/src/components/Forms/Autocomplete/styles/style.scss +61 -8
- package/src/components/Forms/Autocomplete/tests/Autocomplete.static.test.ts +187 -0
- package/src/components/Forms/Checkbox/styles/style.scss +13 -6
- package/src/components/Forms/DatePicker/styles/style.scss +1 -2
- package/src/components/Forms/Group/Group.tsx +4 -1
- package/src/components/Forms/Group/styles/config.scss +1 -1
- package/src/components/Forms/Group/styles/mixins.scss +17 -0
- package/src/components/Forms/Group/tests/Group.unit.test.jsx +9 -0
- package/src/components/Forms/InputStepper/styles/style.scss +15 -8
- package/src/components/Forms/TextArea/styles/config.scss +1 -0
- package/src/components/Forms/TextArea/styles/mixins.scss +7 -1
- package/src/components/Forms/TextInput/styles/config.scss +3 -1
- package/src/components/Forms/TextInput/styles/mixins.scss +7 -1
- package/src/components/Forms/TextInput/styles/style.scss +17 -12
- package/src/components/Forms/styles/config.scss +3 -2
- package/src/components/Icon/styles/style.scss +2 -1
- package/src/components/Link/styles/mixins.scss +0 -1
- package/src/components/Loader/styles/style.scss +0 -2
- package/src/components/Megamenu/Megamenu.tsx +2 -2
- package/src/components/Megamenu/MegamenuBlog.tsx +2 -2
- package/src/components/Megamenu/styles/mixins.scss +20 -12
- package/src/components/Pagination/styles/mixins.scss +8 -6
- package/src/components/Pagination/styles/style.scss +0 -4
- package/src/components/Preview/CodeExample.tsx +66 -25
- package/src/components/Preview/Preview.tsx +26 -13
- package/src/components/Preview/PreviewGenerator.tsx +72 -34
- package/src/components/Preview/getElementDisplayName.ts +25 -0
- package/src/components/PromotionCard/styles/mixins.scss +2 -1
- package/src/components/Section/styles/mixins.scss +27 -5
- package/src/components/SocialButton/styles/config.scss +2 -2
- package/src/components/Stepbar/styles/config.scss +34 -17
- package/src/components/Stepbar/styles/mixins.scss +5 -3
- package/src/components/Stepbar/styles/style.scss +4 -2
- package/src/components/Table/styles/mixins.scss +6 -3
- package/src/components/Tabs/Tabs.static.ts +157 -30
- package/src/components/Tabs/Tabs.tsx +62 -67
- package/src/components/Tabs/styles/config.scss +18 -25
- package/src/components/Tabs/styles/mixins.scss +93 -28
- package/src/components/Tabs/styles/style.scss +4 -15
- package/src/components/Tabs/tests/Tabs.unit.test.jsx +111 -0
- package/src/components/Tag/styles/config.scss +1 -1
- package/src/components/Tag/styles/style.scss +22 -5
- package/src/components/Tile/Tile.tsx +18 -42
- package/src/components/Tile/styles/mixins.scss +45 -47
- package/src/components/Tile/styles/style.scss +5 -17
- package/src/components/Tile/tests/Tile.unit.test.jsx +9 -78
- package/src/styles/base/globals.scss +2 -0
- package/src/styles/tokens/color-vars.scss +0 -2
- package/src/styles/utilities/color.scss +0 -153
- package/src/styles/utilities/horizontal-scroll.scss +7 -2
- package/src/styles/utilities/text.scss +0 -1
- package/src/components/Tile/CHANGELOG.md +0 -28
- package/src/components/Tile/styles/config.scss +0 -7
|
@@ -109,6 +109,15 @@ describe("rendering Group", () => {
|
|
|
109
109
|
);
|
|
110
110
|
expect(container.getElementsByClassName("select").length).toBe(1);
|
|
111
111
|
});
|
|
112
|
+
it("renders Autocomplete component (autocomplete class) when control type is set to autocomplete", () => {
|
|
113
|
+
const { container } = render(
|
|
114
|
+
<Group
|
|
115
|
+
data-testid="test-id"
|
|
116
|
+
control={{ type: "autocomplete", options: ["", "apple"] }}
|
|
117
|
+
/>,
|
|
118
|
+
);
|
|
119
|
+
expect(container.getElementsByClassName("autocomplete").length).toBe(1);
|
|
120
|
+
});
|
|
112
121
|
it("addonPrefix Item has class control-group__item--large when size is set to large", () => {
|
|
113
122
|
const { container } = render(
|
|
114
123
|
<Group
|
|
@@ -111,12 +111,17 @@
|
|
|
111
111
|
&--invalid {
|
|
112
112
|
.input-stepper__button,
|
|
113
113
|
.input-stepper__number,
|
|
114
|
-
.input-stepper__button--minus:hover:not(:disabled),
|
|
115
|
-
.input-stepper__button--plus:hover:not(:disabled),
|
|
116
114
|
.input-stepper__button--minus:active:not(:disabled),
|
|
117
115
|
.input-stepper__button--plus:active:not(:disabled) {
|
|
118
116
|
border-color: var(--color-border-negative);
|
|
119
117
|
}
|
|
118
|
+
|
|
119
|
+
@media (hover: hover) and (pointer: fine) {
|
|
120
|
+
.input-stepper__button--minus:hover:not(:disabled),
|
|
121
|
+
.input-stepper__button--plus:hover:not(:disabled) {
|
|
122
|
+
border-color: var(--color-border-negative);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
&__button--minus:disabled,
|
|
@@ -126,13 +131,15 @@
|
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
133
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
@media (hover: hover) and (pointer: fine) {
|
|
135
|
+
&__button--minus:hover:not(:disabled),
|
|
136
|
+
&__button--plus:hover:not(:disabled) {
|
|
137
|
+
background-color: var(--color-fill-contrast);
|
|
138
|
+
border-color: var(--color-fill-contrast);
|
|
133
139
|
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
&::before {
|
|
141
|
+
background-color: var(--color-fill-primary);
|
|
142
|
+
}
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
@include generate.css-map($config, "disabled");
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
&:read-only {
|
|
25
|
+
&:read-only:not(:disabled) {
|
|
26
26
|
@include generate.css-map($config, "readonly");
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
@include generate.css-map($config, "invalid");
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
&::placeholder {
|
|
34
|
+
@include generate.css-map($config, "placeholder");
|
|
35
|
+
|
|
36
|
+
opacity: 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
&.is-valid {
|
|
34
40
|
padding-right: 36px;
|
|
35
41
|
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 15 15'%3E%3Cpath d='M7.5,15 C3.35786438,15 0,11.6421356 0,7.5 C0,3.35786438 3.35786438,0 7.5,0 C11.6421356,0 15,3.35786438 15,7.5 C15,11.6421356 11.6421356,15 7.5,15 Z M3.40550597,6.68901229 C2.99100286,7.0539857 2.95085113,7.6858763 3.31582458,8.1003794 L5.77477826,10.8930318 C6.1397517,11.3075349 6.7716423,11.3476866 7.18614541,10.9827132 C7.20478962,10.9662968 7.22281563,10.9491914 7.24018594,10.9314326 L11.8941565,6.17336831 C12.2803381,5.7785491 12.2733359,5.14542284 11.8785167,4.75924123 C11.4836975,4.37305961 10.8505712,4.38006176 10.4643896,4.77488097 L7.31720124,7.9924615 C6.93101963,8.3872807 6.29789337,8.3942828 5.90307416,8.0081012 C5.88531533,7.9907309 5.86820993,7.9727049 5.85179355,7.9540607 L4.81687313,6.77869369 C4.45189969,6.36419058 3.82000909,6.32403885 3.40550597,6.68901229 Z' fill='%2332c832' /%3E%3C/svg%3E");
|
|
@@ -25,6 +25,7 @@ $states: (
|
|
|
25
25
|
disabled: commonConfig.$disabled,
|
|
26
26
|
readonly: commonConfig.$readonly,
|
|
27
27
|
invalid: commonConfig.$invalid,
|
|
28
|
+
placeholder: commonConfig.$placeholder,
|
|
28
29
|
);
|
|
29
30
|
|
|
30
31
|
$sizes: (
|
|
@@ -57,4 +58,5 @@ $widths: (
|
|
|
57
58
|
),
|
|
58
59
|
);
|
|
59
60
|
|
|
60
|
-
$background-image-search-icon: url('data:image/svg+xml,<svg
|
|
61
|
+
$background-image-search-icon: url('data:image/svg+xml,<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.5 0C13.1944 1.026e-07 17 3.80558 17 8.5C17 10.3053 16.4363 11.9785 15.4766 13.355L19.4248 17.3032L17.3032 19.4248L13.3555 15.4766C11.9789 16.4364 10.3054 17 8.5 17C3.80558 17 -1.026e-07 13.1944 0 8.5C1.026e-07 3.80558 3.80558 -1.026e-07 8.5 0ZM8.5 3C5.46243 3 3 5.46243 3 8.5C3 11.5376 5.46243 14 8.5 14C11.5376 14 14 11.5376 14 8.5C14 5.46243 11.5376 3 8.5 3Z" fill="%23F15E00"/></svg>');
|
|
62
|
+
$mask-image-search-icon: url('data:image/svg+xml,<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.5 0C13.1944 1.026e-07 17 3.80558 17 8.5C17 10.3053 16.4363 11.9785 15.4766 13.355L19.4248 17.3032L17.3032 19.4248L13.3555 15.4766C11.9789 16.4364 10.3054 17 8.5 17C3.80558 17 -1.026e-07 13.1944 0 8.5C1.026e-07 3.80558 3.80558 -1.026e-07 8.5 0ZM8.5 3C5.46243 3 3 5.46243 3 8.5C3 11.5376 5.46243 14 8.5 14C11.5376 14 14 11.5376 14 8.5C14 5.46243 11.5376 3 8.5 3Z" fill="%23000"/></svg>');
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
@include generate.css-map($config, "disabled");
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
&:read-only {
|
|
27
|
+
&:read-only:not(:disabled) {
|
|
28
28
|
@include generate.css-map($config, "readonly");
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
@include generate.css-map($config, "invalid");
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
&::placeholder {
|
|
36
|
+
@include generate.css-map($config, "placeholder");
|
|
37
|
+
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
&.is-valid {
|
|
36
42
|
padding-right: convert.to-rem(36px);
|
|
37
43
|
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 15 15'%3E%3Cpath d='M7.5,15 C3.35786438,15 0,11.6421356 0,7.5 C0,3.35786438 3.35786438,0 7.5,0 C11.6421356,0 15,3.35786438 15,7.5 C15,11.6421356 11.6421356,15 7.5,15 Z M3.40550597,6.68901229 C2.99100286,7.0539857 2.95085113,7.6858763 3.31582458,8.1003794 L5.77477826,10.8930318 C6.1397517,11.3075349 6.7716423,11.3476866 7.18614541,10.9827132 C7.20478962,10.9662968 7.22281563,10.9491914 7.24018594,10.9314326 L11.8941565,6.17336831 C12.2803381,5.7785491 12.2733359,5.14542284 11.8785167,4.75924123 C11.4836975,4.37305961 10.8505712,4.38006176 10.4643896,4.77488097 L7.31720124,7.9924615 C6.93101963,8.3872807 6.29789337,8.3942828 5.90307416,8.0081012 C5.88531533,7.9907309 5.86820993,7.9727049 5.85179355,7.9540607 L4.81687313,6.77869369 C4.45189969,6.36419058 3.82000909,6.32403885 3.40550597,6.68901229 Z' fill='%2332c832' /%3E%3C/svg%3E");
|
|
@@ -38,29 +38,34 @@
|
|
|
38
38
|
content: "";
|
|
39
39
|
position: absolute;
|
|
40
40
|
top: 50%;
|
|
41
|
-
left: 0.
|
|
41
|
+
left: 0.625rem;
|
|
42
42
|
width: 1.25rem;
|
|
43
43
|
height: 1.25rem;
|
|
44
44
|
transform: translateY(-50%);
|
|
45
|
-
background-
|
|
46
|
-
|
|
45
|
+
background-color: var(--color-icon-brand);
|
|
46
|
+
mask-image: config.$mask-image-search-icon;
|
|
47
|
+
mask-position: center;
|
|
48
|
+
mask-repeat: no-repeat;
|
|
49
|
+
mask-size: contain;
|
|
47
50
|
pointer-events: none;
|
|
48
51
|
z-index: 1;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
> .text-input {
|
|
52
|
-
background-
|
|
53
|
-
padding-left: 2.5rem;
|
|
54
|
+
&:has(> .text-input:not(:placeholder-shown))::before {
|
|
55
|
+
background-color: var(--color-icon-default);
|
|
54
56
|
}
|
|
55
|
-
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
opacity: 0;
|
|
58
|
+
&:has(> .text-input:disabled)::before {
|
|
59
|
+
background-color: var(--color-icon-disabled);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
&:has(> .text-input
|
|
63
|
-
|
|
62
|
+
&:has(> .text-input.is-invalid)::before {
|
|
63
|
+
background-color: var(--color-icon-negative);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
> .text-input {
|
|
67
|
+
background-image: none !important;
|
|
68
|
+
padding-left: 2.5rem;
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
71
|
}
|
|
@@ -15,7 +15,7 @@ $focus: (
|
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
$disabled: (
|
|
18
|
-
background-color:
|
|
18
|
+
background-color: transparent,
|
|
19
19
|
border-color: var(--color-border-strong),
|
|
20
20
|
color: var(--color-text-secondary),
|
|
21
21
|
);
|
|
@@ -25,7 +25,7 @@ $disabled-checked: (
|
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
$readonly: (
|
|
28
|
-
background-color:
|
|
28
|
+
background-color: transparent,
|
|
29
29
|
color: var(--color-text-secondary),
|
|
30
30
|
);
|
|
31
31
|
|
|
@@ -35,6 +35,7 @@ $invalid: (
|
|
|
35
35
|
|
|
36
36
|
$placeholder: (
|
|
37
37
|
color: var(--color-text-secondary),
|
|
38
|
+
font-weight: bold,
|
|
38
39
|
);
|
|
39
40
|
|
|
40
41
|
$radiocheck-sizes: (
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
@include mixins.size(large);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.bg-orange &,
|
|
17
16
|
.surface-secondary &,
|
|
18
17
|
.surface-tertiary & {
|
|
19
18
|
@include mixins.color-inverse();
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
&__line {
|
|
24
23
|
@include mixins.line-base;
|
|
25
24
|
|
|
26
|
-
.bg-orange &,
|
|
27
25
|
.surface-secondary &,
|
|
28
26
|
.surface-tertiary & {
|
|
29
27
|
@include mixins.line-color-inverse();
|
|
@@ -414,9 +414,9 @@ export const Megamenu = ({
|
|
|
414
414
|
aria-labelledby={ids.mobileMainTitleId}
|
|
415
415
|
aria-hidden="true"
|
|
416
416
|
>
|
|
417
|
-
<
|
|
417
|
+
<span id={ids.mobileMainTitleId} className="sr-only">
|
|
418
418
|
Hlavné menu
|
|
419
|
-
</
|
|
419
|
+
</span>
|
|
420
420
|
<button
|
|
421
421
|
aria-label="Zatvoriť menu"
|
|
422
422
|
className={CLASS_MOBILE_OVERLAY}
|
|
@@ -325,9 +325,9 @@ export const MegamenuBlog = ({
|
|
|
325
325
|
aria-labelledby={ids.mobileMainTitleId}
|
|
326
326
|
aria-hidden="true"
|
|
327
327
|
>
|
|
328
|
-
<
|
|
328
|
+
<span id={ids.mobileMainTitleId} className="sr-only">
|
|
329
329
|
Hlavné menu
|
|
330
|
-
</
|
|
330
|
+
</span>
|
|
331
331
|
<button
|
|
332
332
|
aria-label="Zatvoriť menu"
|
|
333
333
|
className={CLASS_MOBILE_OVERLAY}
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
font-size: inherit;
|
|
60
60
|
text-decoration: underline;
|
|
61
61
|
text-underline-offset: convert.to-rem(2px);
|
|
62
|
-
text-decoration-thickness:
|
|
62
|
+
text-decoration-thickness: auto;
|
|
63
63
|
|
|
64
64
|
&:hover,
|
|
65
65
|
&:focus,
|
|
@@ -630,7 +630,8 @@
|
|
|
630
630
|
@mixin mobile-account-logout {
|
|
631
631
|
display: inline-block;
|
|
632
632
|
text-decoration: underline;
|
|
633
|
-
text-underline-offset: convert.to-rem(
|
|
633
|
+
text-underline-offset: convert.to-rem(2px);
|
|
634
|
+
text-decoration-thickness: auto;
|
|
634
635
|
margin-bottom: convert.to-rem(20px);
|
|
635
636
|
font-weight: 400 !important;
|
|
636
637
|
}
|
|
@@ -665,8 +666,15 @@
|
|
|
665
666
|
}
|
|
666
667
|
|
|
667
668
|
@mixin mobile-account-link {
|
|
668
|
-
text-decoration:
|
|
669
|
-
|
|
669
|
+
text-decoration: none !important;
|
|
670
|
+
|
|
671
|
+
&:hover,
|
|
672
|
+
&:focus,
|
|
673
|
+
&:active {
|
|
674
|
+
text-decoration: underline !important;
|
|
675
|
+
text-underline-offset: convert.to-rem(2px);
|
|
676
|
+
text-decoration-thickness: auto;
|
|
677
|
+
}
|
|
670
678
|
}
|
|
671
679
|
|
|
672
680
|
@mixin container {
|
|
@@ -696,7 +704,7 @@
|
|
|
696
704
|
a:focus {
|
|
697
705
|
text-decoration: underline;
|
|
698
706
|
text-underline-offset: convert.to-rem(2px);
|
|
699
|
-
text-decoration-thickness:
|
|
707
|
+
text-decoration-thickness: auto;
|
|
700
708
|
}
|
|
701
709
|
|
|
702
710
|
@include breakpoint.get("md", "down") {
|
|
@@ -709,19 +717,15 @@
|
|
|
709
717
|
}
|
|
710
718
|
|
|
711
719
|
@mixin text-large {
|
|
712
|
-
font-size: convert.to-rem(
|
|
720
|
+
font-size: convert.to-rem(28px) !important;
|
|
721
|
+
line-height: convert.to-rem(32px);
|
|
713
722
|
font-weight: 700;
|
|
714
|
-
line-height: convert.to-rem(22px);
|
|
715
|
-
|
|
716
|
-
@include breakpoint.get("md", "down") {
|
|
717
|
-
font-size: convert.to-rem(24px) !important;
|
|
718
|
-
line-height: convert.to-rem(28px);
|
|
719
|
-
}
|
|
720
723
|
}
|
|
721
724
|
|
|
722
725
|
@mixin caption {
|
|
723
726
|
@include generate.css-map(typographyConfig.$caption, "default");
|
|
724
727
|
margin-top: 0;
|
|
728
|
+
margin-bottom: convert.to-rem(20px);
|
|
725
729
|
}
|
|
726
730
|
|
|
727
731
|
@mixin caption-large {
|
|
@@ -817,6 +821,10 @@
|
|
|
817
821
|
@mixin accordion {
|
|
818
822
|
@include accordion.base;
|
|
819
823
|
margin-bottom: 0px !important;
|
|
824
|
+
|
|
825
|
+
a {
|
|
826
|
+
text-decoration: none !important;
|
|
827
|
+
}
|
|
820
828
|
}
|
|
821
829
|
|
|
822
830
|
@mixin accordion-item {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
@mixin base() {
|
|
9
9
|
@include typoMixins.list-unstyled();
|
|
10
10
|
|
|
11
|
+
gap: convert.to-rem(7px);
|
|
11
12
|
display: flex;
|
|
12
13
|
max-width: none;
|
|
13
14
|
margin-bottom: space.get("large");
|
|
@@ -17,24 +18,25 @@
|
|
|
17
18
|
font-weight: bold;
|
|
18
19
|
height: 50%;
|
|
19
20
|
align-self: center;
|
|
21
|
+
margin: 0 convert.to-rem(10px);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
@mixin item() {
|
|
23
|
-
margin-right: space.get("small");
|
|
24
25
|
margin-bottom: 0;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
@mixin last-item() {
|
|
28
|
-
margin-right: 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
28
|
@mixin link() {
|
|
32
|
-
border-radius:
|
|
29
|
+
border-radius: convert.to-rem(5px);
|
|
33
30
|
margin-bottom: 0;
|
|
34
31
|
background-color: var(--color-background-primary);
|
|
32
|
+
|
|
35
33
|
&:hover {
|
|
36
34
|
background-color: var(--color-background-contrast);
|
|
37
35
|
}
|
|
36
|
+
|
|
37
|
+
&:active {
|
|
38
|
+
background-color: var(--color-surface-tertiary);
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
@mixin link-active() {
|
|
@@ -6,16 +6,78 @@ import unescape from "unescape-html";
|
|
|
6
6
|
import { formatHTML } from "../../utils/formatCode";
|
|
7
7
|
import { Button } from "../Button";
|
|
8
8
|
import Code from "../Code/";
|
|
9
|
+
import { getElementDisplayName } from "./getElementDisplayName";
|
|
9
10
|
|
|
10
11
|
interface CodeExampleProps {
|
|
11
12
|
codeJSXOptions?: Record<string, any>;
|
|
12
13
|
codeTypes?: string[];
|
|
13
14
|
children?: ReactNode;
|
|
15
|
+
htmlThemeClass?: string;
|
|
14
16
|
jsxCode?: string; // Pre-generated JSX string (from server-side PreviewAuto)
|
|
15
17
|
htmlCode?: ReactNode; // Code for HTML rendering
|
|
16
18
|
[key: string]: any;
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
const addClassToOpeningTag = (tag: string, className: string): string => {
|
|
22
|
+
if (tag.includes(' class="')) {
|
|
23
|
+
return tag.replace(/ class="([^"]*)"/, (_, existingClassName) => {
|
|
24
|
+
const mergedClassName = [existingClassName, className]
|
|
25
|
+
.filter(Boolean)
|
|
26
|
+
.join(" ");
|
|
27
|
+
return ` class="${mergedClassName}"`;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return tag.replace(/^<([\w-]+)/, `<$1 class="${className}"`);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const applyThemeClassToMarkup = (
|
|
35
|
+
markup: string,
|
|
36
|
+
themeClass?: string,
|
|
37
|
+
wrapMultipleRoots = false,
|
|
38
|
+
): string => {
|
|
39
|
+
if (!themeClass || !markup.trim()) {
|
|
40
|
+
return markup;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (wrapMultipleRoots) {
|
|
44
|
+
return `<div class="${themeClass}">${markup}</div>`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return markup.replace(/^<[^>]+>/, (openingTag) =>
|
|
48
|
+
addClassToOpeningTag(openingTag, themeClass),
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const renderMarkupToHtml = (markup: ReactNode, themeClass?: string): string => {
|
|
53
|
+
if (!markup) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (typeof markup === "string") {
|
|
58
|
+
return markup;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (Array.isArray(markup)) {
|
|
62
|
+
const renderedMarkup = markup
|
|
63
|
+
.map((markupItem) =>
|
|
64
|
+
renderToStaticMarkup(markupItem as React.ReactElement),
|
|
65
|
+
)
|
|
66
|
+
.join("");
|
|
67
|
+
|
|
68
|
+
return applyThemeClassToMarkup(
|
|
69
|
+
renderedMarkup,
|
|
70
|
+
themeClass,
|
|
71
|
+
markup.length > 1,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return applyThemeClassToMarkup(
|
|
76
|
+
renderToStaticMarkup(markup as React.ReactElement),
|
|
77
|
+
themeClass,
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
19
81
|
/**
|
|
20
82
|
* Remove props that are undefined or null
|
|
21
83
|
* Don't show React.Fragment in code example
|
|
@@ -68,25 +130,7 @@ const getJSXAsStringFromMarkup = (
|
|
|
68
130
|
showDefaultProps: false,
|
|
69
131
|
showFunctions: true,
|
|
70
132
|
functionValue: (fn: any) => fn.name,
|
|
71
|
-
displayName:
|
|
72
|
-
// Try to get display name from various sources
|
|
73
|
-
if (ReactElement.props && ReactElement.props.mdxType) {
|
|
74
|
-
return ReactElement.props.mdxType;
|
|
75
|
-
}
|
|
76
|
-
if (ReactElement.type && ReactElement.type.displayName) {
|
|
77
|
-
return ReactElement.type.displayName;
|
|
78
|
-
}
|
|
79
|
-
if (ReactElement.type && ReactElement.type.name) {
|
|
80
|
-
return ReactElement.type.name;
|
|
81
|
-
}
|
|
82
|
-
if (typeof ReactElement.type === "string") {
|
|
83
|
-
return ReactElement.type;
|
|
84
|
-
}
|
|
85
|
-
// Fallback to type name or 'Component'
|
|
86
|
-
return (
|
|
87
|
-
ReactElement.type?.displayName || ReactElement.type?.name || "Component"
|
|
88
|
-
);
|
|
89
|
-
},
|
|
133
|
+
displayName: getElementDisplayName,
|
|
90
134
|
filterProps: ["mdxType", "originalType", ...filterProps],
|
|
91
135
|
...otherOptions,
|
|
92
136
|
};
|
|
@@ -124,6 +168,7 @@ const CodeExample: React.FC<CodeExampleProps> = ({
|
|
|
124
168
|
children,
|
|
125
169
|
codeJSXOptions,
|
|
126
170
|
codeTypes = ["html", "jsx"],
|
|
171
|
+
htmlThemeClass,
|
|
127
172
|
jsxCode,
|
|
128
173
|
htmlCode,
|
|
129
174
|
...other
|
|
@@ -184,18 +229,14 @@ const CodeExample: React.FC<CodeExampleProps> = ({
|
|
|
184
229
|
typeof htmlCode === "string"
|
|
185
230
|
? unescape(htmlCode)
|
|
186
231
|
: unescape(
|
|
187
|
-
formatHTML(
|
|
188
|
-
renderToStaticMarkup(htmlCode as React.ReactElement),
|
|
189
|
-
),
|
|
232
|
+
formatHTML(renderMarkupToHtml(htmlCode, htmlThemeClass)),
|
|
190
233
|
);
|
|
191
234
|
} else {
|
|
192
235
|
codeToShow =
|
|
193
236
|
typeof children === "string"
|
|
194
237
|
? unescape(children)
|
|
195
238
|
: unescape(
|
|
196
|
-
formatHTML(
|
|
197
|
-
renderToStaticMarkup(children as React.ReactElement),
|
|
198
|
-
),
|
|
239
|
+
formatHTML(renderMarkupToHtml(children, htmlThemeClass)),
|
|
199
240
|
);
|
|
200
241
|
}
|
|
201
242
|
break;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import reactElementToJSXString from "react-element-to-jsx-string";
|
|
6
|
+
import { getElementDisplayName } from "./getElementDisplayName";
|
|
6
7
|
import { PreviewGenerator } from "./PreviewGenerator";
|
|
7
8
|
|
|
8
9
|
type PreviewProps = React.ComponentProps<typeof PreviewGenerator> & {
|
|
@@ -51,21 +52,27 @@ export function Preview({
|
|
|
51
52
|
codeTypes = ["html", "jsx"],
|
|
52
53
|
...rest
|
|
53
54
|
}: PreviewProps) {
|
|
55
|
+
const normalizedChildren = React.Children.toArray(children);
|
|
56
|
+
const normalizedCode =
|
|
57
|
+
rest.code == null
|
|
58
|
+
? undefined
|
|
59
|
+
: typeof rest.code === "string" || typeof rest.code === "function"
|
|
60
|
+
? rest.code
|
|
61
|
+
: React.Children.toArray(rest.code);
|
|
62
|
+
const jsxSource =
|
|
63
|
+
normalizedCode &&
|
|
64
|
+
typeof normalizedCode !== "string" &&
|
|
65
|
+
typeof normalizedCode !== "function"
|
|
66
|
+
? normalizedCode
|
|
67
|
+
: normalizedChildren;
|
|
68
|
+
const hasMultipleCodeRoots = React.Children.count(jsxSource) > 1;
|
|
69
|
+
|
|
54
70
|
// Generate JSX string on server
|
|
55
|
-
const jsxCode = generateJSXString(
|
|
71
|
+
const jsxCode = generateJSXString(jsxSource, {
|
|
56
72
|
showDefaultProps: false,
|
|
57
73
|
showFunctions: true,
|
|
58
74
|
functionValue: (fn: any) => fn.name || "Function",
|
|
59
|
-
displayName:
|
|
60
|
-
// More robust display name handling
|
|
61
|
-
if (!el) return "Unknown";
|
|
62
|
-
return (
|
|
63
|
-
el?.props?.mdxType ||
|
|
64
|
-
el?.type?.displayName ||
|
|
65
|
-
el?.type?.name ||
|
|
66
|
-
(typeof el?.type === "string" ? el.type : "Component")
|
|
67
|
-
);
|
|
68
|
-
},
|
|
75
|
+
displayName: getElementDisplayName,
|
|
69
76
|
filterProps: ["mdxType", "originalType"],
|
|
70
77
|
useBooleanShorthandSyntax: false,
|
|
71
78
|
sortProps: false,
|
|
@@ -74,8 +81,14 @@ export function Preview({
|
|
|
74
81
|
|
|
75
82
|
// Pass the pre-generated JSX code to PreviewGenerator
|
|
76
83
|
return (
|
|
77
|
-
<PreviewGenerator
|
|
78
|
-
{
|
|
84
|
+
<PreviewGenerator
|
|
85
|
+
{...rest}
|
|
86
|
+
code={normalizedCode}
|
|
87
|
+
hasMultipleCodeRoots={hasMultipleCodeRoots}
|
|
88
|
+
jsxCode={jsxCode}
|
|
89
|
+
codeTypes={codeTypes}
|
|
90
|
+
>
|
|
91
|
+
{normalizedChildren}
|
|
79
92
|
</PreviewGenerator>
|
|
80
93
|
);
|
|
81
94
|
}
|