@navikt/ds-react 5.6.0-beta.0 → 5.6.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/_docs.json +1495 -652
- package/cjs/accordion/Accordion.js +1 -0
- package/cjs/accordion/AccordionContext.js +1 -1
- package/cjs/accordion/AccordionHeader.js +2 -2
- package/cjs/accordion/AccordionItem.js +3 -0
- package/cjs/date/datepicker/DatePicker.js +30 -34
- package/cjs/date/datepicker/DatePickerStandalone.js +23 -26
- package/cjs/date/datepicker/parts/Caption.js +28 -0
- package/cjs/date/datepicker/{DayButton.js → parts/DayButton.js} +1 -2
- package/cjs/date/datepicker/{caption → parts}/DropdownCaption.js +13 -7
- package/cjs/date/datepicker/parts/HeadRow.js +36 -0
- package/cjs/date/datepicker/parts/Row.js +23 -0
- package/cjs/date/datepicker/{TableHead.js → parts/TableHead.js} +4 -3
- package/cjs/date/datepicker/parts/WeekNumber.js +35 -0
- package/cjs/date/datepicker/parts/WeekRow.js +34 -0
- package/cjs/date/utils/get-month-weeks.js +46 -0
- package/cjs/date/utils/labels.js +40 -1
- package/cjs/index.js +1 -0
- package/cjs/layout/bleed/Bleed.js +25 -5
- package/cjs/layout/bleed/index.js +1 -4
- package/cjs/layout/box/Box.js +1 -1
- package/cjs/layout/responsive/Responsive.js +8 -6
- package/cjs/layout/utilities/css.js +37 -14
- package/esm/accordion/Accordion.js +1 -0
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/accordion/AccordionContext.d.ts +1 -0
- package/esm/accordion/AccordionContext.js +1 -1
- package/esm/accordion/AccordionContext.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +2 -2
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.js +3 -0
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +14 -5
- package/esm/date/datepicker/DatePicker.js +29 -33
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.d.ts +3 -2
- package/esm/date/datepicker/DatePickerStandalone.js +22 -25
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/datepicker/{caption → parts}/Caption.d.ts +3 -0
- package/esm/date/datepicker/parts/Caption.js +22 -0
- package/esm/date/datepicker/parts/Caption.js.map +1 -0
- package/esm/date/datepicker/parts/DayButton.d.ts +4 -0
- package/esm/date/datepicker/{DayButton.js → parts/DayButton.js} +2 -1
- package/esm/date/datepicker/parts/DayButton.js.map +1 -0
- package/esm/date/datepicker/{caption → parts}/DropdownCaption.d.ts +3 -0
- package/esm/date/datepicker/parts/DropdownCaption.js +44 -0
- package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -0
- package/esm/date/datepicker/parts/HeadRow.d.ts +11 -0
- package/esm/date/datepicker/parts/HeadRow.js +29 -0
- package/esm/date/datepicker/parts/HeadRow.js.map +1 -0
- package/esm/date/datepicker/parts/Row.d.ts +17 -0
- package/esm/date/datepicker/parts/Row.js +19 -0
- package/esm/date/datepicker/parts/Row.js.map +1 -0
- package/esm/date/datepicker/parts/TableHead.d.ts +6 -0
- package/esm/date/datepicker/{TableHead.js → parts/TableHead.js} +5 -2
- package/esm/date/datepicker/parts/TableHead.js.map +1 -0
- package/esm/date/datepicker/parts/WeekNumber.d.ts +13 -0
- package/esm/date/datepicker/parts/WeekNumber.js +31 -0
- package/esm/date/datepicker/parts/WeekNumber.js.map +1 -0
- package/esm/date/datepicker/parts/WeekRow.d.ts +5 -0
- package/esm/date/datepicker/parts/WeekRow.js +30 -0
- package/esm/date/datepicker/parts/WeekRow.js.map +1 -0
- package/esm/date/utils/get-month-weeks.d.ts +16 -0
- package/esm/date/utils/get-month-weeks.js +42 -0
- package/esm/date/utils/get-month-weeks.js.map +1 -0
- package/esm/date/utils/labels.d.ts +9 -0
- package/esm/date/utils/labels.js +36 -0
- package/esm/date/utils/labels.js.map +1 -1
- package/esm/form/Fieldset/useFieldset.d.ts +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/radio/useRadio.d.ts +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/layout/bleed/Bleed.d.ts +46 -7
- package/esm/layout/bleed/Bleed.js +25 -5
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/bleed/index.d.ts +1 -1
- package/esm/layout/bleed/index.js +1 -1
- package/esm/layout/bleed/index.js.map +1 -1
- package/esm/layout/box/Box.js +1 -1
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/responsive/Responsive.d.ts +8 -4
- package/esm/layout/responsive/Responsive.js +8 -6
- package/esm/layout/responsive/Responsive.js.map +1 -1
- package/esm/layout/utilities/css.d.ts +1 -1
- package/esm/layout/utilities/css.js +37 -14
- package/esm/layout/utilities/css.js.map +1 -1
- package/package.json +5 -4
- package/src/accordion/Accordion.tsx +1 -0
- package/src/accordion/AccordionContext.tsx +2 -1
- package/src/accordion/AccordionHeader.tsx +2 -2
- package/src/accordion/AccordionItem.tsx +4 -0
- package/src/date/datepicker/DatePicker.tsx +63 -58
- package/src/date/datepicker/DatePickerStandalone.tsx +36 -37
- package/src/date/datepicker/datepicker.stories.tsx +66 -1
- package/src/date/datepicker/{caption → parts}/Caption.tsx +19 -17
- package/src/date/datepicker/{DayButton.tsx → parts/DayButton.tsx} +3 -1
- package/src/date/datepicker/parts/DropdownCaption.tsx +113 -0
- package/src/date/datepicker/parts/HeadRow.tsx +56 -0
- package/src/date/datepicker/parts/Row.tsx +47 -0
- package/src/date/datepicker/{TableHead.tsx → parts/TableHead.tsx} +6 -2
- package/src/date/datepicker/parts/WeekNumber.tsx +79 -0
- package/src/date/datepicker/parts/WeekRow.tsx +60 -0
- package/src/date/utils/__tests__/get-month-weeks.test.ts +113 -0
- package/src/date/utils/get-month-weeks.ts +93 -0
- package/src/date/utils/labels.ts +51 -0
- package/src/index.ts +1 -0
- package/src/layout/bleed/Bleed.stories.tsx +381 -0
- package/src/layout/bleed/Bleed.tsx +130 -0
- package/src/layout/bleed/index.ts +1 -0
- package/src/layout/box/Box.tsx +1 -0
- package/src/layout/responsive/Responsive.tsx +21 -6
- package/src/layout/responsive/hide.stories.tsx +35 -0
- package/src/layout/responsive/show.stories.tsx +35 -0
- package/src/layout/utilities/css.ts +59 -19
- package/cjs/date/datepicker/caption/Caption.js +0 -23
- package/cjs/date/datepicker/caption/index.js +0 -10
- package/cjs/date/datepicker/caption/package.json +0 -6
- package/cjs/layout/content-box/ContentBox.js +0 -56
- package/cjs/layout/content-box/index.js +0 -8
- package/cjs/layout/content-box/package.json +0 -6
- package/cjs/layout/page-demo/AvatarPanel.js +0 -18
- package/cjs/layout/page-demo/Filter.js +0 -21
- package/cjs/layout/page-demo/Header.js +0 -48
- package/cjs/layout/page-demo/Intro.js +0 -36
- package/cjs/layout/page-demo/Sidebar.js +0 -49
- package/esm/date/datepicker/DayButton.d.ts +0 -3
- package/esm/date/datepicker/DayButton.js.map +0 -1
- package/esm/date/datepicker/TableHead.d.ts +0 -3
- package/esm/date/datepicker/TableHead.js.map +0 -1
- package/esm/date/datepicker/caption/Caption.js +0 -17
- package/esm/date/datepicker/caption/Caption.js.map +0 -1
- package/esm/date/datepicker/caption/DropdownCaption.js +0 -38
- package/esm/date/datepicker/caption/DropdownCaption.js.map +0 -1
- package/esm/date/datepicker/caption/index.d.ts +0 -2
- package/esm/date/datepicker/caption/index.js +0 -3
- package/esm/date/datepicker/caption/index.js.map +0 -1
- package/esm/layout/content-box/ContentBox.d.ts +0 -8
- package/esm/layout/content-box/ContentBox.js +0 -28
- package/esm/layout/content-box/ContentBox.js.map +0 -1
- package/esm/layout/content-box/index.d.ts +0 -1
- package/esm/layout/content-box/index.js +0 -2
- package/esm/layout/content-box/index.js.map +0 -1
- package/esm/layout/page-demo/AvatarPanel.d.ts +0 -4
- package/esm/layout/page-demo/AvatarPanel.js +0 -12
- package/esm/layout/page-demo/AvatarPanel.js.map +0 -1
- package/esm/layout/page-demo/Filter.d.ts +0 -2
- package/esm/layout/page-demo/Filter.js +0 -15
- package/esm/layout/page-demo/Filter.js.map +0 -1
- package/esm/layout/page-demo/Header.d.ts +0 -2
- package/esm/layout/page-demo/Header.js +0 -42
- package/esm/layout/page-demo/Header.js.map +0 -1
- package/esm/layout/page-demo/Intro.d.ts +0 -2
- package/esm/layout/page-demo/Intro.js +0 -30
- package/esm/layout/page-demo/Intro.js.map +0 -1
- package/esm/layout/page-demo/Sidebar.d.ts +0 -4
- package/esm/layout/page-demo/Sidebar.js +0 -41
- package/esm/layout/page-demo/Sidebar.js.map +0 -1
- package/src/date/datepicker/caption/DropdownCaption.tsx +0 -108
- package/src/date/datepicker/caption/index.ts +0 -2
package/src/date/utils/labels.ts
CHANGED
|
@@ -82,3 +82,54 @@ export const labels: Partial<Labels> = {
|
|
|
82
82
|
labelNext,
|
|
83
83
|
labelPrevious,
|
|
84
84
|
};
|
|
85
|
+
|
|
86
|
+
export const labelWeekNumber = ({
|
|
87
|
+
localeCode,
|
|
88
|
+
week,
|
|
89
|
+
}: {
|
|
90
|
+
localeCode?: string;
|
|
91
|
+
week: number;
|
|
92
|
+
}): string => {
|
|
93
|
+
switch (localeCode) {
|
|
94
|
+
case "nb":
|
|
95
|
+
return `Uke ${week}`;
|
|
96
|
+
case "nn":
|
|
97
|
+
return `Veke ${week}`;
|
|
98
|
+
case "en-GB":
|
|
99
|
+
return `Week ${week}`;
|
|
100
|
+
default:
|
|
101
|
+
return `Uke ${week}`;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const labelWeekNumberButton = ({
|
|
106
|
+
localeCode,
|
|
107
|
+
week,
|
|
108
|
+
}: {
|
|
109
|
+
localeCode?: string;
|
|
110
|
+
week: number;
|
|
111
|
+
}): string => {
|
|
112
|
+
switch (localeCode) {
|
|
113
|
+
case "nb":
|
|
114
|
+
return `Velg uke ${week}`;
|
|
115
|
+
case "nn":
|
|
116
|
+
return `Vel veke ${week}`;
|
|
117
|
+
case "en-GB":
|
|
118
|
+
return `Pick week ${week}`;
|
|
119
|
+
default:
|
|
120
|
+
return `Velg uke ${week}`;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const labelWeek = (localeCode?: string): string => {
|
|
125
|
+
switch (localeCode) {
|
|
126
|
+
case "nb":
|
|
127
|
+
return `Uke:`;
|
|
128
|
+
case "nn":
|
|
129
|
+
return `Veke:`;
|
|
130
|
+
case "en-GB":
|
|
131
|
+
return `Week:`;
|
|
132
|
+
default:
|
|
133
|
+
return `Uke:`;
|
|
134
|
+
}
|
|
135
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Meta } from "@storybook/react";
|
|
3
|
+
import { BodyLong } from "../../typography";
|
|
4
|
+
import { Bleed } from "./Bleed";
|
|
5
|
+
import { Box, HStack, VStack } from "../..";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "ds-react/Primitives/Bleed",
|
|
9
|
+
component: Bleed,
|
|
10
|
+
} satisfies Meta<typeof Bleed>;
|
|
11
|
+
|
|
12
|
+
export const Default = {
|
|
13
|
+
render: () => (
|
|
14
|
+
<>
|
|
15
|
+
<VStack gap="2">
|
|
16
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
17
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
18
|
+
<Bleed marginInline="10 0">
|
|
19
|
+
<Box
|
|
20
|
+
padding="3"
|
|
21
|
+
className="p"
|
|
22
|
+
background="surface-success-subtle"
|
|
23
|
+
>
|
|
24
|
+
<BodyLong>marginInline="10 0"</BodyLong>
|
|
25
|
+
</Box>
|
|
26
|
+
</Bleed>
|
|
27
|
+
</Box>
|
|
28
|
+
</Box>
|
|
29
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
30
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
31
|
+
<Bleed marginInline="0 10">
|
|
32
|
+
<Box
|
|
33
|
+
padding="3"
|
|
34
|
+
className="p"
|
|
35
|
+
background="surface-success-subtle"
|
|
36
|
+
>
|
|
37
|
+
<BodyLong>marginInline="0 10"</BodyLong>
|
|
38
|
+
</Box>
|
|
39
|
+
</Bleed>
|
|
40
|
+
</Box>
|
|
41
|
+
</Box>
|
|
42
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
43
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
44
|
+
<Bleed marginBlock="10 0">
|
|
45
|
+
<Box
|
|
46
|
+
padding="3"
|
|
47
|
+
className="p"
|
|
48
|
+
background="surface-success-subtle"
|
|
49
|
+
>
|
|
50
|
+
<BodyLong>marginBlock="10 0"</BodyLong>
|
|
51
|
+
</Box>
|
|
52
|
+
</Bleed>
|
|
53
|
+
</Box>
|
|
54
|
+
</Box>
|
|
55
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
56
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
57
|
+
<Bleed marginBlock="0 10">
|
|
58
|
+
<Box
|
|
59
|
+
padding="3"
|
|
60
|
+
className="p"
|
|
61
|
+
background="surface-success-subtle"
|
|
62
|
+
>
|
|
63
|
+
<BodyLong>marginBlock="0 10"</BodyLong>
|
|
64
|
+
</Box>
|
|
65
|
+
</Bleed>
|
|
66
|
+
</Box>
|
|
67
|
+
</Box>
|
|
68
|
+
</VStack>
|
|
69
|
+
</>
|
|
70
|
+
),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const AsChild = {
|
|
74
|
+
render: () => (
|
|
75
|
+
<>
|
|
76
|
+
<VStack gap="2">
|
|
77
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
78
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
79
|
+
<Bleed marginInline="10 0" asChild>
|
|
80
|
+
<Box padding="3" background="surface-success-subtle">
|
|
81
|
+
<BodyLong>marginInline="10 0"</BodyLong>
|
|
82
|
+
</Box>
|
|
83
|
+
</Bleed>
|
|
84
|
+
</Box>
|
|
85
|
+
</Box>
|
|
86
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
87
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
88
|
+
<Bleed marginInline="0 10" asChild>
|
|
89
|
+
<Box padding="3" background="surface-success-subtle">
|
|
90
|
+
<BodyLong>marginInline="0 10"</BodyLong>
|
|
91
|
+
</Box>
|
|
92
|
+
</Bleed>
|
|
93
|
+
</Box>
|
|
94
|
+
</Box>
|
|
95
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
96
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
97
|
+
<Bleed marginBlock="10 0" asChild>
|
|
98
|
+
<Box padding="3" background="surface-success-subtle">
|
|
99
|
+
<BodyLong>marginBlock="10 0"</BodyLong>
|
|
100
|
+
</Box>
|
|
101
|
+
</Bleed>
|
|
102
|
+
</Box>
|
|
103
|
+
</Box>
|
|
104
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
105
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
106
|
+
<Bleed marginBlock="0 10" asChild>
|
|
107
|
+
<Box padding="3" background="surface-success-subtle">
|
|
108
|
+
<BodyLong>marginBlock="0 10"</BodyLong>
|
|
109
|
+
</Box>
|
|
110
|
+
</Bleed>
|
|
111
|
+
</Box>
|
|
112
|
+
</Box>
|
|
113
|
+
</VStack>
|
|
114
|
+
</>
|
|
115
|
+
),
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const Breakpoints = {
|
|
119
|
+
render: () => (
|
|
120
|
+
<>
|
|
121
|
+
<VStack gap="2">
|
|
122
|
+
<Box background="surface-alt-1-subtle" padding={{ xs: "5", md: "10" }}>
|
|
123
|
+
<Box
|
|
124
|
+
background="surface-alt-2-subtle"
|
|
125
|
+
padding={{ xs: "5", md: "10" }}
|
|
126
|
+
>
|
|
127
|
+
<Bleed marginInline={{ xs: "10 0", md: "20 0" }}>
|
|
128
|
+
<Box padding="3" background="surface-success-subtle">
|
|
129
|
+
<BodyLong>
|
|
130
|
+
{'marginInline={{ xs: "10 0", md: "20 0" }}'}
|
|
131
|
+
</BodyLong>
|
|
132
|
+
</Box>
|
|
133
|
+
</Bleed>
|
|
134
|
+
</Box>
|
|
135
|
+
</Box>
|
|
136
|
+
<Box background="surface-alt-1-subtle" padding={{ xs: "5", md: "10" }}>
|
|
137
|
+
<Box
|
|
138
|
+
background="surface-alt-2-subtle"
|
|
139
|
+
padding={{ xs: "5", md: "10" }}
|
|
140
|
+
>
|
|
141
|
+
<Bleed marginInline={{ xs: "0 10", md: "0 20" }}>
|
|
142
|
+
<Box padding="3" background="surface-success-subtle">
|
|
143
|
+
<BodyLong>
|
|
144
|
+
{'marginInline={{ xs: "0 10", md: "0 20" }}'}
|
|
145
|
+
</BodyLong>
|
|
146
|
+
</Box>
|
|
147
|
+
</Bleed>
|
|
148
|
+
</Box>
|
|
149
|
+
</Box>
|
|
150
|
+
<Box background="surface-alt-1-subtle" padding={{ xs: "5", md: "10" }}>
|
|
151
|
+
<Box
|
|
152
|
+
background="surface-alt-2-subtle"
|
|
153
|
+
padding={{ xs: "5", md: "10" }}
|
|
154
|
+
>
|
|
155
|
+
<Bleed marginBlock={{ xs: "10 0", md: "20 0" }}>
|
|
156
|
+
<Box padding="3" background="surface-success-subtle">
|
|
157
|
+
<BodyLong>
|
|
158
|
+
{'marginBlock={{ xs: "10 0", md: "20 0" }}'}
|
|
159
|
+
</BodyLong>
|
|
160
|
+
</Box>
|
|
161
|
+
</Bleed>
|
|
162
|
+
</Box>
|
|
163
|
+
</Box>
|
|
164
|
+
<Box background="surface-alt-1-subtle" padding={{ xs: "5", md: "10" }}>
|
|
165
|
+
<Box
|
|
166
|
+
background="surface-alt-2-subtle"
|
|
167
|
+
padding={{ xs: "5", md: "10" }}
|
|
168
|
+
>
|
|
169
|
+
<Bleed marginBlock={{ xs: "0 10", md: "0 20" }}>
|
|
170
|
+
<Box padding="3" background="surface-success-subtle">
|
|
171
|
+
<BodyLong>
|
|
172
|
+
{'marginBlock={{ xs: "0 10", md: "0 20" }}'}
|
|
173
|
+
</BodyLong>
|
|
174
|
+
</Box>
|
|
175
|
+
</Bleed>
|
|
176
|
+
</Box>
|
|
177
|
+
</Box>
|
|
178
|
+
</VStack>
|
|
179
|
+
</>
|
|
180
|
+
),
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const Px = {
|
|
184
|
+
render: () => (
|
|
185
|
+
<>
|
|
186
|
+
<style>
|
|
187
|
+
{`
|
|
188
|
+
.circle {
|
|
189
|
+
width: 24px;
|
|
190
|
+
height: 24px;
|
|
191
|
+
display: flex;
|
|
192
|
+
align-items: center;
|
|
193
|
+
justify-content: center;
|
|
194
|
+
}
|
|
195
|
+
.scale {
|
|
196
|
+
transform: scale(5);
|
|
197
|
+
}
|
|
198
|
+
`}
|
|
199
|
+
</style>
|
|
200
|
+
<Box padding="32">
|
|
201
|
+
<HStack className="" gap="32">
|
|
202
|
+
<Box
|
|
203
|
+
className="circle scale"
|
|
204
|
+
background="surface-success-subtle"
|
|
205
|
+
borderRadius="full"
|
|
206
|
+
>
|
|
207
|
+
L
|
|
208
|
+
</Box>
|
|
209
|
+
<Box
|
|
210
|
+
className="circle scale"
|
|
211
|
+
background="surface-success-subtle"
|
|
212
|
+
borderRadius="full"
|
|
213
|
+
>
|
|
214
|
+
<Bleed marginInline="0 px">L</Bleed>
|
|
215
|
+
</Box>
|
|
216
|
+
</HStack>
|
|
217
|
+
</Box>
|
|
218
|
+
</>
|
|
219
|
+
),
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const Full = {
|
|
223
|
+
parameters: {
|
|
224
|
+
layout: "fullscreen",
|
|
225
|
+
},
|
|
226
|
+
render: () => (
|
|
227
|
+
<>
|
|
228
|
+
<style>
|
|
229
|
+
{`
|
|
230
|
+
.maxWidth {
|
|
231
|
+
max-width: 300px;
|
|
232
|
+
}
|
|
233
|
+
`}
|
|
234
|
+
</style>
|
|
235
|
+
<VStack gap="2" align="center">
|
|
236
|
+
<Box
|
|
237
|
+
className="maxWidth"
|
|
238
|
+
background="surface-alt-1-subtle"
|
|
239
|
+
padding="10"
|
|
240
|
+
>
|
|
241
|
+
<Box background="surface-alt-2-subtle" padding="10">
|
|
242
|
+
<Bleed marginInline="full">
|
|
243
|
+
<Box background="surface-success-subtle">
|
|
244
|
+
<BodyLong>marginInline="full"</BodyLong>
|
|
245
|
+
</Box>
|
|
246
|
+
</Bleed>
|
|
247
|
+
</Box>
|
|
248
|
+
</Box>
|
|
249
|
+
<Box
|
|
250
|
+
className="maxWidth"
|
|
251
|
+
background="surface-alt-1-subtle"
|
|
252
|
+
padding="10"
|
|
253
|
+
>
|
|
254
|
+
<Box background="surface-alt-2-subtle" padding="10">
|
|
255
|
+
<Bleed marginInline="full 0">
|
|
256
|
+
<Box background="surface-success-subtle">
|
|
257
|
+
<BodyLong>marginInline="full 0"</BodyLong>
|
|
258
|
+
</Box>
|
|
259
|
+
</Bleed>
|
|
260
|
+
</Box>
|
|
261
|
+
</Box>
|
|
262
|
+
<Box
|
|
263
|
+
className="maxWidth"
|
|
264
|
+
background="surface-alt-1-subtle"
|
|
265
|
+
padding="10"
|
|
266
|
+
>
|
|
267
|
+
<Box background="surface-alt-2-subtle" padding="10">
|
|
268
|
+
<Bleed marginInline="0 full">
|
|
269
|
+
<Box background="surface-success-subtle">
|
|
270
|
+
<BodyLong>marginInline="0 full"</BodyLong>
|
|
271
|
+
</Box>
|
|
272
|
+
</Bleed>
|
|
273
|
+
</Box>
|
|
274
|
+
</Box>
|
|
275
|
+
</VStack>
|
|
276
|
+
</>
|
|
277
|
+
),
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export const ReflectivePadding = {
|
|
281
|
+
render: () => (
|
|
282
|
+
<>
|
|
283
|
+
<style>
|
|
284
|
+
{`
|
|
285
|
+
.navds-bleed {
|
|
286
|
+
background-color: var(--a-surface-success-subtle);
|
|
287
|
+
width: fit-content;
|
|
288
|
+
}
|
|
289
|
+
`}
|
|
290
|
+
</style>
|
|
291
|
+
<HStack gap="3">
|
|
292
|
+
<VStack gap="2">
|
|
293
|
+
<p>CSS string</p>
|
|
294
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
295
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
296
|
+
<Bleed asChild>
|
|
297
|
+
<BodyLong>before Bleed</BodyLong>
|
|
298
|
+
</Bleed>
|
|
299
|
+
</Box>
|
|
300
|
+
</Box>
|
|
301
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
302
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
303
|
+
<Bleed marginInline="10 0" asChild>
|
|
304
|
+
<BodyLong>without reflectivePadding</BodyLong>
|
|
305
|
+
</Bleed>
|
|
306
|
+
</Box>
|
|
307
|
+
</Box>
|
|
308
|
+
<Box background="surface-alt-1-subtle" padding="5">
|
|
309
|
+
<Box background="surface-alt-2-subtle" padding="5">
|
|
310
|
+
<Bleed marginInline="10 0" reflectivePadding asChild>
|
|
311
|
+
<BodyLong>with reflectivePadding</BodyLong>
|
|
312
|
+
</Bleed>
|
|
313
|
+
</Box>
|
|
314
|
+
</Box>
|
|
315
|
+
</VStack>
|
|
316
|
+
|
|
317
|
+
<VStack gap="2">
|
|
318
|
+
<p>breakpoints</p>
|
|
319
|
+
<Box
|
|
320
|
+
background="surface-alt-1-subtle"
|
|
321
|
+
padding={{ xs: "2", sm: "4", md: "6", lg: "8", xl: "10" }}
|
|
322
|
+
>
|
|
323
|
+
<Box
|
|
324
|
+
background="surface-alt-2-subtle"
|
|
325
|
+
padding={{ xs: "2", sm: "4", md: "6", lg: "8", xl: "10" }}
|
|
326
|
+
>
|
|
327
|
+
<Bleed asChild>
|
|
328
|
+
<BodyLong>before Bleed</BodyLong>
|
|
329
|
+
</Bleed>
|
|
330
|
+
</Box>
|
|
331
|
+
</Box>
|
|
332
|
+
<Box
|
|
333
|
+
background="surface-alt-1-subtle"
|
|
334
|
+
padding={{ xs: "2", sm: "4", md: "6", lg: "8", xl: "10" }}
|
|
335
|
+
>
|
|
336
|
+
<Box
|
|
337
|
+
background="surface-alt-2-subtle"
|
|
338
|
+
padding={{ xs: "2", sm: "4", md: "6", lg: "8", xl: "10" }}
|
|
339
|
+
>
|
|
340
|
+
<Bleed
|
|
341
|
+
marginInline={{
|
|
342
|
+
xs: "4 0",
|
|
343
|
+
sm: "8 0",
|
|
344
|
+
md: "12 0",
|
|
345
|
+
lg: "16 0",
|
|
346
|
+
xl: "20 0",
|
|
347
|
+
}}
|
|
348
|
+
asChild
|
|
349
|
+
>
|
|
350
|
+
<BodyLong>without reflectivePadding</BodyLong>
|
|
351
|
+
</Bleed>
|
|
352
|
+
</Box>
|
|
353
|
+
</Box>
|
|
354
|
+
<Box
|
|
355
|
+
background="surface-alt-1-subtle"
|
|
356
|
+
padding={{ xs: "2", sm: "4", md: "6", lg: "8", xl: "10" }}
|
|
357
|
+
>
|
|
358
|
+
<Box
|
|
359
|
+
background="surface-alt-2-subtle"
|
|
360
|
+
padding={{ xs: "2", sm: "4", md: "6", lg: "8", xl: "10" }}
|
|
361
|
+
>
|
|
362
|
+
<Bleed
|
|
363
|
+
marginInline={{
|
|
364
|
+
xs: "4 0",
|
|
365
|
+
sm: "8 0",
|
|
366
|
+
md: "12 0",
|
|
367
|
+
lg: "16 0",
|
|
368
|
+
xl: "20 0",
|
|
369
|
+
}}
|
|
370
|
+
reflectivePadding
|
|
371
|
+
asChild
|
|
372
|
+
>
|
|
373
|
+
<BodyLong>with reflectivePadding</BodyLong>
|
|
374
|
+
</Bleed>
|
|
375
|
+
</Box>
|
|
376
|
+
</Box>
|
|
377
|
+
</VStack>
|
|
378
|
+
</HStack>
|
|
379
|
+
</>
|
|
380
|
+
),
|
|
381
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import {
|
|
4
|
+
ResponsiveProp,
|
|
5
|
+
SpacingScale,
|
|
6
|
+
getResponsiveProps,
|
|
7
|
+
} from "../utilities/css";
|
|
8
|
+
import { Slot } from "../../util/Slot";
|
|
9
|
+
|
|
10
|
+
export type BleedSpacingInline = "0" | "full" | "px" | SpacingScale;
|
|
11
|
+
export type BleedSpacingBlock = "0" | "px" | SpacingScale;
|
|
12
|
+
|
|
13
|
+
export interface BleedProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
/** **Negative** horizontal margin around children.
|
|
15
|
+
* Accepts a spacing token or an object of spacing tokens for different breakpoints.
|
|
16
|
+
* @example
|
|
17
|
+
* marginInline='4'
|
|
18
|
+
* marginInline='4 5'
|
|
19
|
+
* marginInline={{xs: '0 32', sm: '3', md: '4 5', lg: '5', xl: '6'}}
|
|
20
|
+
*/
|
|
21
|
+
marginInline?: ResponsiveProp<
|
|
22
|
+
BleedSpacingInline | `${BleedSpacingInline} ${BleedSpacingInline}`
|
|
23
|
+
>;
|
|
24
|
+
/** **Negative** vertical margin around children.
|
|
25
|
+
* Accepts a spacing token or an object of spacing tokens for different breakpoints.
|
|
26
|
+
* @example
|
|
27
|
+
* marginBlock='4'
|
|
28
|
+
* marginBlock='4 5'
|
|
29
|
+
* marginBlock={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
|
|
30
|
+
*/
|
|
31
|
+
marginBlock?: ResponsiveProp<
|
|
32
|
+
BleedSpacingBlock | `${BleedSpacingBlock} ${BleedSpacingBlock}`
|
|
33
|
+
>;
|
|
34
|
+
/**
|
|
35
|
+
* When true, set the padding to mirror the margin.
|
|
36
|
+
* This maintains the apparent width of the element prior to adding Bleed.
|
|
37
|
+
* When this is used with `asChild`, it will overwrite the padding of the child.
|
|
38
|
+
*/
|
|
39
|
+
reflectivePadding?: boolean;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* When true, the Bleed will render as its child. This merges classes, styles and event handlers.
|
|
43
|
+
*/
|
|
44
|
+
asChild?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Foundational Layout-primitive for generic encapsulation & styling.
|
|
49
|
+
*
|
|
50
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/Bleed)
|
|
51
|
+
* @see 🏷️ {@link BleedProps}
|
|
52
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* <Box padding="4">
|
|
56
|
+
* <Bleed marginInline="4" marginBlock="4">
|
|
57
|
+
* <BodyLong>Some content</BodyLong>
|
|
58
|
+
* </Bleed>
|
|
59
|
+
* </Box>
|
|
60
|
+
*/
|
|
61
|
+
export const Bleed = forwardRef<HTMLDivElement, BleedProps>(
|
|
62
|
+
(
|
|
63
|
+
{
|
|
64
|
+
className,
|
|
65
|
+
marginInline,
|
|
66
|
+
marginBlock,
|
|
67
|
+
reflectivePadding,
|
|
68
|
+
style: _style,
|
|
69
|
+
asChild,
|
|
70
|
+
...rest
|
|
71
|
+
},
|
|
72
|
+
ref
|
|
73
|
+
) => {
|
|
74
|
+
let style: React.CSSProperties = {
|
|
75
|
+
..._style,
|
|
76
|
+
...getResponsiveProps(
|
|
77
|
+
"bleed",
|
|
78
|
+
"margin-inline",
|
|
79
|
+
"spacing",
|
|
80
|
+
marginInline,
|
|
81
|
+
true,
|
|
82
|
+
["0", "full", "px"]
|
|
83
|
+
),
|
|
84
|
+
|
|
85
|
+
...getResponsiveProps(
|
|
86
|
+
"bleed",
|
|
87
|
+
"margin-block",
|
|
88
|
+
"spacing",
|
|
89
|
+
marginBlock,
|
|
90
|
+
true,
|
|
91
|
+
["0", "px"]
|
|
92
|
+
),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
if (reflectivePadding) {
|
|
96
|
+
style = {
|
|
97
|
+
...style,
|
|
98
|
+
...getResponsiveProps(
|
|
99
|
+
"bleed",
|
|
100
|
+
"padding-inline",
|
|
101
|
+
"spacing",
|
|
102
|
+
marginInline,
|
|
103
|
+
false,
|
|
104
|
+
["0", "full", "px"]
|
|
105
|
+
),
|
|
106
|
+
...getResponsiveProps(
|
|
107
|
+
"bleed",
|
|
108
|
+
"padding-block",
|
|
109
|
+
"spacing",
|
|
110
|
+
marginBlock,
|
|
111
|
+
false,
|
|
112
|
+
["0", "px"]
|
|
113
|
+
),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const Comp = asChild ? Slot : "div";
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<Comp
|
|
121
|
+
{...rest}
|
|
122
|
+
className={cl("navds-bleed", className, {
|
|
123
|
+
"navds-bleed--padding": reflectivePadding,
|
|
124
|
+
})}
|
|
125
|
+
ref={ref}
|
|
126
|
+
style={style}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Bleed, type BleedProps } from "./Bleed";
|
package/src/layout/box/Box.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, HTMLAttributes } from "react";
|
|
3
3
|
import { BreakpointsAlias } from "../utilities/css";
|
|
4
|
+
import { Slot } from "../../util/Slot";
|
|
4
5
|
|
|
5
6
|
export interface ResponsiveProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
7
|
children: React.ReactNode;
|
|
@@ -19,6 +20,10 @@ export interface ResponsiveProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
19
20
|
* @default "div"
|
|
20
21
|
*/
|
|
21
22
|
as?: "div" | "span";
|
|
23
|
+
/**
|
|
24
|
+
* When true, will render element as its child. This merges classes, styles and event handlers.
|
|
25
|
+
*/
|
|
26
|
+
asChild?: boolean;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
const Responsive = forwardRef<
|
|
@@ -26,14 +31,24 @@ const Responsive = forwardRef<
|
|
|
26
31
|
ResponsiveProps & { variant: "show" | "hide" }
|
|
27
32
|
>(
|
|
28
33
|
(
|
|
29
|
-
{
|
|
34
|
+
{
|
|
35
|
+
as: Component = "div",
|
|
36
|
+
className,
|
|
37
|
+
above,
|
|
38
|
+
below,
|
|
39
|
+
variant,
|
|
40
|
+
asChild,
|
|
41
|
+
...rest
|
|
42
|
+
},
|
|
30
43
|
ref
|
|
31
44
|
) => {
|
|
32
45
|
const aboveProp = variant === "show" ? above : below;
|
|
33
46
|
const belowProp = variant === "show" ? below : above;
|
|
34
47
|
|
|
48
|
+
const Comp = asChild ? Slot : Component;
|
|
49
|
+
|
|
35
50
|
return (
|
|
36
|
-
<
|
|
51
|
+
<Comp
|
|
37
52
|
{...rest}
|
|
38
53
|
ref={ref}
|
|
39
54
|
className={cl("navds-responsive", className, {
|
|
@@ -54,14 +69,14 @@ const Responsive = forwardRef<
|
|
|
54
69
|
* @example
|
|
55
70
|
* <HGrid columns={{ xs: 1, md: 2 }} gap="4">
|
|
56
71
|
* <div/>
|
|
57
|
-
* <Hide below="md">
|
|
72
|
+
* <Hide below="md" asChild>
|
|
58
73
|
* // Only visible above "md"
|
|
59
74
|
* </Hide>
|
|
60
75
|
* </HGrid>
|
|
61
76
|
* @example
|
|
62
77
|
* <HGrid columns={{ xs: 1, md: 2 }} gap="4">
|
|
63
78
|
* <div/>
|
|
64
|
-
* <Hide above="md">
|
|
79
|
+
* <Hide above="md" asChild>
|
|
65
80
|
* // Only visible below "md"
|
|
66
81
|
* </Hide>
|
|
67
82
|
* </HGrid>
|
|
@@ -79,14 +94,14 @@ export const Hide = forwardRef<HTMLDivElement, ResponsiveProps>(
|
|
|
79
94
|
* @example
|
|
80
95
|
* <HGrid columns={{ xs: 1, md: 2 }} gap="4">
|
|
81
96
|
* <div/>
|
|
82
|
-
* <Show below="md">
|
|
97
|
+
* <Show below="md" asChild>
|
|
83
98
|
* // Only visible below "md"
|
|
84
99
|
* </Show>
|
|
85
100
|
* </HGrid>
|
|
86
101
|
* @example
|
|
87
102
|
* <HGrid columns={{ xs: 1, md: 2 }} gap="4">
|
|
88
103
|
* <div/>
|
|
89
|
-
* <Show above="md">
|
|
104
|
+
* <Show above="md" asChild>
|
|
90
105
|
* // Only visible above "md"
|
|
91
106
|
* </Show>
|
|
92
107
|
* </HGrid>
|