@orangesk/orange-design-system 2.0.0-beta.46 → 2.0.0-beta.47
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/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/Footer/style.css +1 -1
- package/build/components/Footer/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/Megamenu/style.css +1 -1
- package/build/components/Megamenu/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/Tabs/style.css +1 -1
- package/build/components/Tabs/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 +0 -4
- 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/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/utilities.css +1 -1
- package/build/lib/utilities.css.map +1 -1
- package/build/search-index.json +2 -2
- package/package.json +12 -12
- package/src/components/Breadcrumbs/styles/mixins.scss +15 -8
- package/src/components/Carousel/styles/mixins.scss +22 -2
- package/src/components/Footer/styles/mixins.scss +2 -1
- package/src/components/Forms/Checkbox/styles/style.scss +13 -6
- package/src/components/Forms/InputStepper/styles/style.scss +15 -8
- package/src/components/Link/styles/mixins.scss +0 -1
- 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/Preview/CodeExample.tsx +66 -25
- package/src/components/Preview/Preview.tsx +26 -13
- package/src/components/Preview/PreviewGenerator.tsx +57 -32
- package/src/components/Preview/getElementDisplayName.ts +25 -0
- package/src/components/Stepbar/styles/config.scss +34 -17
- package/src/components/Stepbar/styles/mixins.scss +5 -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/styles/base/globals.scss +2 -0
- package/src/styles/utilities/horizontal-scroll.scss +7 -2
- package/src/styles/utilities/text.scss +0 -1
|
@@ -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
|
|
|
@@ -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 {
|
|
@@ -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
|
}
|
|
@@ -17,6 +17,7 @@ import { Card } from "../Card";
|
|
|
17
17
|
import { Dropdown, DropdownItem } from "../Dropdown";
|
|
18
18
|
import { Icon } from "../Icon";
|
|
19
19
|
import CodeExample from "./CodeExample";
|
|
20
|
+
import { getElementDisplayName } from "./getElementDisplayName";
|
|
20
21
|
import PreviewTitleBar from "./PreviewTitleBar";
|
|
21
22
|
|
|
22
23
|
import "./styles/style.scss";
|
|
@@ -32,16 +33,7 @@ const generateJSXString = (
|
|
|
32
33
|
showDefaultProps: false,
|
|
33
34
|
showFunctions: true,
|
|
34
35
|
functionValue: (fn: any) => fn.name || "Function",
|
|
35
|
-
displayName:
|
|
36
|
-
// More robust display name handling
|
|
37
|
-
if (!el) return "Unknown";
|
|
38
|
-
return (
|
|
39
|
-
el?.props?.mdxType ||
|
|
40
|
-
el?.type?.displayName ||
|
|
41
|
-
el?.type?.name ||
|
|
42
|
-
(typeof el?.type === "string" ? el.type : "Component")
|
|
43
|
-
);
|
|
44
|
-
},
|
|
36
|
+
displayName: getElementDisplayName,
|
|
45
37
|
filterProps: ["mdxType", "originalType"],
|
|
46
38
|
useBooleanShorthandSyntax: false,
|
|
47
39
|
sortProps: false,
|
|
@@ -116,7 +108,6 @@ const PREVIEW_BREAKPOINTS: PreviewBreakpoint[] = [
|
|
|
116
108
|
];
|
|
117
109
|
|
|
118
110
|
const IFRAME_VIEWPORT_GUTTER = 16;
|
|
119
|
-
|
|
120
111
|
const getScreenLikeMinHeight = (width: number | null): number => {
|
|
121
112
|
if (width === null) {
|
|
122
113
|
return 1;
|
|
@@ -284,6 +275,7 @@ interface PreviewProps {
|
|
|
284
275
|
codeTypes?: string[];
|
|
285
276
|
enableFullscreen?: boolean;
|
|
286
277
|
hasCodePreview?: boolean;
|
|
278
|
+
hasMultipleCodeRoots?: boolean;
|
|
287
279
|
html?: string;
|
|
288
280
|
jsxCode?: string; // Pre-generated JSX string (from server component)
|
|
289
281
|
disableBreakpoints?: boolean;
|
|
@@ -344,6 +336,7 @@ const PreviewGenerator: FunctionComponent<PreviewProps> = ({
|
|
|
344
336
|
codeTypes = ["html", "jsx"],
|
|
345
337
|
enableFullscreen = true,
|
|
346
338
|
hasCodePreview = true,
|
|
339
|
+
hasMultipleCodeRoots = false,
|
|
347
340
|
html,
|
|
348
341
|
jsxCode,
|
|
349
342
|
isDark = false,
|
|
@@ -419,6 +412,33 @@ const PreviewGenerator: FunctionComponent<PreviewProps> = ({
|
|
|
419
412
|
|
|
420
413
|
const themeClass = isDarkMode ? "is-dark" : "is-light";
|
|
421
414
|
const bgClass = getBgClassFromName(previewBackground.label);
|
|
415
|
+
const applyThemeClassToJsxCode = (value?: string): string | undefined => {
|
|
416
|
+
if (!value) return value;
|
|
417
|
+
|
|
418
|
+
const trimmedValue = value.trim();
|
|
419
|
+
if (!trimmedValue) return trimmedValue;
|
|
420
|
+
|
|
421
|
+
if (hasMultipleCodeRoots) {
|
|
422
|
+
return `<div className="${themeClass}">\n${trimmedValue}\n</div>`;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return trimmedValue.replace(
|
|
426
|
+
/^<([A-Za-z][\w.]*)((?:\s+[\s\S]*?)?)\s*(\/?)>/,
|
|
427
|
+
(_, tagName: string, rawAttrs = "", selfClosing = "") => {
|
|
428
|
+
const attrs = rawAttrs || "";
|
|
429
|
+
|
|
430
|
+
if (/\sclassName=/.test(attrs)) {
|
|
431
|
+
return `<${tagName}${attrs.replace(
|
|
432
|
+
/className=(['"])(.*?)\1/,
|
|
433
|
+
(_match: string, quote: string, className: string) =>
|
|
434
|
+
`className=${quote}${className} ${themeClass}${quote}`,
|
|
435
|
+
)}${selfClosing ? " /" : ""}>`;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return `<${tagName}${attrs}\n className="${themeClass}"${selfClosing ? " /" : ""}>`;
|
|
439
|
+
},
|
|
440
|
+
);
|
|
441
|
+
};
|
|
422
442
|
|
|
423
443
|
const classes = cx(CLASS_ROOT, themeClass, bgClass, className);
|
|
424
444
|
const wrapperClasses = cx("previewWrapper", {
|
|
@@ -534,28 +554,36 @@ const PreviewGenerator: FunctionComponent<PreviewProps> = ({
|
|
|
534
554
|
? children(renderAsFunctionContext)
|
|
535
555
|
: children;
|
|
536
556
|
|
|
537
|
-
|
|
538
|
-
const wrapComponentWithTheme = (component: ReactNode) => {
|
|
557
|
+
const wrapRenderedComponentWithTheme = (component: ReactNode) => {
|
|
539
558
|
if (!component) return component;
|
|
540
559
|
|
|
541
|
-
//
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const existingClassName = props.className || "";
|
|
545
|
-
const newClassName = cx(existingClassName, themeClass);
|
|
560
|
+
// Keep wrapper shape stable across SSR/hydration and avoid cloning RSC children.
|
|
561
|
+
return <div className={cx(themeClass)}>{component}</div>;
|
|
562
|
+
};
|
|
546
563
|
|
|
547
|
-
|
|
564
|
+
const wrapCodeWithTheme = (component: ReactNode) => {
|
|
565
|
+
if (!component) return component;
|
|
566
|
+
|
|
567
|
+
const normalizedChildren = React.Children.toArray(component);
|
|
568
|
+
|
|
569
|
+
if (
|
|
570
|
+
normalizedChildren.length === 1 &&
|
|
571
|
+
React.isValidElement(normalizedChildren[0])
|
|
572
|
+
) {
|
|
573
|
+
const element = normalizedChildren[0] as React.ReactElement<any>;
|
|
574
|
+
const props = element.props as { className?: string };
|
|
575
|
+
|
|
576
|
+
return React.cloneElement(element, {
|
|
548
577
|
...props,
|
|
549
|
-
className:
|
|
550
|
-
}
|
|
578
|
+
className: cx(props.className, themeClass),
|
|
579
|
+
});
|
|
551
580
|
}
|
|
552
581
|
|
|
553
|
-
// For multiple elements or other cases, wrap in a div with theme classes
|
|
554
582
|
return <div className={cx(themeClass)}>{component}</div>;
|
|
555
583
|
};
|
|
556
584
|
|
|
557
585
|
const toRender = childrenToRender ? (
|
|
558
|
-
|
|
586
|
+
wrapRenderedComponentWithTheme(childrenToRender)
|
|
559
587
|
) : html ? (
|
|
560
588
|
<div
|
|
561
589
|
className={cx(themeClass)}
|
|
@@ -574,22 +602,18 @@ const PreviewGenerator: FunctionComponent<PreviewProps> = ({
|
|
|
574
602
|
html;
|
|
575
603
|
|
|
576
604
|
// Apply the exact same wrapping logic for code display
|
|
577
|
-
const toCode = codeContent
|
|
578
|
-
? wrapComponentWithTheme(codeContent)
|
|
579
|
-
: codeContent;
|
|
605
|
+
const toCode = codeContent ? wrapCodeWithTheme(codeContent) : codeContent;
|
|
580
606
|
|
|
581
607
|
// Generate JSX string for the JSX tab
|
|
582
608
|
// Use pre-generated JSX if provided (from server), otherwise generate client-side
|
|
583
609
|
const generatedJSXCode =
|
|
584
|
-
|
|
585
|
-
(typeof code === "string"
|
|
610
|
+
typeof code === "string"
|
|
586
611
|
? code
|
|
587
|
-
:
|
|
588
|
-
? generateJSXString(toCode, codeJSXOptions)
|
|
589
|
-
: "");
|
|
612
|
+
: applyThemeClassToJsxCode(jsxCode) ||
|
|
613
|
+
(toCode ? generateJSXString(toCode, codeJSXOptions) : "");
|
|
590
614
|
|
|
591
615
|
// Use toCode for HTML rendering
|
|
592
|
-
const codeForHTML =
|
|
616
|
+
const codeForHTML = codeContent;
|
|
593
617
|
|
|
594
618
|
const previewViewportWidth = disableBreakpoints
|
|
595
619
|
? null
|
|
@@ -636,6 +660,7 @@ const PreviewGenerator: FunctionComponent<PreviewProps> = ({
|
|
|
636
660
|
<CodeExample
|
|
637
661
|
codeJSXOptions={codeJSXOptions}
|
|
638
662
|
codeTypes={codeTypes}
|
|
663
|
+
htmlThemeClass={themeClass}
|
|
639
664
|
jsxCode={generatedJSXCode}
|
|
640
665
|
htmlCode={codeForHTML}
|
|
641
666
|
>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const getElementDisplayName = (element: any): string => {
|
|
2
|
+
if (!element) return "Unknown";
|
|
3
|
+
|
|
4
|
+
const type = element.type;
|
|
5
|
+
const clientReferenceId =
|
|
6
|
+
typeof type?.$$id === "string" ? type.$$id.split("#").pop() : undefined;
|
|
7
|
+
const payloadValue = type?._payload?.value;
|
|
8
|
+
const payloadName =
|
|
9
|
+
typeof payloadValue === "string"
|
|
10
|
+
? payloadValue.split("#").pop()
|
|
11
|
+
: payloadValue?.name;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
element?.props?.mdxType ||
|
|
15
|
+
type?.displayName ||
|
|
16
|
+
type?.render?.displayName ||
|
|
17
|
+
type?.render?.name ||
|
|
18
|
+
type?.name ||
|
|
19
|
+
type?.type?.displayName ||
|
|
20
|
+
type?.type?.name ||
|
|
21
|
+
clientReferenceId ||
|
|
22
|
+
payloadName ||
|
|
23
|
+
(typeof type === "string" ? type : "Component")
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
$item-base: (
|
|
6
6
|
display: inline-flex,
|
|
7
7
|
align-items: center,
|
|
8
|
-
padding-top:
|
|
9
|
-
padding-bottom:
|
|
8
|
+
padding-top: convert.to-rem(10px),
|
|
9
|
+
padding-bottom: convert.to-rem(10px),
|
|
10
10
|
margin: 0 0 0 space.get("xsmall"),
|
|
11
|
-
color: var(--
|
|
11
|
+
color: var(--stepbar-item-color),
|
|
12
|
+
background: var(--stepbar-item-background),
|
|
13
|
+
--stepbar-arrow-size: #{convert.to-rem(21px)},
|
|
14
|
+
--stepbar-item-background: var(--color-surface-contrast),
|
|
15
|
+
--stepbar-item-color: var(--color-text-inverse),
|
|
12
16
|
);
|
|
13
17
|
|
|
14
18
|
$arrow-spacing-small: (
|
|
@@ -26,8 +30,8 @@ $arrow-spacing-small: (
|
|
|
26
30
|
|
|
27
31
|
$arrow-spacing: (
|
|
28
32
|
default: (
|
|
29
|
-
padding-left: convert.to-rem(
|
|
30
|
-
padding-right: convert.to-rem(
|
|
33
|
+
padding-left: convert.to-rem(35px),
|
|
34
|
+
padding-right: convert.to-rem(30px),
|
|
31
35
|
),
|
|
32
36
|
first: (
|
|
33
37
|
padding-left: convert.to-rem(35px),
|
|
@@ -40,43 +44,56 @@ $arrow-spacing: (
|
|
|
40
44
|
$arrows: (
|
|
41
45
|
default: (
|
|
42
46
|
done:
|
|
43
|
-
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath
|
|
47
|
+
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 0H0V40H5L21 20L5 0Z' fill='white'/%3E%3Cpath d='M0 0L16 20L0 40V0Z' fill='%23141414'/%3E%3C/svg%3E"),
|
|
44
48
|
current:
|
|
45
|
-
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath
|
|
49
|
+
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 0H0V40H5L21 20L5 0Z' fill='white'/%3E%3Cpath d='M0 0L16 20L0 40V0Z' fill='%23f15e00'/%3E%3C/svg%3E"),
|
|
46
50
|
next:
|
|
47
|
-
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath
|
|
51
|
+
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 0H0V40H5L21 20L5 0Z' fill='white'/%3E%3Cpath d='M0 0L16 20L0 40V0Z' fill='%23dddddd'/%3E%3C/svg%3E"),
|
|
48
52
|
),
|
|
49
53
|
inverse: (
|
|
50
54
|
done:
|
|
51
|
-
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath
|
|
55
|
+
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 0H0V40H5L21 20L5 0Z' fill='%23141414'/%3E%3Cpath d='M0 0L16 20L0 40V0Z' fill='white'/%3E%3C/svg%3E"),
|
|
52
56
|
current:
|
|
53
|
-
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath
|
|
57
|
+
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 0H0V40H5L21 20L5 0Z' fill='%23141414'/%3E%3Cpath d='M0 0L16 20L0 40V0Z' fill='%23f15e00'/%3E%3C/svg%3E"),
|
|
54
58
|
next:
|
|
55
|
-
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath
|
|
59
|
+
url("data:image/svg+xml,%3Csvg width='21' height='40' viewBox='0 0 21 40' fill='none' preserveAspectRatio='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 0H0V40H5L21 20L5 0Z' fill='%23141414'/%3E%3Cpath d='M0 0L16 20L0 40V0Z' fill='%23595959'/%3E%3C/svg%3E"),
|
|
56
60
|
),
|
|
57
61
|
);
|
|
58
62
|
|
|
59
63
|
$item-done-colors: (
|
|
60
64
|
default: (
|
|
61
|
-
background: var(--color-surface-contrast),
|
|
65
|
+
--stepbar-item-background: var(--color-surface-contrast),
|
|
66
|
+
--stepbar-item-color: var(--color-text-inverse),
|
|
67
|
+
),
|
|
68
|
+
inverse: (
|
|
69
|
+
--stepbar-item-background: var(--color-surface-contrast),
|
|
70
|
+
--stepbar-item-color: var(--color-text-inverse),
|
|
62
71
|
),
|
|
63
72
|
);
|
|
64
73
|
|
|
65
74
|
$item-colors: (
|
|
66
75
|
current: (
|
|
67
|
-
background: var(--color-surface-tertiary),
|
|
68
|
-
color:
|
|
76
|
+
--stepbar-item-background: var(--color-surface-tertiary),
|
|
77
|
+
--stepbar-item-color: #{color.$white},
|
|
69
78
|
),
|
|
70
79
|
next: (
|
|
71
|
-
background: var(--color-surface-
|
|
72
|
-
color: var(--color-
|
|
80
|
+
--stepbar-item-background: var(--color-surface-moderate),
|
|
81
|
+
--stepbar-item-color: var(--color-text-default),
|
|
73
82
|
),
|
|
74
83
|
);
|
|
75
84
|
|
|
76
85
|
$link-colors: (
|
|
77
86
|
default: (
|
|
78
87
|
base: (
|
|
79
|
-
color: var(--
|
|
88
|
+
color: var(--stepbar-item-color),
|
|
89
|
+
),
|
|
90
|
+
interaction: (
|
|
91
|
+
color: var(--color-text-accent),
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
inverse: (
|
|
95
|
+
base: (
|
|
96
|
+
color: var(--stepbar-item-color),
|
|
80
97
|
),
|
|
81
98
|
interaction: (
|
|
82
99
|
color: var(--color-text-accent),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
@use "../../../styles/tools/generate";
|
|
5
5
|
@use "../../../styles/tools/map";
|
|
6
6
|
@use "../../../styles/tokens/breakpoint";
|
|
7
|
-
@use "../../../styles/typography/
|
|
7
|
+
@use "../../../styles/typography/config" as typographyConfig;
|
|
8
8
|
@use "./config";
|
|
9
9
|
|
|
10
10
|
@mixin list-base {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
padding-left: 0;
|
|
15
15
|
margin: 0 0 space.get("large") 0;
|
|
16
16
|
max-width: none;
|
|
17
|
+
@include generate.css-map(sass-map.get(typographyConfig.$caption, "large"));
|
|
17
18
|
font-weight: bold;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -65,10 +66,11 @@
|
|
|
65
66
|
position: absolute;
|
|
66
67
|
z-index: 1;
|
|
67
68
|
top: 0;
|
|
68
|
-
right: -
|
|
69
|
-
width:
|
|
69
|
+
right: calc(var(--stepbar-arrow-size) * -1);
|
|
70
|
+
width: var(--stepbar-arrow-size);
|
|
70
71
|
height: 100%;
|
|
71
72
|
background-size: 100% 100%;
|
|
73
|
+
pointer-events: none;
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
|