@navikt/ds-react 7.22.0 → 7.23.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/cjs/alert/Alert.d.ts +4 -0
- package/cjs/alert/Alert.js +15 -1
- package/cjs/alert/Alert.js.map +1 -1
- package/cjs/button/Button.js +30 -2
- package/cjs/button/Button.js.map +1 -1
- package/cjs/chat/Chat.js +14 -2
- package/cjs/chat/Chat.js.map +1 -1
- package/cjs/chips/Removable.js +22 -2
- package/cjs/chips/Removable.js.map +1 -1
- package/cjs/chips/Toggle.js +24 -5
- package/cjs/chips/Toggle.js.map +1 -1
- package/cjs/expansion-card/ExpansionCard.js +2 -2
- package/cjs/expansion-card/ExpansionCard.js.map +1 -1
- package/cjs/form/checkbox/Checkbox.js +1 -1
- package/cjs/form/checkbox/Checkbox.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/cjs/form/confirmation-panel/ConfirmationPanel.js +2 -2
- package/cjs/form/confirmation-panel/ConfirmationPanel.js.map +1 -1
- package/cjs/form/error-summary/ErrorSummary.js +1 -1
- package/cjs/form/error-summary/ErrorSummary.js.map +1 -1
- package/cjs/form/form-summary/FormSummaryAnswers.js +2 -2
- package/cjs/form/form-summary/FormSummaryAnswers.js.map +1 -1
- package/cjs/form/radio/Radio.js +1 -1
- package/cjs/form/radio/Radio.js.map +1 -1
- package/cjs/form/search/Search.d.ts +1 -1
- package/cjs/form/search/Search.js +2 -2
- 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/guide-panel/Illustration.darkside.js +1 -1
- package/cjs/guide-panel/Illustration.darkside.js.map +1 -1
- package/cjs/help-text/HelpText.js +2 -2
- package/cjs/help-text/HelpText.js.map +1 -1
- package/cjs/layout/box/Box.darkside.d.ts +4 -4
- package/cjs/layout/box/Box.darkside.js.map +1 -1
- package/cjs/layout/utilities/types.d.ts +8 -8
- package/cjs/link/Link.js +26 -2
- package/cjs/link/Link.js.map +1 -1
- package/cjs/loader/Loader.d.ts +5 -0
- package/cjs/loader/Loader.js +15 -2
- package/cjs/loader/Loader.js.map +1 -1
- package/cjs/overlays/action-menu/ActionMenu.js +5 -5
- package/cjs/overlays/action-menu/ActionMenu.js.map +1 -1
- package/cjs/pagination/Pagination.js +5 -7
- package/cjs/pagination/Pagination.js.map +1 -1
- package/cjs/pagination/PaginationItem.js +2 -2
- package/cjs/pagination/PaginationItem.js.map +1 -1
- package/cjs/portal/Portal.js +1 -1
- package/cjs/portal/Portal.js.map +1 -1
- package/cjs/stepper/Stepper.js +3 -2
- package/cjs/stepper/Stepper.js.map +1 -1
- package/cjs/tag/Tag.js +39 -3
- package/cjs/tag/Tag.js.map +1 -1
- package/cjs/theme/Theme.d.ts +10 -1
- package/cjs/theme/Theme.js +3 -3
- package/cjs/theme/Theme.js.map +1 -1
- package/cjs/timeline/Pin.js +1 -3
- package/cjs/timeline/Pin.js.map +1 -1
- package/cjs/timeline/period/ClickablePeriod.js +3 -5
- package/cjs/timeline/period/ClickablePeriod.js.map +1 -1
- package/cjs/timeline/period/NonClickablePeriod.js +2 -1
- package/cjs/timeline/period/NonClickablePeriod.js.map +1 -1
- package/cjs/timeline/utils/period.d.ts +1 -1
- package/cjs/timeline/utils/period.js.map +1 -1
- package/cjs/toggle-group/ToggleGroup.js +21 -3
- package/cjs/toggle-group/ToggleGroup.js.map +1 -1
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +18 -0
- package/cjs/types/index.js.map +1 -0
- package/esm/alert/Alert.d.ts +4 -0
- package/esm/alert/Alert.js +15 -1
- package/esm/alert/Alert.js.map +1 -1
- package/esm/button/Button.js +30 -2
- package/esm/button/Button.js.map +1 -1
- package/esm/chat/Chat.js +14 -2
- package/esm/chat/Chat.js.map +1 -1
- package/esm/chips/Removable.js +23 -3
- package/esm/chips/Removable.js.map +1 -1
- package/esm/chips/Toggle.js +25 -6
- package/esm/chips/Toggle.js.map +1 -1
- package/esm/expansion-card/ExpansionCard.js +2 -2
- package/esm/expansion-card/ExpansionCard.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +1 -1
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/esm/form/confirmation-panel/ConfirmationPanel.js +2 -2
- package/esm/form/confirmation-panel/ConfirmationPanel.js.map +1 -1
- package/esm/form/error-summary/ErrorSummary.js +1 -1
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/form-summary/FormSummaryAnswers.js +2 -2
- package/esm/form/form-summary/FormSummaryAnswers.js.map +1 -1
- package/esm/form/radio/Radio.js +1 -1
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/search/Search.d.ts +1 -1
- package/esm/form/search/Search.js +2 -2
- 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/guide-panel/Illustration.darkside.js +1 -1
- package/esm/guide-panel/Illustration.darkside.js.map +1 -1
- package/esm/help-text/HelpText.js +2 -2
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/layout/box/Box.darkside.d.ts +4 -4
- package/esm/layout/box/Box.darkside.js.map +1 -1
- package/esm/layout/utilities/types.d.ts +8 -8
- package/esm/link/Link.js +27 -3
- package/esm/link/Link.js.map +1 -1
- package/esm/loader/Loader.d.ts +5 -0
- package/esm/loader/Loader.js +15 -2
- package/esm/loader/Loader.js.map +1 -1
- package/esm/overlays/action-menu/ActionMenu.js +5 -5
- package/esm/overlays/action-menu/ActionMenu.js.map +1 -1
- package/esm/pagination/Pagination.js +5 -7
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.js +2 -2
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/portal/Portal.js +1 -1
- package/esm/portal/Portal.js.map +1 -1
- package/esm/stepper/Stepper.js +3 -2
- package/esm/stepper/Stepper.js.map +1 -1
- package/esm/tag/Tag.js +39 -3
- package/esm/tag/Tag.js.map +1 -1
- package/esm/theme/Theme.d.ts +10 -1
- package/esm/theme/Theme.js +3 -3
- package/esm/theme/Theme.js.map +1 -1
- package/esm/timeline/Pin.js +2 -4
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/period/ClickablePeriod.js +4 -6
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/timeline/period/NonClickablePeriod.js +2 -1
- package/esm/timeline/period/NonClickablePeriod.js.map +1 -1
- package/esm/timeline/utils/period.d.ts +1 -1
- package/esm/timeline/utils/period.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +22 -4
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +2 -0
- package/esm/types/index.js.map +1 -0
- package/esm/types/theme.d.ts +15 -0
- package/package.json +12 -7
- package/src/alert/Alert.tsx +22 -0
- package/src/button/Button.tsx +38 -0
- package/src/chat/Chat.tsx +17 -0
- package/src/chips/Removable.tsx +30 -3
- package/src/chips/Toggle.tsx +31 -13
- package/src/expansion-card/ExpansionCard.tsx +2 -0
- package/src/form/checkbox/Checkbox.tsx +1 -0
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +6 -1
- package/src/form/confirmation-panel/ConfirmationPanel.tsx +2 -2
- package/src/form/error-summary/ErrorSummary.tsx +1 -1
- package/src/form/form-summary/FormSummaryAnswers.tsx +23 -12
- package/src/form/radio/Radio.tsx +1 -0
- package/src/form/search/Search.tsx +3 -2
- package/src/guide-panel/GuidePanel.tsx +13 -2
- package/src/guide-panel/Illustration.darkside.tsx +1 -6
- package/src/help-text/HelpText.tsx +5 -1
- package/src/layout/box/Box.darkside.tsx +10 -8
- package/src/layout/utilities/css.ts +8 -8
- package/src/layout/utilities/types.ts +18 -16
- package/src/link/Link.tsx +36 -3
- package/src/loader/Loader.tsx +24 -0
- package/src/overlays/action-menu/ActionMenu.tsx +5 -5
- package/src/pagination/Pagination.tsx +5 -0
- package/src/pagination/PaginationItem.tsx +3 -1
- package/src/portal/Portal.tsx +6 -1
- package/src/react-css.d.ts +0 -4
- package/src/stepper/Stepper.tsx +4 -3
- package/src/tag/Tag.tsx +53 -4
- package/src/theme/Theme.tsx +13 -2
- package/src/timeline/Pin.tsx +1 -3
- package/src/timeline/period/ClickablePeriod.tsx +2 -3
- package/src/timeline/period/NonClickablePeriod.tsx +1 -0
- package/src/timeline/utils/period.ts +1 -1
- package/src/toggle-group/ToggleGroup.tsx +28 -3
- package/src/types/index.ts +1 -0
- package/src/types/theme.d.ts +15 -0
package/src/chat/Chat.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { HTMLAttributes, forwardRef } from "react";
|
|
2
2
|
import { useRenameCSS } from "../theme/Theme";
|
|
3
|
+
import { AkselColor } from "../types";
|
|
3
4
|
import { BodyLong, HeadingProps } from "../typography";
|
|
4
5
|
import Bubble from "./Bubble";
|
|
5
6
|
|
|
@@ -94,6 +95,7 @@ export const Chat = forwardRef<HTMLDivElement, ChatProps>(
|
|
|
94
95
|
toptextPosition,
|
|
95
96
|
size = "medium",
|
|
96
97
|
toptextHeadingLevel = "3",
|
|
98
|
+
"data-color": color,
|
|
97
99
|
...rest
|
|
98
100
|
}: ChatProps,
|
|
99
101
|
ref,
|
|
@@ -111,7 +113,9 @@ export const Chat = forwardRef<HTMLDivElement, ChatProps>(
|
|
|
111
113
|
`navds-chat--${size}`,
|
|
112
114
|
`navds-chat--${variant}`,
|
|
113
115
|
)}
|
|
116
|
+
data-color={color ?? variantToColor(variant)}
|
|
114
117
|
{...rest}
|
|
118
|
+
data-variant={variant}
|
|
115
119
|
>
|
|
116
120
|
{avatar && (
|
|
117
121
|
<div className={cn("navds-chat__avatar")} aria-hidden>
|
|
@@ -139,6 +143,19 @@ export const Chat = forwardRef<HTMLDivElement, ChatProps>(
|
|
|
139
143
|
},
|
|
140
144
|
) as ChatComponent;
|
|
141
145
|
|
|
146
|
+
function variantToColor(variant: ChatProps["variant"]): AkselColor {
|
|
147
|
+
switch (variant) {
|
|
148
|
+
case "neutral":
|
|
149
|
+
return "neutral";
|
|
150
|
+
case "subtle":
|
|
151
|
+
return "neutral";
|
|
152
|
+
case "info":
|
|
153
|
+
return "info";
|
|
154
|
+
default:
|
|
155
|
+
return "neutral";
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
142
159
|
Chat.Bubble = Bubble;
|
|
143
160
|
|
|
144
161
|
export default Chat;
|
package/src/chips/Removable.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { XMarkIcon } from "@navikt/aksel-icons";
|
|
3
|
-
import { useRenameCSS } from "../theme/Theme";
|
|
3
|
+
import { useRenameCSS, useThemeInternal } from "../theme/Theme";
|
|
4
|
+
import { AkselColor } from "../types";
|
|
4
5
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
5
6
|
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
6
7
|
|
|
@@ -25,27 +26,40 @@ export const RemovableChips = forwardRef<
|
|
|
25
26
|
(
|
|
26
27
|
{
|
|
27
28
|
children,
|
|
28
|
-
variant
|
|
29
|
+
variant,
|
|
29
30
|
onDelete,
|
|
30
31
|
className,
|
|
31
32
|
onClick,
|
|
32
33
|
type = "button",
|
|
34
|
+
"data-color": color,
|
|
33
35
|
...rest
|
|
34
36
|
},
|
|
35
37
|
ref,
|
|
36
38
|
) => {
|
|
37
39
|
const translate = useI18n("Chips");
|
|
40
|
+
const themeContext = useThemeInternal(false);
|
|
38
41
|
const { cn } = useRenameCSS();
|
|
39
42
|
|
|
43
|
+
let localVariant: ChipsRemovableProps["variant"] | undefined;
|
|
44
|
+
|
|
45
|
+
if (themeContext) {
|
|
46
|
+
localVariant = variant;
|
|
47
|
+
} else {
|
|
48
|
+
localVariant = variant ?? "action";
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
return (
|
|
41
52
|
<button
|
|
53
|
+
data-color={color ?? variantToColor(localVariant)}
|
|
42
54
|
{...rest}
|
|
43
55
|
ref={ref}
|
|
44
56
|
type={type}
|
|
45
57
|
className={cn(
|
|
46
58
|
"navds-chips__chip navds-chips__removable navds-chips--icon-right",
|
|
47
59
|
className,
|
|
48
|
-
|
|
60
|
+
{
|
|
61
|
+
[`navds-chips__removable--${localVariant}`]: localVariant,
|
|
62
|
+
},
|
|
49
63
|
)}
|
|
50
64
|
aria-label={`${children} ${translate("Removable.labelSuffix")}`}
|
|
51
65
|
onClick={composeEventHandlers(onClick, onDelete)}
|
|
@@ -59,4 +73,17 @@ export const RemovableChips = forwardRef<
|
|
|
59
73
|
},
|
|
60
74
|
);
|
|
61
75
|
|
|
76
|
+
function variantToColor(
|
|
77
|
+
variant?: ChipsRemovableProps["variant"],
|
|
78
|
+
): AkselColor | undefined {
|
|
79
|
+
switch (variant) {
|
|
80
|
+
case "action":
|
|
81
|
+
return "accent";
|
|
82
|
+
case "neutral":
|
|
83
|
+
return "neutral";
|
|
84
|
+
default:
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
62
89
|
export default RemovableChips;
|
package/src/chips/Toggle.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
|
-
import { useRenameCSS } from "../theme/Theme";
|
|
2
|
+
import { useRenameCSS, useThemeInternal } from "../theme/Theme";
|
|
3
|
+
import { AkselColor } from "../types";
|
|
3
4
|
import { OverridableComponent } from "../util/types";
|
|
4
5
|
|
|
5
6
|
export interface ChipsToggleProps
|
|
@@ -30,25 +31,33 @@ export const ToggleChips: OverridableComponent<
|
|
|
30
31
|
className,
|
|
31
32
|
children,
|
|
32
33
|
selected,
|
|
33
|
-
variant
|
|
34
|
+
variant,
|
|
34
35
|
checkmark = true,
|
|
35
36
|
as: Component = "button",
|
|
37
|
+
"data-color": color,
|
|
36
38
|
...rest
|
|
37
39
|
},
|
|
38
40
|
ref,
|
|
39
41
|
) => {
|
|
40
42
|
const { cn } = useRenameCSS();
|
|
43
|
+
const themeContext = useThemeInternal(false);
|
|
44
|
+
let localVariant: ChipsToggleProps["variant"] | undefined;
|
|
45
|
+
|
|
46
|
+
if (themeContext) {
|
|
47
|
+
localVariant = variant;
|
|
48
|
+
} else {
|
|
49
|
+
localVariant = variant ?? "action";
|
|
50
|
+
}
|
|
41
51
|
|
|
42
52
|
return (
|
|
43
53
|
<Component
|
|
54
|
+
data-color={color ?? variantToColor(localVariant)}
|
|
44
55
|
{...rest}
|
|
45
56
|
ref={ref}
|
|
46
|
-
className={cn(
|
|
47
|
-
"navds-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{ "navds-chips__toggle--with-checkmark": checkmark },
|
|
51
|
-
)}
|
|
57
|
+
className={cn("navds-chips__chip navds-chips__toggle", className, {
|
|
58
|
+
"navds-chips__toggle--with-checkmark": checkmark,
|
|
59
|
+
[`navds-chips__toggle--${localVariant}`]: localVariant,
|
|
60
|
+
})}
|
|
52
61
|
aria-pressed={selected}
|
|
53
62
|
data-pressed={selected}
|
|
54
63
|
>
|
|
@@ -77,11 +86,7 @@ export const ToggleChips: OverridableComponent<
|
|
|
77
86
|
clipRule="evenodd"
|
|
78
87
|
d="M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10Z"
|
|
79
88
|
/* After removing old fallbacks, change to currentColor */
|
|
80
|
-
fill=
|
|
81
|
-
variant === "action"
|
|
82
|
-
? "--ax-text-accent"
|
|
83
|
-
: "--ax-text-neutral"
|
|
84
|
-
}, var(--ac-chip-toggle-circle-border, var(--a-border-default)))`}
|
|
89
|
+
fill="var(--ax-text-default, var(--ac-chip-toggle-circle-border, var(--a-border-default)))"
|
|
85
90
|
/>
|
|
86
91
|
)}
|
|
87
92
|
</svg>
|
|
@@ -92,4 +97,17 @@ export const ToggleChips: OverridableComponent<
|
|
|
92
97
|
},
|
|
93
98
|
);
|
|
94
99
|
|
|
100
|
+
function variantToColor(
|
|
101
|
+
variant?: ChipsToggleProps["variant"],
|
|
102
|
+
): AkselColor | undefined {
|
|
103
|
+
switch (variant) {
|
|
104
|
+
case "action":
|
|
105
|
+
return "accent";
|
|
106
|
+
case "neutral":
|
|
107
|
+
return "neutral";
|
|
108
|
+
default:
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
95
113
|
export default ToggleChips;
|
|
@@ -113,6 +113,7 @@ export const ExpansionCard = forwardRef<HTMLDivElement, ExpansionCardProps>(
|
|
|
113
113
|
open,
|
|
114
114
|
defaultOpen = false,
|
|
115
115
|
size = "medium",
|
|
116
|
+
"data-color": color = "neutral",
|
|
116
117
|
...rest
|
|
117
118
|
},
|
|
118
119
|
ref,
|
|
@@ -138,6 +139,7 @@ export const ExpansionCard = forwardRef<HTMLDivElement, ExpansionCardProps>(
|
|
|
138
139
|
}}
|
|
139
140
|
>
|
|
140
141
|
<section
|
|
142
|
+
data-color={color}
|
|
141
143
|
{...rest}
|
|
142
144
|
className={cn(
|
|
143
145
|
"navds-expansioncard",
|
|
@@ -27,7 +27,12 @@ const Option = ({ option }: { option: ComboboxOption }) => {
|
|
|
27
27
|
|
|
28
28
|
if (readOnly || inputProps.disabled) {
|
|
29
29
|
return (
|
|
30
|
-
<Chips.Toggle
|
|
30
|
+
<Chips.Toggle
|
|
31
|
+
data-color="neutral"
|
|
32
|
+
variant="neutral"
|
|
33
|
+
checkmark={false}
|
|
34
|
+
as="div"
|
|
35
|
+
>
|
|
31
36
|
{option.label}
|
|
32
37
|
</Chips.Toggle>
|
|
33
38
|
);
|
|
@@ -60,7 +60,7 @@ export const ConfirmationPanel = forwardRef<
|
|
|
60
60
|
|
|
61
61
|
const id = useId();
|
|
62
62
|
|
|
63
|
-
const
|
|
63
|
+
const currentColor = hasError
|
|
64
64
|
? "danger"
|
|
65
65
|
: props.checked
|
|
66
66
|
? "success"
|
|
@@ -73,7 +73,7 @@ export const ConfirmationPanel = forwardRef<
|
|
|
73
73
|
"navds-confirmation-panel--error": hasError,
|
|
74
74
|
"navds-confirmation-panel--checked": !!props.checked,
|
|
75
75
|
})}
|
|
76
|
-
data-color
|
|
76
|
+
data-color={currentColor}
|
|
77
77
|
>
|
|
78
78
|
<div className={cn("navds-confirmation-panel__inner")}>
|
|
79
79
|
{children && (
|
|
@@ -105,7 +105,7 @@ export const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(
|
|
|
105
105
|
<Heading
|
|
106
106
|
className={cn("navds-error-summary__heading")}
|
|
107
107
|
as={headingTag}
|
|
108
|
-
size="small"
|
|
108
|
+
size={size === "medium" ? "small" : "xsmall"}
|
|
109
109
|
ref={headingRef}
|
|
110
110
|
tabIndex={-1}
|
|
111
111
|
>
|
|
@@ -12,18 +12,29 @@ export interface FormSummaryAnswersProps
|
|
|
12
12
|
export const FormSummaryAnswers = forwardRef<
|
|
13
13
|
HTMLDListElement,
|
|
14
14
|
FormSummaryAnswersProps
|
|
15
|
-
>(
|
|
16
|
-
|
|
15
|
+
>(
|
|
16
|
+
(
|
|
17
|
+
{
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
"data-color": color = "info",
|
|
21
|
+
...rest
|
|
22
|
+
}: FormSummaryAnswersProps,
|
|
23
|
+
ref,
|
|
24
|
+
) => {
|
|
25
|
+
const { cn } = useRenameCSS();
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
return (
|
|
28
|
+
<dl
|
|
29
|
+
ref={ref}
|
|
30
|
+
data-color={color}
|
|
31
|
+
{...rest}
|
|
32
|
+
className={cn("navds-form-summary__answers", className)}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</dl>
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
28
39
|
|
|
29
40
|
export default FormSummaryAnswers;
|
package/src/form/radio/Radio.tsx
CHANGED
|
@@ -21,6 +21,7 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
|
|
|
21
21
|
"navds-radio--disabled": inputProps.disabled,
|
|
22
22
|
"navds-radio--readonly": readOnly,
|
|
23
23
|
})}
|
|
24
|
+
data-color={hasError ? "danger" : props["data-color"]}
|
|
24
25
|
>
|
|
25
26
|
<input
|
|
26
27
|
{...omit(props, ["children", "size", "description", "readOnly"])}
|
|
@@ -91,7 +91,7 @@ interface SearchComponent
|
|
|
91
91
|
* @example
|
|
92
92
|
* ```jsx
|
|
93
93
|
* <form role="search">
|
|
94
|
-
* <Search label="Søk alle Nav sine sider" variant="primary" />
|
|
94
|
+
* <Search label="Søk i alle Nav sine sider" variant="primary" />
|
|
95
95
|
* </form>
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
@@ -155,7 +155,8 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
|
|
|
155
155
|
themeContext ? (
|
|
156
156
|
<Button
|
|
157
157
|
className={cn("navds-search__button-clear")}
|
|
158
|
-
variant="tertiary
|
|
158
|
+
variant="tertiary"
|
|
159
|
+
data-color="neutral"
|
|
159
160
|
size={size === "medium" ? "small" : "xsmall"}
|
|
160
161
|
icon={<XMarkIcon aria-hidden />}
|
|
161
162
|
title={clearButtonLabel || translate("clear")}
|
|
@@ -35,12 +35,23 @@ export interface GuidePanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
export const GuidePanel = forwardRef<HTMLDivElement, GuidePanelProps>(
|
|
38
|
-
(
|
|
38
|
+
(
|
|
39
|
+
{
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
illustration,
|
|
43
|
+
poster,
|
|
44
|
+
"data-color": color = "info",
|
|
45
|
+
...rest
|
|
46
|
+
},
|
|
47
|
+
ref,
|
|
48
|
+
) => {
|
|
39
49
|
const { cn } = useRenameCSS();
|
|
40
50
|
const themeContext = useThemeInternal(false);
|
|
41
51
|
|
|
42
52
|
return (
|
|
43
53
|
<div
|
|
54
|
+
data-color={color}
|
|
44
55
|
{...rest}
|
|
45
56
|
ref={ref}
|
|
46
57
|
className={cn("navds-guide-panel", className, {
|
|
@@ -81,7 +92,7 @@ export const GuidePanel = forwardRef<HTMLDivElement, GuidePanelProps>(
|
|
|
81
92
|
fillRule="evenodd"
|
|
82
93
|
clipRule="evenodd"
|
|
83
94
|
d="M0 20C-2.87106e-10 19.9934 3.21047e-05 19.987 9.68646e-05 19.9804C0.0494722 14.9659 0.299239 11.5341 0.964025 8.68212C1.64231 5.77217 2.72947 3.56367 4.28501 0.971094C4.71185 0.259692 5.53358 -0.114327 6.35038 0.0310157C7.16718 0.176359 7.80944 0.810884 7.96467 1.62586C8.84145 6.22896 11.9453 10.3172 16.2599 13.2908C20.5715 16.2623 25.9294 18.0001 31 18.0001C32.1046 18.0001 33 18.8954 33 20L0 20ZM6.755 4.70521C8.97688 10.7068 14.4934 15.469 20.8803 18.0001C24.1345 19.2897 27.6146 20.0001 31 20.0001L2 20.0001C2.00689 19.3003 2.01774 18.6346 2.033 18.0001C2.19625 11.2107 2.86405 7.98363 4.58479 4.54371C4.9944 3.72487 5.46367 2.89399 6 2.00011C6.17639 2.92619 6.43058 3.82889 6.755 4.70521Z"
|
|
84
|
-
fill="var(--ax-border-
|
|
95
|
+
fill="var(--ax-border-default)"
|
|
85
96
|
/>
|
|
86
97
|
</svg>
|
|
87
98
|
)}
|
|
@@ -16,12 +16,7 @@ export const DarksideGudiepanelIllustration = () => {
|
|
|
16
16
|
role="img"
|
|
17
17
|
>
|
|
18
18
|
<g clipPath="url(#clip0_1387_21067)">
|
|
19
|
-
<rect
|
|
20
|
-
width="80"
|
|
21
|
-
height="80"
|
|
22
|
-
rx="40"
|
|
23
|
-
fill="var(--ax-bg-info-moderate)"
|
|
24
|
-
/>
|
|
19
|
+
<rect width="80" height="80" rx="40" fill="var(--ax-bg-moderate)" />
|
|
25
20
|
|
|
26
21
|
<path
|
|
27
22
|
fillRule="evenodd"
|
|
@@ -44,6 +44,7 @@ export const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
|
|
|
44
44
|
title,
|
|
45
45
|
onClick,
|
|
46
46
|
wrapperClassName,
|
|
47
|
+
"data-color": color = "info",
|
|
47
48
|
...rest
|
|
48
49
|
},
|
|
49
50
|
ref,
|
|
@@ -58,7 +59,10 @@ export const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
|
|
|
58
59
|
const titleWithFallback = title || translate("title");
|
|
59
60
|
|
|
60
61
|
return (
|
|
61
|
-
<div
|
|
62
|
+
<div
|
|
63
|
+
className={cn("navds-help-text", wrapperClassName)}
|
|
64
|
+
data-color={color}
|
|
65
|
+
>
|
|
62
66
|
<button
|
|
63
67
|
{...rest}
|
|
64
68
|
ref={mergedRef}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
AkselColoredBorderToken,
|
|
4
|
+
AkselColoredStatelessBackgroundToken,
|
|
5
|
+
AkselRootBackgroundToken,
|
|
6
|
+
AkselRootBorderToken,
|
|
7
|
+
AkselShadowToken,
|
|
8
8
|
} from "@navikt/ds-tokens/types";
|
|
9
9
|
import { Slot } from "../../slot/Slot";
|
|
10
10
|
import { useRenameCSS } from "../../theme/Theme";
|
|
@@ -28,13 +28,15 @@ export type BoxNewProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
28
28
|
* Accepts a [background/surface color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#afff774dad80).
|
|
29
29
|
* @see {@link StaticDefaultBgKeys} and {@link StaticBgKeys}
|
|
30
30
|
*/
|
|
31
|
-
background?:
|
|
31
|
+
background?: AkselRootBackgroundToken | AkselColoredStatelessBackgroundToken;
|
|
32
32
|
/**
|
|
33
33
|
* CSS `border-color` property.
|
|
34
34
|
* Accepts a [border color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#adb1767e2f87).
|
|
35
35
|
* @see {@link BorderColorKeys} and {@link BorderColorWithRoleKeys}
|
|
36
36
|
*/
|
|
37
|
-
borderColor?:
|
|
37
|
+
borderColor?:
|
|
38
|
+
| Exclude<AkselRootBorderToken, "focus">
|
|
39
|
+
| AkselColoredBorderToken;
|
|
38
40
|
/**
|
|
39
41
|
* CSS `border-radius` property.
|
|
40
42
|
* Accepts a [radius token](https://aksel.nav.no/grunnleggende/styling/design-tokens#6d79c5605d31)
|
|
@@ -60,7 +62,7 @@ export type BoxNewProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
60
62
|
* shadow='small'
|
|
61
63
|
* @see {@link ShadowKeys}
|
|
62
64
|
*/
|
|
63
|
-
shadow?:
|
|
65
|
+
shadow?: AkselShadowToken;
|
|
64
66
|
} & PrimitiveProps &
|
|
65
67
|
PrimitiveAsChildProps;
|
|
66
68
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
AkselBorderRadiusToken,
|
|
3
|
+
AkselLegacyBorderRadiusToken,
|
|
4
|
+
AkselLegacySpacingToken,
|
|
5
|
+
AkselSpaceToken,
|
|
6
6
|
} from "@navikt/ds-tokens/types";
|
|
7
7
|
import { ResponsiveProp } from "./types";
|
|
8
8
|
|
|
@@ -34,8 +34,8 @@ export function getResponsiveValue<T = string>(
|
|
|
34
34
|
* Temporary lookup for mapping legacy spacing tokens to new space tokens.
|
|
35
35
|
*/
|
|
36
36
|
const legacySpacingTokenLookup: Record<
|
|
37
|
-
`--ax-spacing-${
|
|
38
|
-
`--ax-${
|
|
37
|
+
`--ax-spacing-${AkselLegacySpacingToken}`,
|
|
38
|
+
`--ax-${AkselSpaceToken}`
|
|
39
39
|
> = {
|
|
40
40
|
"--ax-spacing-32": "--ax-space-128",
|
|
41
41
|
"--ax-spacing-24": "--ax-space-96",
|
|
@@ -61,8 +61,8 @@ const legacySpacingTokenLookup: Record<
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const legacyBorderRadiusNameTokenLookup: Record<
|
|
64
|
-
`${
|
|
65
|
-
`${
|
|
64
|
+
`${AkselLegacyBorderRadiusToken}`,
|
|
65
|
+
`${AkselBorderRadiusToken}`
|
|
66
66
|
> = {
|
|
67
67
|
full: "full",
|
|
68
68
|
xlarge: "12",
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
AkselBorderRadiusToken,
|
|
3
|
+
AkselBreakpointToken,
|
|
4
|
+
AkselLegacyBackgroundColorToken,
|
|
5
|
+
AkselLegacyBorderColorToken,
|
|
6
|
+
AkselLegacyBorderRadiusToken,
|
|
7
|
+
AkselLegacyShadowToken,
|
|
8
|
+
AkselLegacySpacingToken,
|
|
9
|
+
AkselLegacySurfaceColorToken,
|
|
10
|
+
AkselSpaceToken,
|
|
11
11
|
} from "@navikt/ds-tokens/types";
|
|
12
12
|
|
|
13
|
-
export type BackgroundColorToken =
|
|
14
|
-
export type SurfaceColorToken =
|
|
15
|
-
export type BorderColorToken =
|
|
16
|
-
export type ShadowToken =
|
|
13
|
+
export type BackgroundColorToken = AkselLegacyBackgroundColorToken;
|
|
14
|
+
export type SurfaceColorToken = AkselLegacySurfaceColorToken;
|
|
15
|
+
export type BorderColorToken = AkselLegacyBorderColorToken;
|
|
16
|
+
export type ShadowToken = AkselLegacyShadowToken;
|
|
17
17
|
|
|
18
18
|
export type BreakpointsAlias = Extract<
|
|
19
|
-
|
|
19
|
+
AkselBreakpointToken,
|
|
20
20
|
"xs" | "sm" | "md" | "lg" | "xl" | "2xl"
|
|
21
21
|
>;
|
|
22
22
|
|
|
23
|
-
export type SpacingScale =
|
|
24
|
-
export type BorderRadiusScale =
|
|
23
|
+
export type SpacingScale = AkselLegacySpacingToken | AkselSpaceToken;
|
|
24
|
+
export type BorderRadiusScale =
|
|
25
|
+
| AkselLegacyBorderRadiusToken
|
|
26
|
+
| AkselBorderRadiusToken;
|
|
25
27
|
|
|
26
28
|
export type SpaceDelimitedAttribute<T extends string> =
|
|
27
29
|
| T
|
package/src/link/Link.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
|
-
import { useRenameCSS } from "../theme/Theme";
|
|
2
|
+
import { useRenameCSS, useThemeInternal } from "../theme/Theme";
|
|
3
|
+
import { AkselColor } from "../types";
|
|
3
4
|
import { OverridableComponent } from "../util/types";
|
|
4
5
|
|
|
5
6
|
export interface LinkProps
|
|
@@ -56,18 +57,35 @@ export const Link: OverridableComponent<LinkProps, HTMLAnchorElement> =
|
|
|
56
57
|
as: Component = "a",
|
|
57
58
|
className,
|
|
58
59
|
underline = true,
|
|
59
|
-
variant
|
|
60
|
+
variant,
|
|
60
61
|
inlineText = false,
|
|
62
|
+
"data-color": color,
|
|
61
63
|
...rest
|
|
62
64
|
},
|
|
63
65
|
ref,
|
|
64
66
|
) => {
|
|
67
|
+
const themeContext = useThemeInternal(false);
|
|
65
68
|
const { cn } = useRenameCSS();
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
* We avoid defaulting to "action" in darkside.
|
|
72
|
+
*/
|
|
73
|
+
let localVariant: LinkProps["variant"];
|
|
74
|
+
|
|
75
|
+
if (themeContext) {
|
|
76
|
+
localVariant = variant;
|
|
77
|
+
} else {
|
|
78
|
+
localVariant = variant ?? "action";
|
|
79
|
+
}
|
|
80
|
+
|
|
66
81
|
return (
|
|
67
82
|
<Component
|
|
83
|
+
data-color={color ?? variantToColor(localVariant)}
|
|
84
|
+
data-variant={localVariant}
|
|
68
85
|
{...rest}
|
|
69
86
|
ref={ref}
|
|
70
|
-
className={cn("navds-link", className,
|
|
87
|
+
className={cn("navds-link", className, {
|
|
88
|
+
[`navds-link--${localVariant}`]: localVariant,
|
|
71
89
|
"navds-link--remove-underline": !underline,
|
|
72
90
|
"navds-link--inline-text": inlineText,
|
|
73
91
|
})}
|
|
@@ -76,4 +94,19 @@ export const Link: OverridableComponent<LinkProps, HTMLAnchorElement> =
|
|
|
76
94
|
},
|
|
77
95
|
);
|
|
78
96
|
|
|
97
|
+
function variantToColor(
|
|
98
|
+
variant?: LinkProps["variant"],
|
|
99
|
+
): AkselColor | undefined {
|
|
100
|
+
switch (variant) {
|
|
101
|
+
case "action":
|
|
102
|
+
return "accent";
|
|
103
|
+
case "neutral":
|
|
104
|
+
return "neutral";
|
|
105
|
+
case "subtle":
|
|
106
|
+
return "neutral";
|
|
107
|
+
default:
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
79
112
|
export default Link;
|
package/src/loader/Loader.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { SVGProps, forwardRef } from "react";
|
|
2
2
|
import { useRenameCSS } from "../theme/Theme";
|
|
3
|
+
import { AkselColor } from "../types";
|
|
3
4
|
import { omit } from "../util";
|
|
4
5
|
import { useId } from "../util/hooks";
|
|
5
6
|
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
@@ -33,6 +34,10 @@ export interface LoaderProps extends Omit<SVGProps<SVGSVGElement>, "ref"> {
|
|
|
33
34
|
* @default "neutral"
|
|
34
35
|
*/
|
|
35
36
|
variant?: "neutral" | "interaction" | "inverted";
|
|
37
|
+
/**
|
|
38
|
+
* Overrides loader-color
|
|
39
|
+
*/
|
|
40
|
+
"data-color"?: AkselColor;
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
/* Workaround for @types/react v17/v18 feil */
|
|
@@ -60,6 +65,7 @@ export const Loader: LoaderType = forwardRef<SVGSVGElement, LoaderProps>(
|
|
|
60
65
|
transparent = false,
|
|
61
66
|
variant = "neutral",
|
|
62
67
|
id,
|
|
68
|
+
"data-color": color,
|
|
63
69
|
...rest
|
|
64
70
|
},
|
|
65
71
|
ref,
|
|
@@ -84,7 +90,9 @@ export const Loader: LoaderType = forwardRef<SVGSVGElement, LoaderProps>(
|
|
|
84
90
|
focusable="false"
|
|
85
91
|
viewBox="0 0 50 50"
|
|
86
92
|
preserveAspectRatio="xMidYMid"
|
|
93
|
+
data-color={color ?? variantToColor(variant)}
|
|
87
94
|
{...omit(rest, ["children"])}
|
|
95
|
+
data-variant={variant}
|
|
88
96
|
>
|
|
89
97
|
<title id={id ?? `loader-${internalId}`}>
|
|
90
98
|
{title || translate("title")}
|
|
@@ -110,4 +118,20 @@ export const Loader: LoaderType = forwardRef<SVGSVGElement, LoaderProps>(
|
|
|
110
118
|
},
|
|
111
119
|
);
|
|
112
120
|
|
|
121
|
+
function variantToColor(
|
|
122
|
+
variant: LoaderProps["variant"],
|
|
123
|
+
): AkselColor | undefined {
|
|
124
|
+
switch (variant) {
|
|
125
|
+
case "neutral":
|
|
126
|
+
return "neutral";
|
|
127
|
+
case "inverted":
|
|
128
|
+
return "neutral";
|
|
129
|
+
/* We assume "interaction" is the main app color in this instance */
|
|
130
|
+
case "interaction":
|
|
131
|
+
return undefined;
|
|
132
|
+
default:
|
|
133
|
+
return "neutral";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
113
137
|
export default Loader;
|