@navikt/ds-react 7.30.0 → 7.30.1
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/cjs/accordion/AccordionContent.js +1 -1
- package/cjs/accordion/AccordionContent.js.map +1 -1
- package/cjs/accordion/AccordionHeader.js +1 -1
- package/cjs/accordion/AccordionHeader.js.map +1 -1
- package/cjs/chips/Removable.js +1 -1
- package/cjs/chips/Removable.js.map +1 -1
- package/cjs/chips/Toggle.js +1 -1
- package/cjs/chips/Toggle.js.map +1 -1
- package/cjs/copybutton/CopyButton.js +8 -4
- package/cjs/copybutton/CopyButton.js.map +1 -1
- package/cjs/expansion-card/ExpansionCardContent.js +2 -1
- package/cjs/expansion-card/ExpansionCardContent.js.map +1 -1
- package/cjs/form/checkbox/Checkbox.js +42 -0
- package/cjs/form/checkbox/Checkbox.js.map +1 -1
- package/cjs/form/checkbox/useCheckbox.d.ts +2 -2
- package/cjs/form/checkbox/useCheckbox.js +5 -5
- package/cjs/form/checkbox/useCheckbox.js.map +1 -1
- package/cjs/form/radio/Radio.js +18 -0
- package/cjs/form/radio/Radio.js.map +1 -1
- package/cjs/form/radio/useRadio.d.ts +2 -2
- package/cjs/form/radio/useRadio.js +5 -5
- package/cjs/form/radio/useRadio.js.map +1 -1
- package/cjs/form/search/Search.js +1 -1
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/guide-panel/GuidePanel.js +3 -3
- package/cjs/guide-panel/GuidePanel.js.map +1 -1
- package/cjs/help-text/HelpText.js +1 -1
- package/cjs/help-text/HelpText.js.map +1 -1
- package/cjs/internal-header/InternalHeader.js +1 -1
- package/cjs/internal-header/InternalHeader.js.map +1 -1
- package/cjs/layout/base/BasePrimitive.js +1 -1
- package/cjs/layout/base/BasePrimitive.js.map +1 -1
- package/cjs/layout/bleed/Bleed.js +1 -1
- package/cjs/layout/bleed/Bleed.js.map +1 -1
- package/cjs/layout/box/Box.js +4 -4
- package/cjs/layout/box/Box.js.map +1 -1
- package/cjs/layout/grid/HGrid.js +1 -1
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.js +3 -1
- package/cjs/layout/page/Page.js.map +1 -1
- package/cjs/layout/stack/Stack.js +1 -1
- package/cjs/layout/stack/Stack.js.map +1 -1
- package/cjs/link/Link.js +1 -1
- package/cjs/link/Link.js.map +1 -1
- package/cjs/list/List.js +1 -1
- package/cjs/list/List.js.map +1 -1
- package/cjs/overlays/action-menu/ActionMenu.js +1 -1
- package/cjs/overlays/action-menu/ActionMenu.js.map +1 -1
- package/cjs/pagination/PaginationItem.js +1 -1
- package/cjs/pagination/PaginationItem.js.map +1 -1
- package/cjs/popover/Popover.js +2 -2
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/portal/Portal.js +1 -1
- package/cjs/portal/Portal.js.map +1 -1
- package/cjs/theme/Theme.d.ts +6 -1
- package/cjs/theme/Theme.js +10 -2
- package/cjs/theme/Theme.js.map +1 -1
- package/cjs/timeline/Pin.js +1 -1
- package/cjs/timeline/Pin.js.map +1 -1
- package/cjs/timeline/period/ClickablePeriod.js +1 -1
- package/cjs/timeline/period/ClickablePeriod.js.map +1 -1
- package/cjs/toggle-group/ToggleGroup.js +1 -1
- package/cjs/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/accordion/AccordionContent.js +1 -1
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +1 -1
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/chips/Removable.js +1 -1
- package/esm/chips/Removable.js.map +1 -1
- package/esm/chips/Toggle.js +1 -1
- package/esm/chips/Toggle.js.map +1 -1
- package/esm/copybutton/CopyButton.js +8 -4
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/expansion-card/ExpansionCardContent.js +3 -2
- package/esm/expansion-card/ExpansionCardContent.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +44 -2
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +2 -2
- package/esm/form/checkbox/useCheckbox.js +5 -5
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/radio/Radio.js +17 -2
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/useRadio.d.ts +2 -2
- package/esm/form/radio/useRadio.js +5 -5
- package/esm/form/radio/useRadio.js.map +1 -1
- package/esm/form/search/Search.js +1 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/guide-panel/GuidePanel.js +3 -3
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/help-text/HelpText.js +1 -1
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/internal-header/InternalHeader.js +1 -1
- package/esm/internal-header/InternalHeader.js.map +1 -1
- package/esm/layout/base/BasePrimitive.js +1 -1
- package/esm/layout/base/BasePrimitive.js.map +1 -1
- package/esm/layout/bleed/Bleed.js +1 -1
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.js +4 -4
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/grid/HGrid.js +1 -1
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.js +3 -1
- package/esm/layout/page/Page.js.map +1 -1
- package/esm/layout/stack/Stack.js +1 -1
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/link/Link.js +1 -1
- package/esm/link/Link.js.map +1 -1
- package/esm/list/List.js +1 -1
- package/esm/list/List.js.map +1 -1
- package/esm/overlays/action-menu/ActionMenu.js +1 -1
- package/esm/overlays/action-menu/ActionMenu.js.map +1 -1
- package/esm/pagination/PaginationItem.js +1 -1
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/popover/Popover.js +2 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/portal/Portal.js +1 -1
- package/esm/portal/Portal.js.map +1 -1
- package/esm/theme/Theme.d.ts +6 -1
- package/esm/theme/Theme.js +10 -2
- package/esm/theme/Theme.js.map +1 -1
- package/esm/timeline/Pin.js +1 -1
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/period/ClickablePeriod.js +1 -1
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +1 -1
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/AccordionContent.tsx +1 -1
- package/src/accordion/AccordionHeader.tsx +1 -1
- package/src/chips/Removable.tsx +1 -1
- package/src/chips/Toggle.tsx +1 -1
- package/src/copybutton/CopyButton.tsx +8 -4
- package/src/expansion-card/ExpansionCardContent.tsx +3 -1
- package/src/form/checkbox/Checkbox.tsx +91 -2
- package/src/form/checkbox/useCheckbox.ts +5 -5
- package/src/form/radio/Radio.tsx +47 -2
- package/src/form/radio/useRadio.ts +5 -5
- package/src/form/search/Search.tsx +1 -1
- package/src/guide-panel/GuidePanel.tsx +3 -3
- package/src/help-text/HelpText.tsx +2 -2
- package/src/internal-header/InternalHeader.tsx +1 -1
- package/src/layout/base/BasePrimitive.tsx +1 -1
- package/src/layout/bleed/Bleed.tsx +1 -1
- package/src/layout/box/Box.tsx +5 -4
- package/src/layout/grid/HGrid.tsx +1 -1
- package/src/layout/page/Page.tsx +5 -1
- package/src/layout/stack/Stack.tsx +1 -1
- package/src/link/Link.tsx +1 -1
- package/src/list/List.tsx +1 -1
- package/src/overlays/action-menu/ActionMenu.tsx +1 -1
- package/src/pagination/PaginationItem.tsx +1 -1
- package/src/popover/Popover.tsx +2 -2
- package/src/portal/Portal.tsx +1 -1
- package/src/theme/Theme.tsx +14 -3
- package/src/timeline/Pin.tsx +1 -1
- package/src/timeline/period/ClickablePeriod.tsx +1 -1
- package/src/toggle-group/ToggleGroup.tsx +1 -1
package/src/form/radio/Radio.tsx
CHANGED
|
@@ -1,13 +1,58 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
1
2
|
import React, { forwardRef } from "react";
|
|
2
|
-
import { useRenameCSS } from "../../theme/Theme";
|
|
3
|
+
import { useRenameCSS, useThemeInternal } from "../../theme/Theme";
|
|
3
4
|
import { BodyShort } from "../../typography";
|
|
4
|
-
import { omit } from "../../util";
|
|
5
|
+
import { omit, useId } from "../../util";
|
|
5
6
|
import { RadioProps } from "./types";
|
|
6
7
|
import { useRadio } from "./useRadio";
|
|
7
8
|
|
|
8
9
|
export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
|
|
9
10
|
const { cn } = useRenameCSS();
|
|
10
11
|
const { inputProps, size, hasError, readOnly } = useRadio(props);
|
|
12
|
+
const descriptionId = useId();
|
|
13
|
+
const themeContext = useThemeInternal(false);
|
|
14
|
+
|
|
15
|
+
if (themeContext?.isDarkside) {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
className={cn(props.className, "navds-radio", `navds-radio--${size}`, {
|
|
19
|
+
"navds-radio--error": hasError,
|
|
20
|
+
"navds-radio--disabled": inputProps.disabled,
|
|
21
|
+
"navds-radio--readonly": readOnly,
|
|
22
|
+
})}
|
|
23
|
+
data-color={hasError ? "danger" : props["data-color"]}
|
|
24
|
+
>
|
|
25
|
+
<input
|
|
26
|
+
{...omit(props, ["children", "size", "description", "readOnly"])}
|
|
27
|
+
{...omit(inputProps, ["aria-invalid", "aria-describedby"])}
|
|
28
|
+
aria-describedby={cl(inputProps["aria-describedby"], {
|
|
29
|
+
[descriptionId]: props.description,
|
|
30
|
+
})}
|
|
31
|
+
className={cn("navds-radio__input")}
|
|
32
|
+
ref={ref}
|
|
33
|
+
/>
|
|
34
|
+
<BodyShort
|
|
35
|
+
as="label"
|
|
36
|
+
htmlFor={inputProps.id}
|
|
37
|
+
className={cn("navds-radio__label")}
|
|
38
|
+
size={size}
|
|
39
|
+
>
|
|
40
|
+
{props.children}
|
|
41
|
+
</BodyShort>
|
|
42
|
+
{props.description && (
|
|
43
|
+
<BodyShort
|
|
44
|
+
id={descriptionId}
|
|
45
|
+
size={size}
|
|
46
|
+
className={cn(
|
|
47
|
+
"navds-form-field__subdescription navds-radio__description",
|
|
48
|
+
)}
|
|
49
|
+
>
|
|
50
|
+
{props.description}
|
|
51
|
+
</BodyShort>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
11
56
|
|
|
12
57
|
return (
|
|
13
58
|
<div
|
|
@@ -37,19 +37,19 @@ export const useRadio = (props: RadioProps) => {
|
|
|
37
37
|
radioGroup?.value === undefined
|
|
38
38
|
? undefined
|
|
39
39
|
: radioGroup?.value === props.value,
|
|
40
|
-
onChange: (
|
|
40
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
41
41
|
if (readOnly) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
props.onChange?.(
|
|
44
|
+
props.onChange?.(event);
|
|
45
45
|
radioGroup?.onChange?.(props.value);
|
|
46
46
|
},
|
|
47
|
-
onClick: (
|
|
47
|
+
onClick: (event: React.MouseEvent<HTMLInputElement>) => {
|
|
48
48
|
if (readOnly) {
|
|
49
|
-
|
|
49
|
+
event.preventDefault();
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
props?.onClick?.(
|
|
52
|
+
props?.onClick?.(event);
|
|
53
53
|
},
|
|
54
54
|
required: radioGroup?.required,
|
|
55
55
|
type: "radio",
|
|
@@ -271,7 +271,7 @@ function ClearButton({
|
|
|
271
271
|
const themeContext = useThemeInternal(false);
|
|
272
272
|
const translate = useI18n("Search");
|
|
273
273
|
|
|
274
|
-
return themeContext ? (
|
|
274
|
+
return themeContext?.isDarkside ? (
|
|
275
275
|
<Button
|
|
276
276
|
className={cn("navds-search__button-clear")}
|
|
277
277
|
variant="tertiary"
|
|
@@ -64,14 +64,14 @@ export const GuidePanel = forwardRef<HTMLDivElement, GuidePanelProps>(
|
|
|
64
64
|
>
|
|
65
65
|
<div className={cn("navds-guide")}>
|
|
66
66
|
{illustration ??
|
|
67
|
-
(themeContext ? (
|
|
67
|
+
(themeContext?.isDarkside ? (
|
|
68
68
|
<DarksideGudiepanelIllustration />
|
|
69
69
|
) : (
|
|
70
70
|
<DefaultIllustration />
|
|
71
71
|
))}
|
|
72
72
|
</div>
|
|
73
73
|
<div className={cn("navds-guide-panel__content")}>
|
|
74
|
-
{themeContext && (
|
|
74
|
+
{themeContext?.isDarkside && (
|
|
75
75
|
<svg
|
|
76
76
|
viewBox="0 0 33 22"
|
|
77
77
|
width="33"
|
|
@@ -96,7 +96,7 @@ export const GuidePanel = forwardRef<HTMLDivElement, GuidePanelProps>(
|
|
|
96
96
|
/>
|
|
97
97
|
</svg>
|
|
98
98
|
)}
|
|
99
|
-
{themeContext ? (
|
|
99
|
+
{themeContext?.isDarkside ? (
|
|
100
100
|
<div className={cn("navds-guide-panel__content-inner")}>
|
|
101
101
|
{children}
|
|
102
102
|
</div>
|
|
@@ -81,8 +81,8 @@ export const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
|
|
|
81
81
|
anchorEl={buttonRef.current}
|
|
82
82
|
placement={placement}
|
|
83
83
|
strategy={strategy}
|
|
84
|
-
offset={themeContext ? 8 : 12}
|
|
85
|
-
arrow={!themeContext}
|
|
84
|
+
offset={themeContext?.isDarkside ? 8 : 12}
|
|
85
|
+
arrow={!themeContext?.isDarkside}
|
|
86
86
|
>
|
|
87
87
|
<Popover.Content className={cn("navds-body-short")}>
|
|
88
88
|
{children}
|
|
@@ -84,7 +84,7 @@ export const InternalHeader = forwardRef(({ className, ...rest }, ref) => {
|
|
|
84
84
|
/*
|
|
85
85
|
* Component is always in "dark" mode, so we manually override global theme.
|
|
86
86
|
*/
|
|
87
|
-
if (themeContext) {
|
|
87
|
+
if (themeContext?.isDarkside) {
|
|
88
88
|
return (
|
|
89
89
|
<Theme theme="dark" asChild hasBackground={false}>
|
|
90
90
|
<header
|
|
@@ -253,7 +253,7 @@ export const BasePrimitive = ({
|
|
|
253
253
|
}: BasePrimitiveProps) => {
|
|
254
254
|
const themeContext = useThemeInternal(false);
|
|
255
255
|
const { cn } = useRenameCSS();
|
|
256
|
-
const prefix = themeContext ? "ax" : "a";
|
|
256
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
257
257
|
|
|
258
258
|
const style: React.CSSProperties = {
|
|
259
259
|
/* Padding */
|
|
@@ -82,7 +82,7 @@ export const Bleed = forwardRef<HTMLDivElement, BleedProps>(
|
|
|
82
82
|
) => {
|
|
83
83
|
const themeContext = useThemeInternal(false);
|
|
84
84
|
const { cn } = useRenameCSS();
|
|
85
|
-
const prefix = themeContext ? "ax" : "a";
|
|
85
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
86
86
|
|
|
87
87
|
let style: React.CSSProperties = {
|
|
88
88
|
..._style,
|
package/src/layout/box/Box.tsx
CHANGED
|
@@ -113,7 +113,7 @@ export const BoxComponent: OverridableComponent<BoxProps, HTMLDivElement> =
|
|
|
113
113
|
|
|
114
114
|
if (
|
|
115
115
|
process.env.NODE_ENV !== "production" &&
|
|
116
|
-
themeContext &&
|
|
116
|
+
themeContext?.isDarkside &&
|
|
117
117
|
(background || borderColor || shadow)
|
|
118
118
|
) {
|
|
119
119
|
let errorText = ``;
|
|
@@ -131,7 +131,7 @@ export const BoxComponent: OverridableComponent<BoxProps, HTMLDivElement> =
|
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
const prefix = themeContext ? "ax" : "a";
|
|
134
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
135
135
|
|
|
136
136
|
const style: React.CSSProperties = {
|
|
137
137
|
..._style,
|
|
@@ -173,8 +173,9 @@ export const BoxComponent: OverridableComponent<BoxProps, HTMLDivElement> =
|
|
|
173
173
|
"navds-box-bg": background,
|
|
174
174
|
"navds-box-border-color": borderColor,
|
|
175
175
|
"navds-box-border-width": borderWidth,
|
|
176
|
-
"navds-box-border-radius":
|
|
177
|
-
|
|
176
|
+
"navds-box-border-radius":
|
|
177
|
+
borderRadius && !themeContext?.isDarkside,
|
|
178
|
+
"navds-box-radius": borderRadius && themeContext?.isDarkside,
|
|
178
179
|
"navds-box-shadow": shadow,
|
|
179
180
|
})}
|
|
180
181
|
>
|
|
@@ -78,7 +78,7 @@ export const HGrid: OverridableComponent<HGridProps, HTMLDivElement> =
|
|
|
78
78
|
ref,
|
|
79
79
|
) => {
|
|
80
80
|
const themeContext = useThemeInternal(false);
|
|
81
|
-
const prefix = themeContext ? "ax" : "a";
|
|
81
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
82
82
|
const { cn } = useRenameCSS();
|
|
83
83
|
|
|
84
84
|
const styles: React.CSSProperties = {
|
package/src/layout/page/Page.tsx
CHANGED
|
@@ -56,7 +56,11 @@ export const PageComponent: OverridableComponent<PageProps, HTMLElement> =
|
|
|
56
56
|
const themeContext = useThemeInternal(false);
|
|
57
57
|
const { cn } = useRenameCSS();
|
|
58
58
|
|
|
59
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
process.env.NODE_ENV !== "production" &&
|
|
61
|
+
themeContext?.isDarkside &&
|
|
62
|
+
background
|
|
63
|
+
) {
|
|
60
64
|
console.warn(
|
|
61
65
|
`Prop \`background\` is deprecated and cannot be used with theme-support. Instead wrap component with \`<Box asChild background>\``,
|
|
62
66
|
);
|
|
@@ -84,7 +84,7 @@ export const Stack: OverridableComponent<StackProps, HTMLDivElement> =
|
|
|
84
84
|
ref,
|
|
85
85
|
) => {
|
|
86
86
|
const themeContext = useThemeInternal(false);
|
|
87
|
-
const prefix = themeContext ? "ax" : "a";
|
|
87
|
+
const prefix = themeContext?.isDarkside ? "ax" : "a";
|
|
88
88
|
const { cn } = useRenameCSS();
|
|
89
89
|
|
|
90
90
|
const style: React.CSSProperties = {
|
package/src/link/Link.tsx
CHANGED
package/src/list/List.tsx
CHANGED
|
@@ -802,7 +802,7 @@ export const ActionMenuRadioItem = forwardRef<
|
|
|
802
802
|
fill="var(--ax-bg-default, var(--a-surface-default))"
|
|
803
803
|
/>
|
|
804
804
|
</g>
|
|
805
|
-
{themeContext ? (
|
|
805
|
+
{themeContext?.isDarkside ? (
|
|
806
806
|
<g className={cn("navds-action-menu__indicator-icon--checked")}>
|
|
807
807
|
<rect
|
|
808
808
|
width="24"
|
|
@@ -46,7 +46,7 @@ export const Item: PaginationItemType = forwardRef(
|
|
|
46
46
|
return (
|
|
47
47
|
<Button
|
|
48
48
|
as={Component}
|
|
49
|
-
variant={themeContext ? "tertiary-neutral" : "tertiary"}
|
|
49
|
+
variant={themeContext?.isDarkside ? "tertiary-neutral" : "tertiary"}
|
|
50
50
|
data-color={color}
|
|
51
51
|
aria-current={selected}
|
|
52
52
|
data-pressed={selected}
|
package/src/popover/Popover.tsx
CHANGED
|
@@ -138,7 +138,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
|
138
138
|
placement,
|
|
139
139
|
open,
|
|
140
140
|
middleware: [
|
|
141
|
-
flOffset(offset ?? (themeContext ? 8 : arrow ? 16 : 4)),
|
|
141
|
+
flOffset(offset ?? (themeContext?.isDarkside ? 8 : arrow ? 16 : 4)),
|
|
142
142
|
chosenFlip &&
|
|
143
143
|
flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
|
|
144
144
|
shift({ padding: 12 }),
|
|
@@ -191,7 +191,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
|
191
191
|
>
|
|
192
192
|
{children}
|
|
193
193
|
{/* Hide arrow in new design, prop will be removed in breaking change update */}
|
|
194
|
-
{arrow && !themeContext && (
|
|
194
|
+
{arrow && !themeContext?.isDarkside && (
|
|
195
195
|
<div
|
|
196
196
|
ref={(node) => {
|
|
197
197
|
arrowRef.current = node;
|
package/src/portal/Portal.tsx
CHANGED
|
@@ -26,7 +26,7 @@ export const Portal = forwardRef<HTMLDivElement, PortalProps>(
|
|
|
26
26
|
* Portal can be mounted outside of theme-classNames.
|
|
27
27
|
* If a theme is present, we want to make sure that theme cascades to portaled element.
|
|
28
28
|
*/
|
|
29
|
-
if (themeContext) {
|
|
29
|
+
if (themeContext?.isDarkside) {
|
|
30
30
|
return root
|
|
31
31
|
? ReactDOM.createPortal(
|
|
32
32
|
<Theme
|
package/src/theme/Theme.tsx
CHANGED
|
@@ -45,6 +45,8 @@ const RenameCSS = ({ children }: { children: React.ReactNode }) => {
|
|
|
45
45
|
/* -------------------------------------------------------------------------- */
|
|
46
46
|
/* Theme provider */
|
|
47
47
|
/* -------------------------------------------------------------------------- */
|
|
48
|
+
const DEFAULT_COLOR: AkselColor = "accent";
|
|
49
|
+
|
|
48
50
|
type ThemeContext = {
|
|
49
51
|
/**
|
|
50
52
|
* Color theme
|
|
@@ -52,12 +54,21 @@ type ThemeContext = {
|
|
|
52
54
|
*/
|
|
53
55
|
theme?: "light" | "dark";
|
|
54
56
|
color?: AkselColor;
|
|
57
|
+
/**
|
|
58
|
+
* Indicates if Theme-component is used or not.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
isDarkside: boolean;
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
const [ThemeProvider, useThemeInternal] = createContext<ThemeContext>({
|
|
58
65
|
hookName: "useTheme",
|
|
59
66
|
name: "ThemeProvider",
|
|
60
67
|
providerName: "ThemeProvider",
|
|
68
|
+
defaultValue: {
|
|
69
|
+
color: DEFAULT_COLOR,
|
|
70
|
+
isDarkside: false,
|
|
71
|
+
},
|
|
61
72
|
});
|
|
62
73
|
|
|
63
74
|
export type ThemeProps = {
|
|
@@ -70,7 +81,7 @@ export type ThemeProps = {
|
|
|
70
81
|
* Sets default 'base'-color for application
|
|
71
82
|
*/
|
|
72
83
|
"data-color"?: AkselColor;
|
|
73
|
-
} & Omit<ThemeContext, "color"> &
|
|
84
|
+
} & Omit<ThemeContext, "color" | "isDarkside"> &
|
|
74
85
|
AsChildProps;
|
|
75
86
|
|
|
76
87
|
const Theme = forwardRef<HTMLDivElement, ThemeProps>(
|
|
@@ -86,7 +97,7 @@ const Theme = forwardRef<HTMLDivElement, ThemeProps>(
|
|
|
86
97
|
"data-color": color = context?.color,
|
|
87
98
|
} = props;
|
|
88
99
|
|
|
89
|
-
const isRoot = context
|
|
100
|
+
const isRoot = !context?.isDarkside;
|
|
90
101
|
|
|
91
102
|
const hasBackground =
|
|
92
103
|
hasBackgroundProp ?? (isRoot && props.theme !== undefined);
|
|
@@ -94,7 +105,7 @@ const Theme = forwardRef<HTMLDivElement, ThemeProps>(
|
|
|
94
105
|
const SlotElement = asChild ? Slot : "div";
|
|
95
106
|
|
|
96
107
|
return (
|
|
97
|
-
<ThemeProvider theme={theme} color={color}>
|
|
108
|
+
<ThemeProvider theme={theme} color={color} isDarkside={true}>
|
|
98
109
|
<RenameCSS>
|
|
99
110
|
<SlotElement
|
|
100
111
|
ref={ref}
|
package/src/timeline/Pin.tsx
CHANGED
|
@@ -49,7 +49,7 @@ export const Pin = forwardRef<HTMLButtonElement, TimelinePinProps>(
|
|
|
49
49
|
const translate = useI18n("Timeline");
|
|
50
50
|
|
|
51
51
|
const themeContext = useThemeInternal(false);
|
|
52
|
-
const showArrow = !themeContext;
|
|
52
|
+
const showArrow = !themeContext?.isDarkside;
|
|
53
53
|
|
|
54
54
|
const {
|
|
55
55
|
context,
|
|
@@ -84,7 +84,7 @@ export const ToggleGroup = forwardRef<HTMLDivElement, ToggleGroupProps>(
|
|
|
84
84
|
|
|
85
85
|
let localVariant: ToggleGroupProps["variant"] | undefined;
|
|
86
86
|
|
|
87
|
-
if (themeContext) {
|
|
87
|
+
if (themeContext?.isDarkside) {
|
|
88
88
|
localVariant = variant;
|
|
89
89
|
} else {
|
|
90
90
|
localVariant = variant ?? "action";
|