@ndla/primitives 0.0.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/LICENSE +674 -0
- package/dist/panda.buildinfo.json +426 -0
- package/dist/styles.css +1738 -0
- package/es/Accordion.js +103 -0
- package/es/ArticleLists.js +106 -0
- package/es/Badge.js +55 -0
- package/es/BlockQuote.js +49 -0
- package/es/Button.js +211 -0
- package/es/Checkbox.js +118 -0
- package/es/Dialog.js +329 -0
- package/es/ExpandableBox.js +55 -0
- package/es/FieldErrorMessage.js +44 -0
- package/es/FieldHelper.js +37 -0
- package/es/FormControl.js +163 -0
- package/es/FramedContent.js +54 -0
- package/es/Icon.js +71 -0
- package/es/Input.js +159 -0
- package/es/Label.js +104 -0
- package/es/Menu.js +171 -0
- package/es/MessageBox.js +57 -0
- package/es/NdlaLogo.js +284 -0
- package/es/Pagination.js +37 -0
- package/es/Popover.js +78 -0
- package/es/RadioGroup.js +136 -0
- package/es/Skeleton.js +31 -0
- package/es/Slider.js +102 -0
- package/es/Spinner.js +54 -0
- package/es/Switch.js +130 -0
- package/es/Table.js +75 -0
- package/es/Text.js +54 -0
- package/es/Toast.js +82 -0
- package/es/Tooltip.js +59 -0
- package/es/createStyleContext.js +62 -0
- package/es/index.js +19 -0
- package/lib/Accordion.d.ts +17 -0
- package/lib/Accordion.js +109 -0
- package/lib/ArticleLists.d.ts +20 -0
- package/lib/ArticleLists.js +115 -0
- package/lib/Badge.d.ts +33 -0
- package/lib/Badge.js +62 -0
- package/lib/BlockQuote.d.ts +28 -0
- package/lib/BlockQuote.js +56 -0
- package/lib/Button.d.ts +131 -0
- package/lib/Button.js +217 -0
- package/lib/Checkbox.d.ts +15 -0
- package/lib/Checkbox.js +125 -0
- package/lib/Dialog.d.ts +107 -0
- package/lib/Dialog.js +338 -0
- package/lib/ExpandableBox.d.ts +12 -0
- package/lib/ExpandableBox.js +63 -0
- package/lib/FieldErrorMessage.d.ts +11 -0
- package/lib/FieldErrorMessage.js +50 -0
- package/lib/FieldHelper.d.ts +11 -0
- package/lib/FieldHelper.js +43 -0
- package/lib/FormControl.d.ts +65 -0
- package/lib/FormControl.js +173 -0
- package/lib/FramedContent.d.ts +32 -0
- package/lib/FramedContent.js +61 -0
- package/lib/Icon.d.ts +37 -0
- package/lib/Icon.js +78 -0
- package/lib/Input.d.ts +20 -0
- package/lib/Input.js +165 -0
- package/lib/Label.d.ts +16 -0
- package/lib/Label.js +110 -0
- package/lib/Menu.d.ts +25 -0
- package/lib/Menu.js +179 -0
- package/lib/MessageBox.d.ts +33 -0
- package/lib/MessageBox.js +64 -0
- package/lib/NdlaLogo.d.ts +15 -0
- package/lib/NdlaLogo.js +293 -0
- package/lib/Pagination.d.ts +14 -0
- package/lib/Pagination.js +43 -0
- package/lib/Popover.d.ts +22 -0
- package/lib/Popover.js +87 -0
- package/lib/RadioGroup.d.ts +19 -0
- package/lib/RadioGroup.js +143 -0
- package/lib/Skeleton.d.ts +11 -0
- package/lib/Skeleton.js +38 -0
- package/lib/Slider.d.ts +17 -0
- package/lib/Slider.js +109 -0
- package/lib/Spinner.d.ts +26 -0
- package/lib/Spinner.js +61 -0
- package/lib/Switch.d.ts +21 -0
- package/lib/Switch.js +137 -0
- package/lib/Table.d.ts +10 -0
- package/lib/Table.js +82 -0
- package/lib/Text.d.ts +24 -0
- package/lib/Text.js +62 -0
- package/lib/Toast.d.ts +18 -0
- package/lib/Toast.js +90 -0
- package/lib/Tooltip.d.ts +16 -0
- package/lib/Tooltip.js +65 -0
- package/lib/createStyleContext.d.ts +27 -0
- package/lib/createStyleContext.js +69 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.js +130 -0
- package/package.json +48 -0
package/es/Accordion.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { accordionAnatomy } from "@ark-ui/anatomy";
|
|
10
|
+
import { Accordion } from "@ark-ui/react";
|
|
11
|
+
import { sva } from "@ndla/styled-system/css";
|
|
12
|
+
import { createStyleContext } from "./createStyleContext";
|
|
13
|
+
const accordionRecipe = sva({
|
|
14
|
+
slots: accordionAnatomy.keys(),
|
|
15
|
+
base: {
|
|
16
|
+
root: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
flexDirection: "column",
|
|
19
|
+
gap: "3xsmall"
|
|
20
|
+
},
|
|
21
|
+
itemTrigger: {
|
|
22
|
+
display: "flex",
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
justifyContent: "space-between",
|
|
25
|
+
background: "surface.default",
|
|
26
|
+
cursor: "pointer",
|
|
27
|
+
paddingInline: "medium",
|
|
28
|
+
paddingBlock: "medium",
|
|
29
|
+
boxShadowColor: "stroke.subtle",
|
|
30
|
+
boxShadow: "inset 0 0 0 1px var(--shadow-color)",
|
|
31
|
+
borderRadius: "xsmall",
|
|
32
|
+
transitionDuration: "fast",
|
|
33
|
+
transitionTimingFunction: "default",
|
|
34
|
+
transitionProperty: "background, border-color, border, border-radius",
|
|
35
|
+
width: "100%",
|
|
36
|
+
_closed: {
|
|
37
|
+
transitionProperty: "background, border-color, border, border-radius"
|
|
38
|
+
},
|
|
39
|
+
_disabled: {
|
|
40
|
+
cursor: "not-allowed",
|
|
41
|
+
background: "surface..disabled.subtle",
|
|
42
|
+
boxShadowColor: "stroke.disabled",
|
|
43
|
+
color: "text.disabled",
|
|
44
|
+
_hover: {
|
|
45
|
+
background: "surface.disabled.subtle",
|
|
46
|
+
boxShadowColor: "stroke.disabled",
|
|
47
|
+
color: "text.disabled"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
_hover: {
|
|
51
|
+
background: "surface.actionSubtle.hover",
|
|
52
|
+
boxShadowColor: "stroke.hover"
|
|
53
|
+
},
|
|
54
|
+
_open: {
|
|
55
|
+
backgroundColor: "surface.actionSubtle.active",
|
|
56
|
+
boxShadowColor: "stroke.default",
|
|
57
|
+
borderBottomRadius: "sharp"
|
|
58
|
+
},
|
|
59
|
+
_focusVisible: {
|
|
60
|
+
outline: "none",
|
|
61
|
+
boxShadowColor: "stroke.default",
|
|
62
|
+
boxShadow: "inset 0 0 0 2px var(--shadow-color)"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
itemIndicator: {
|
|
66
|
+
color: "icon.strong",
|
|
67
|
+
transformOrigin: "center",
|
|
68
|
+
transitionDuration: "normal",
|
|
69
|
+
transitionProperty: "transform",
|
|
70
|
+
transitionTimingFunction: "default",
|
|
71
|
+
_open: {
|
|
72
|
+
transform: "rotate(180deg)"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
itemContent: {
|
|
76
|
+
overflow: "hidden",
|
|
77
|
+
transitionProperty: "padding-bottom",
|
|
78
|
+
transitionDuration: "normal",
|
|
79
|
+
transitionTimingFunction: "default",
|
|
80
|
+
paddingBlock: "xsmall",
|
|
81
|
+
paddingInline: "small",
|
|
82
|
+
borderBottomRadius: "xsmall",
|
|
83
|
+
borderWidth: "0 1px 1px",
|
|
84
|
+
borderStyle: "solid",
|
|
85
|
+
borderColor: "stroke.default",
|
|
86
|
+
_open: {
|
|
87
|
+
animation: "collapse-in"
|
|
88
|
+
},
|
|
89
|
+
_closed: {
|
|
90
|
+
animation: "collapse-out"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const {
|
|
96
|
+
withProvider,
|
|
97
|
+
withContext
|
|
98
|
+
} = createStyleContext(accordionRecipe);
|
|
99
|
+
export const AccordionRoot = withProvider(Accordion.Root, "root");
|
|
100
|
+
export const AccordionItemContent = withContext(Accordion.ItemContent, "itemContent");
|
|
101
|
+
export const AccordionItemIndicator = withContext(Accordion.ItemIndicator, "itemIndicator");
|
|
102
|
+
export const AccordionItem = withContext(Accordion.Item, "item");
|
|
103
|
+
export const AccordionItemTrigger = withContext(Accordion.ItemTrigger, "itemTrigger");
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const StyledOrderedList = styled("ol", {
|
|
12
|
+
base: {
|
|
13
|
+
listStyle: "revert",
|
|
14
|
+
listStylePosition: "inside",
|
|
15
|
+
paddingInlineStart: "small",
|
|
16
|
+
"& li": {
|
|
17
|
+
marginBlock: "small"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "numbers"
|
|
22
|
+
},
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
numbers: {
|
|
26
|
+
"& > li": {
|
|
27
|
+
_marker: {
|
|
28
|
+
content: "counters(list-item, '.') '. '"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
letters: {
|
|
33
|
+
"& ol[data-variant='numbers'] > li": {
|
|
34
|
+
_marker: {
|
|
35
|
+
content: "counter(list-item, numeric) '. '"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"& li": {
|
|
39
|
+
_marker: {
|
|
40
|
+
content: "counter(list-item, upper-alpha) '. '"
|
|
41
|
+
},
|
|
42
|
+
"& > ol > li": {
|
|
43
|
+
_marker: {
|
|
44
|
+
content: "counter(list-item, lower-alpha) '. '"
|
|
45
|
+
},
|
|
46
|
+
"& li": {
|
|
47
|
+
_marker: {
|
|
48
|
+
content: "counter(list-item, lower-roman) '. '"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
export const OrderedList = _ref => {
|
|
58
|
+
let {
|
|
59
|
+
variant = "numbers",
|
|
60
|
+
...props
|
|
61
|
+
} = _ref;
|
|
62
|
+
return /*#__PURE__*/_jsx(StyledOrderedList, {
|
|
63
|
+
variant: variant,
|
|
64
|
+
"data-variant": variant,
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const StyledUnOrderedList = styled("ul", {
|
|
69
|
+
base: {
|
|
70
|
+
listStyle: "revert",
|
|
71
|
+
listStylePosition: "inside",
|
|
72
|
+
paddingInlineStart: "small",
|
|
73
|
+
"& li": {
|
|
74
|
+
marginBlock: "small",
|
|
75
|
+
_marker: {
|
|
76
|
+
color: "icon.strong"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
export const UnOrderedList = _ref2 => {
|
|
82
|
+
let {
|
|
83
|
+
...props
|
|
84
|
+
} = _ref2;
|
|
85
|
+
return /*#__PURE__*/_jsx(StyledUnOrderedList, {
|
|
86
|
+
...props
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
const StyledDefinitionList = styled("dl", {
|
|
90
|
+
base: {
|
|
91
|
+
"& dt": {
|
|
92
|
+
fontWeight: "bold"
|
|
93
|
+
},
|
|
94
|
+
"& dd": {
|
|
95
|
+
marginInlineStart: "medium"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
export const DefinitionList = _ref3 => {
|
|
100
|
+
let {
|
|
101
|
+
...props
|
|
102
|
+
} = _ref3;
|
|
103
|
+
return /*#__PURE__*/_jsx(StyledDefinitionList, {
|
|
104
|
+
...props
|
|
105
|
+
});
|
|
106
|
+
};
|
package/es/Badge.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { cva, cx } from "@ndla/styled-system/css";
|
|
10
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const badgeRecipe = cva({
|
|
13
|
+
base: {
|
|
14
|
+
paddingInline: "xsmall",
|
|
15
|
+
borderRadius: "xsmall",
|
|
16
|
+
border: "1px solid",
|
|
17
|
+
width: "fit-content"
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
colorTheme: "neutral"
|
|
21
|
+
},
|
|
22
|
+
variants: {
|
|
23
|
+
colorTheme: {
|
|
24
|
+
brand1: {
|
|
25
|
+
backgroundColor: "surface.brand.1.subtle",
|
|
26
|
+
borderColor: "surface.brand.1.strong"
|
|
27
|
+
},
|
|
28
|
+
brand2: {
|
|
29
|
+
backgroundColor: "surface.brand.2.subtle",
|
|
30
|
+
borderColor: "surface.brand.2.strong"
|
|
31
|
+
},
|
|
32
|
+
brand3: {
|
|
33
|
+
backgroundColor: "surface.brand.3.subtle",
|
|
34
|
+
borderColor: "surface.brand.3.strong"
|
|
35
|
+
},
|
|
36
|
+
neutral: {
|
|
37
|
+
backgroundColor: "surface.infoSubtle",
|
|
38
|
+
borderColor: "stroke.default"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
export const Badge = _ref => {
|
|
44
|
+
let {
|
|
45
|
+
colorTheme,
|
|
46
|
+
className,
|
|
47
|
+
...rest
|
|
48
|
+
} = _ref;
|
|
49
|
+
return /*#__PURE__*/_jsx(styled.div, {
|
|
50
|
+
className: cx(badgeRecipe({
|
|
51
|
+
colorTheme
|
|
52
|
+
}), className),
|
|
53
|
+
...rest
|
|
54
|
+
});
|
|
55
|
+
};
|
package/es/BlockQuote.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { cva, cx } from "@ndla/styled-system/css";
|
|
10
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const blockQuoteRecipe = cva({
|
|
13
|
+
base: {
|
|
14
|
+
borderInlineStart: "4px solid",
|
|
15
|
+
paddingInline: "medium"
|
|
16
|
+
},
|
|
17
|
+
variants: {
|
|
18
|
+
variant: {
|
|
19
|
+
neutral: {
|
|
20
|
+
borderColor: "stroke.subtle"
|
|
21
|
+
// TODO: Figure out if this should have a background color.
|
|
22
|
+
},
|
|
23
|
+
brand1: {
|
|
24
|
+
background: "surface.brand.1.subtle",
|
|
25
|
+
borderColor: "surface.brand.1.strong"
|
|
26
|
+
},
|
|
27
|
+
brand2: {
|
|
28
|
+
background: "surface.brand.2.subtle",
|
|
29
|
+
borderColor: "surface.brand.2.strong"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "neutral"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export const BlockQuote = _ref => {
|
|
38
|
+
let {
|
|
39
|
+
className,
|
|
40
|
+
variant,
|
|
41
|
+
...rest
|
|
42
|
+
} = _ref;
|
|
43
|
+
return /*#__PURE__*/_jsx(styled.blockquote, {
|
|
44
|
+
className: cx(blockQuoteRecipe({
|
|
45
|
+
variant
|
|
46
|
+
}), className),
|
|
47
|
+
...rest
|
|
48
|
+
});
|
|
49
|
+
};
|
package/es/Button.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { forwardRef } from "react";
|
|
10
|
+
import { css, cva, cx } from "@ndla/styled-system/css";
|
|
11
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export const buttonBaseRecipe = cva({
|
|
14
|
+
base: {
|
|
15
|
+
display: "inline-flex",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
gap: "xsmall",
|
|
19
|
+
cursor: "pointer",
|
|
20
|
+
textDecoration: "none",
|
|
21
|
+
textStyle: "label.medium",
|
|
22
|
+
fontWeight: "bold",
|
|
23
|
+
transitionProperty: "all",
|
|
24
|
+
transitionDuration: "fast",
|
|
25
|
+
transitionTimingFunction: "default",
|
|
26
|
+
textAlign: "center",
|
|
27
|
+
borderRadius: "xsmall",
|
|
28
|
+
outline: "none",
|
|
29
|
+
boxShadowColor: "stroke.default",
|
|
30
|
+
_disabled: {
|
|
31
|
+
cursor: "not-allowed",
|
|
32
|
+
color: "text.onAction",
|
|
33
|
+
background: "surface.disabled",
|
|
34
|
+
_hover: {
|
|
35
|
+
color: "text.onAction",
|
|
36
|
+
background: "surface.disabled"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
_focusVisible: {
|
|
40
|
+
boxShadow: "inset 0 0 0 3px var(--shadow-color)"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
defaultVariants: {
|
|
44
|
+
variant: "primary"
|
|
45
|
+
},
|
|
46
|
+
variants: {
|
|
47
|
+
variant: {
|
|
48
|
+
primary: {
|
|
49
|
+
color: "text.onAction",
|
|
50
|
+
background: "surface.action",
|
|
51
|
+
_hover: {
|
|
52
|
+
color: "text.onAction",
|
|
53
|
+
background: "surface.action.hover"
|
|
54
|
+
},
|
|
55
|
+
_active: {
|
|
56
|
+
color: "text.onAction",
|
|
57
|
+
background: "surface.action.active"
|
|
58
|
+
},
|
|
59
|
+
_focusVisible: {
|
|
60
|
+
boxShadow: "inset 0 0 0 3px var(--shadow-color), inset 0px 0px 0px 6px currentcolor"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
secondary: {
|
|
64
|
+
color: "text.strong",
|
|
65
|
+
background: "transparent",
|
|
66
|
+
boxShadow: "inset 0 0 0 1px var(--shadow-color)",
|
|
67
|
+
_hover: {
|
|
68
|
+
background: "surface.actionSubtle.hover"
|
|
69
|
+
},
|
|
70
|
+
_active: {
|
|
71
|
+
background: "surface.actionSubtle.active"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
tertiary: {
|
|
75
|
+
color: "text.strong",
|
|
76
|
+
background: "transparent",
|
|
77
|
+
_hover: {
|
|
78
|
+
boxShadow: "inset 0 0 0 1px var(--shadow-color)",
|
|
79
|
+
background: "surface.actionSubtle.hover",
|
|
80
|
+
_focusVisible: {
|
|
81
|
+
boxShadow: "inset 0 0 0 3px var(--shadow-color)"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
_active: {
|
|
85
|
+
borderColor: "stroke.default",
|
|
86
|
+
background: "surface.actionSubtle.active"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
clear: {
|
|
90
|
+
background: "transparent",
|
|
91
|
+
color: "text.strong",
|
|
92
|
+
_hover: {
|
|
93
|
+
color: "stroke.hover"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
clearSubtle: {
|
|
97
|
+
background: "transparent",
|
|
98
|
+
color: "text.onAction",
|
|
99
|
+
_hover: {
|
|
100
|
+
color: "surface.actionSubtle.hover.strong"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
danger: {
|
|
104
|
+
background: "surface.error",
|
|
105
|
+
color: "text.onAction",
|
|
106
|
+
_hover: {
|
|
107
|
+
background: "surface.error.hover"
|
|
108
|
+
},
|
|
109
|
+
_active: {
|
|
110
|
+
background: "surface.error.active"
|
|
111
|
+
},
|
|
112
|
+
_focusVisible: {
|
|
113
|
+
boxShadowColor: "surface.error",
|
|
114
|
+
boxShadow: "inset 0 0 0 3px var(--shadow-color), inset 0px 0px 0px 6px currentcolor"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
success: {
|
|
118
|
+
background: "surface.success",
|
|
119
|
+
color: "text.onAction",
|
|
120
|
+
_hover: {
|
|
121
|
+
background: "surface.success.hover"
|
|
122
|
+
},
|
|
123
|
+
_active: {
|
|
124
|
+
background: "surface.success.active"
|
|
125
|
+
},
|
|
126
|
+
_focusVisible: {
|
|
127
|
+
boxShadowColor: "surface.success",
|
|
128
|
+
boxShadow: "inset 0 0 0 3px var(--shadow-color), inset 0px 0px 0px 6px currentcolor"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
link: {
|
|
132
|
+
background: "transparent",
|
|
133
|
+
color: "text.link",
|
|
134
|
+
textDecoration: "underline",
|
|
135
|
+
textDecorationThickness: "1px",
|
|
136
|
+
_hover: {
|
|
137
|
+
textDecoration: "none"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
export const buttonRecipe = cva({
|
|
144
|
+
defaultVariants: {
|
|
145
|
+
size: "default"
|
|
146
|
+
},
|
|
147
|
+
variants: {
|
|
148
|
+
size: {
|
|
149
|
+
default: {
|
|
150
|
+
paddingInline: "medium",
|
|
151
|
+
paddingBlock: "xxsmall",
|
|
152
|
+
minHeight: "24"
|
|
153
|
+
},
|
|
154
|
+
small: {
|
|
155
|
+
textStyle: "label.small",
|
|
156
|
+
minHeight: "19",
|
|
157
|
+
paddingInline: "small",
|
|
158
|
+
paddingBlock: "3xsmall"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
export const Button = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
164
|
+
let {
|
|
165
|
+
type,
|
|
166
|
+
size,
|
|
167
|
+
className,
|
|
168
|
+
variant,
|
|
169
|
+
...rest
|
|
170
|
+
} = _ref;
|
|
171
|
+
return /*#__PURE__*/_jsx(styled.button, {
|
|
172
|
+
type: type !== null && type !== void 0 ? type : "button",
|
|
173
|
+
className: cx(css(buttonBaseRecipe.raw({
|
|
174
|
+
variant
|
|
175
|
+
}), buttonRecipe.raw({
|
|
176
|
+
size
|
|
177
|
+
})), className),
|
|
178
|
+
...rest,
|
|
179
|
+
ref: ref
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
export const IconButton = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
183
|
+
let {
|
|
184
|
+
type,
|
|
185
|
+
className,
|
|
186
|
+
variant,
|
|
187
|
+
...rest
|
|
188
|
+
} = _ref2;
|
|
189
|
+
return /*#__PURE__*/_jsx(styled.button, {
|
|
190
|
+
type: type !== null && type !== void 0 ? type : "button",
|
|
191
|
+
className: cx(css(buttonBaseRecipe.raw({
|
|
192
|
+
variant
|
|
193
|
+
}), iconButtonRecipe.raw()), className),
|
|
194
|
+
...rest,
|
|
195
|
+
ref: ref
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
export const iconButtonRecipe = cva({
|
|
199
|
+
base: {
|
|
200
|
+
lineHeight: "1",
|
|
201
|
+
minHeight: "unset",
|
|
202
|
+
"& svg": {
|
|
203
|
+
marginInline: "0",
|
|
204
|
+
marginBlock: "0",
|
|
205
|
+
width: "medium",
|
|
206
|
+
height: "medium"
|
|
207
|
+
},
|
|
208
|
+
paddingInline: "xsmall",
|
|
209
|
+
paddingBlock: "xsmall"
|
|
210
|
+
}
|
|
211
|
+
});
|
package/es/Checkbox.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { forwardRef } from "react";
|
|
10
|
+
import { checkboxAnatomy } from "@ark-ui/anatomy";
|
|
11
|
+
import { Checkbox } from "@ark-ui/react";
|
|
12
|
+
import { sva } from "@ndla/styled-system/css";
|
|
13
|
+
import { createStyleContext } from "./createStyleContext";
|
|
14
|
+
import { useFormControl } from "./FormControl";
|
|
15
|
+
import { Text } from "./Text";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
const checkboxRecipe = sva({
|
|
18
|
+
slots: checkboxAnatomy.keys(),
|
|
19
|
+
base: {
|
|
20
|
+
root: {
|
|
21
|
+
userSelect: "none",
|
|
22
|
+
display: "flex",
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
cursor: "pointer",
|
|
25
|
+
gap: "xxsmall",
|
|
26
|
+
_disabled: {
|
|
27
|
+
color: "text.disabled",
|
|
28
|
+
cursor: "not-allowed"
|
|
29
|
+
},
|
|
30
|
+
_hover: {
|
|
31
|
+
color: "text.action"
|
|
32
|
+
},
|
|
33
|
+
_focus: {
|
|
34
|
+
outline: "2px solid",
|
|
35
|
+
outlineOffset: "4xsmall",
|
|
36
|
+
outlineColor: "stroke.default",
|
|
37
|
+
borderRadius: "xsmall"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
control: {
|
|
41
|
+
display: "flex",
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
justifyContent: "center",
|
|
44
|
+
cursor: "pointer",
|
|
45
|
+
width: "medium",
|
|
46
|
+
height: "medium",
|
|
47
|
+
background: "surface.default",
|
|
48
|
+
borderRadius: "xsmall",
|
|
49
|
+
border: "2px solid",
|
|
50
|
+
borderColor: "stroke.subtle",
|
|
51
|
+
color: "text.strong",
|
|
52
|
+
transitionDuration: "normal",
|
|
53
|
+
transitionProperty: "border-color, background, box-shadow, color",
|
|
54
|
+
transitionTimingFunction: "default",
|
|
55
|
+
_hover: {
|
|
56
|
+
boxShadow: "0 0 0 4px var(--shadow-color)",
|
|
57
|
+
boxShadowColor: "surface.actionSubtle.hover.strong"
|
|
58
|
+
},
|
|
59
|
+
_checked: {
|
|
60
|
+
color: "icon.onAction",
|
|
61
|
+
backgroundColor: "surface.action",
|
|
62
|
+
borderColor: "surface.action"
|
|
63
|
+
},
|
|
64
|
+
_disabled: {
|
|
65
|
+
borderColor: "stroke.disabled",
|
|
66
|
+
_hover: {
|
|
67
|
+
borderColor: "stroke.disabled",
|
|
68
|
+
boxShadow: "none"
|
|
69
|
+
},
|
|
70
|
+
_checked: {
|
|
71
|
+
background: "surface.disabled"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
_invalid: {
|
|
75
|
+
borderColor: "stroke.error",
|
|
76
|
+
_checked: {
|
|
77
|
+
color: "stroke.error",
|
|
78
|
+
borderColor: "stroke.error",
|
|
79
|
+
backgroundColor: "surface.default"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const {
|
|
86
|
+
withProvider,
|
|
87
|
+
withContext
|
|
88
|
+
} = createStyleContext(checkboxRecipe);
|
|
89
|
+
const InternalCheckboxRoot = withProvider(Checkbox.Root, "root");
|
|
90
|
+
export const CheckboxRoot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
91
|
+
var _field$invalid;
|
|
92
|
+
const field = useFormControl(props);
|
|
93
|
+
return /*#__PURE__*/_jsx(InternalCheckboxRoot, {
|
|
94
|
+
...field,
|
|
95
|
+
invalid: (_field$invalid = field.invalid) !== null && _field$invalid !== void 0 ? _field$invalid : !!field["aria-invalid"],
|
|
96
|
+
ref: ref,
|
|
97
|
+
"aria-invalid": undefined
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
export const CheckboxIndicator = withContext(Checkbox.Indicator, "indicator");
|
|
101
|
+
const InternalCheckboxLabel = withContext(Checkbox.Label, "label");
|
|
102
|
+
export const CheckboxLabel = _ref => {
|
|
103
|
+
let {
|
|
104
|
+
textStyle = "label.medium",
|
|
105
|
+
children,
|
|
106
|
+
...props
|
|
107
|
+
} = _ref;
|
|
108
|
+
return /*#__PURE__*/_jsx(InternalCheckboxLabel, {
|
|
109
|
+
...props,
|
|
110
|
+
asChild: true,
|
|
111
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
112
|
+
textStyle: textStyle,
|
|
113
|
+
children: children
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
export const CheckboxControl = withContext(Checkbox.Control, "control");
|
|
118
|
+
export const CheckboxHiddenInput = Checkbox.HiddenInput;
|