braid-design-system 32.19.1 → 32.20.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/CHANGELOG.md +61 -0
- package/codemod/dist/wrapper.js +2 -2
- package/dist/lib/components/Tag/Tag.cjs +38 -14
- package/dist/lib/components/Tag/Tag.mjs +38 -14
- package/dist/lib/components/Toggle/Toggle.cjs +125 -77
- package/dist/lib/components/Toggle/Toggle.css.cjs +14 -23
- package/dist/lib/components/Toggle/Toggle.css.mjs +16 -25
- package/dist/lib/components/Toggle/Toggle.mjs +125 -79
- package/dist/lib/playroom/snippets/Tag.cjs +3 -0
- package/dist/lib/playroom/snippets/Tag.mjs +3 -0
- package/dist/lib/playroom/snippets/Toggle.cjs +7 -4
- package/dist/lib/playroom/snippets/Toggle.mjs +7 -4
- package/dist/lib/themes/seekJobs/tokens.cjs +1 -1
- package/dist/lib/themes/seekJobs/tokens.mjs +1 -1
- package/dist/wireframe.chunk.d.ts +19 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# braid-design-system
|
|
2
2
|
|
|
3
|
+
## 32.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **Toggle:** Add `togglePosition` prop ([#1509](https://github.com/seek-oss/braid-design-system/pull/1509))
|
|
8
|
+
|
|
9
|
+
Introduces the `togglePosition` prop, enabling the toggle to either be `leading` or `trailing` its label text.
|
|
10
|
+
|
|
11
|
+
**EXAMPLE USAGE:**
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
<Toggle togglePosition="trailing" label="Label" />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- **Toggle:** Add `bleedY` prop ([#1519](https://github.com/seek-oss/braid-design-system/pull/1519))
|
|
18
|
+
|
|
19
|
+
Introduces the `bleedY` prop, enabling vertical bleed for the `Toggle` component. This removes excess vertical space created by the `Toggle` input.
|
|
20
|
+
|
|
21
|
+
**EXAMPLE USAGE:**
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
<Toggle label="Label" bleedY />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**MIGRATION GUIDE:**
|
|
28
|
+
|
|
29
|
+
Vertical bleed will become standard for the `Toggle` component in a future version. Please use the `bleedY` prop with a value of `true` and update your layout accordingly.
|
|
30
|
+
|
|
31
|
+
- **Tag:** Introduce "addable" support ([#1521](https://github.com/seek-oss/braid-design-system/pull/1521))
|
|
32
|
+
|
|
33
|
+
Tag actions have been extended to now support being “added”.
|
|
34
|
+
A `Tag` will include a small add icon button when both an `onAdd` handler and `addLabel` prop are provided.
|
|
35
|
+
|
|
36
|
+
**EXAMPLE USAGE:**
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
<Tag onAdd={() => {...}} addLabel="Add Tag" />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- **seekJobs:** Use Tahoma for Thai fallback font ([#1527](https://github.com/seek-oss/braid-design-system/pull/1527))
|
|
43
|
+
|
|
44
|
+
Currently in the `seekJobs` theme, the fallback font for the Thai character set resolves to the default system font which differs by operating system.
|
|
45
|
+
By choosing a deterministic fallback that is available across operating systems, we can use [Capsize] to [improve the alignment] with the SEEK Sans web font, and reduce Cumulative Layout Shift for experiences that use Thai.
|
|
46
|
+
|
|
47
|
+
Additionally, adding `sans-serif` as an ultimate fallback in the event that we ever fall all the way through the stack on an obscure operating system.
|
|
48
|
+
|
|
49
|
+
[Capsize]: https://seek-oss.github.io/capsize/
|
|
50
|
+
[improve the alignment]: https://github.com/seek-oss/capsize?tab=readme-ov-file#createfontstack
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- **Tag**: Add missing click event parameter to `onClear` prop type ([#1516](https://github.com/seek-oss/braid-design-system/pull/1516))
|
|
55
|
+
|
|
56
|
+
- **Toggle:** Improve label text vertical alignment at `small` size ([#1518](https://github.com/seek-oss/braid-design-system/pull/1518))
|
|
57
|
+
|
|
58
|
+
- **Toggle:** Remove tick icon & fix antialias haze when selected ([#1525](https://github.com/seek-oss/braid-design-system/pull/1525))
|
|
59
|
+
|
|
60
|
+
Simplying the selected state design by removing the tick icon from the toggle thumb.
|
|
61
|
+
|
|
62
|
+
Also fixes the antialias haze that appears around the thumb when selected.
|
|
63
|
+
|
|
3
64
|
## 32.19.1
|
|
4
65
|
|
|
5
66
|
### Patch Changes
|
package/codemod/dist/wrapper.js
CHANGED
|
@@ -121660,7 +121660,7 @@ var require_lib32 = __commonJS({
|
|
|
121660
121660
|
value: true
|
|
121661
121661
|
});
|
|
121662
121662
|
exports2.default = optimiseCallExpression;
|
|
121663
|
-
var _t =
|
|
121663
|
+
var _t = require_lib3();
|
|
121664
121664
|
var {
|
|
121665
121665
|
callExpression: callExpression2,
|
|
121666
121666
|
identifier,
|
|
@@ -121962,7 +121962,7 @@ var require_lib35 = __commonJS({
|
|
|
121962
121962
|
exports2.isTransparentExprWrapper = isTransparentExprWrapper;
|
|
121963
121963
|
exports2.skipTransparentExprWrapperNodes = skipTransparentExprWrapperNodes;
|
|
121964
121964
|
exports2.skipTransparentExprWrappers = skipTransparentExprWrappers;
|
|
121965
|
-
var _t =
|
|
121965
|
+
var _t = require_lib3();
|
|
121966
121966
|
var {
|
|
121967
121967
|
isParenthesizedExpression,
|
|
121968
121968
|
isTSAsExpression,
|
|
@@ -6,6 +6,7 @@ const lib_components_Text_Text_cjs = require("../Text/Text.cjs");
|
|
|
6
6
|
const lib_components_ButtonIcon_ButtonIcon_cjs = require("../ButtonIcon/ButtonIcon.cjs");
|
|
7
7
|
const lib_components_private_buildDataAttributes_cjs = require("../private/buildDataAttributes.cjs");
|
|
8
8
|
const lib_components_Tag_Tag_css_cjs = require("./Tag.css.cjs");
|
|
9
|
+
const lib_components_icons_IconAdd_IconAdd_cjs = require("../icons/IconAdd/IconAdd.cjs");
|
|
9
10
|
const lib_components_icons_IconClear_IconClear_cjs = require("../icons/IconClear/IconClear.cjs");
|
|
10
11
|
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
11
12
|
const assert__default = /* @__PURE__ */ _interopDefaultCompat(assert);
|
|
@@ -15,8 +16,6 @@ const paddingXForSize = {
|
|
|
15
16
|
standard: "small"
|
|
16
17
|
};
|
|
17
18
|
const Tag = ({
|
|
18
|
-
onClear,
|
|
19
|
-
clearLabel = "Clear",
|
|
20
19
|
size = "standard",
|
|
21
20
|
data,
|
|
22
21
|
id,
|
|
@@ -32,6 +31,21 @@ const Tag = ({
|
|
|
32
31
|
!icon || icon.props.size === void 0 || icon.props.tone === void 0,
|
|
33
32
|
"Icons cannot set the 'size' or 'tone' prop when passed to a Tag component"
|
|
34
33
|
);
|
|
34
|
+
let label = "Clear";
|
|
35
|
+
let buttonType = "clear";
|
|
36
|
+
let handler;
|
|
37
|
+
const clearable = "onClear" in restProps && restProps.onClear;
|
|
38
|
+
const addable = "onAdd" in restProps && restProps.onAdd;
|
|
39
|
+
if (clearable) {
|
|
40
|
+
label = restProps.clearLabel;
|
|
41
|
+
handler = restProps.onClear;
|
|
42
|
+
buttonType = "clear";
|
|
43
|
+
} else if (addable) {
|
|
44
|
+
label = restProps.addLabel;
|
|
45
|
+
handler = restProps.onAdd;
|
|
46
|
+
buttonType = "add";
|
|
47
|
+
}
|
|
48
|
+
const hasButton = clearable || addable;
|
|
35
49
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
50
|
lib_components_Box_Box_cjs.Box,
|
|
37
51
|
{
|
|
@@ -44,18 +58,27 @@ const Tag = ({
|
|
|
44
58
|
display: "flex",
|
|
45
59
|
minWidth: 0,
|
|
46
60
|
alignItems: "center",
|
|
47
|
-
background: "neutralLight",
|
|
61
|
+
background: addable ? "formAccentSoft" : "neutralLight",
|
|
48
62
|
paddingY: "xxsmall",
|
|
49
63
|
paddingX: paddingXForSize[size],
|
|
50
|
-
paddingRight:
|
|
64
|
+
paddingRight: hasButton ? "xsmall" : paddingXForSize[size],
|
|
51
65
|
borderRadius: "full",
|
|
52
66
|
children: [
|
|
53
|
-
/* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { minWidth: 0, title: children, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
/* @__PURE__ */ jsxRuntime.jsx(lib_components_Box_Box_cjs.Box, { minWidth: 0, title: children, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
68
|
+
lib_components_Text_Text_cjs.Text,
|
|
69
|
+
{
|
|
70
|
+
size,
|
|
71
|
+
baseline: false,
|
|
72
|
+
maxLines: 1,
|
|
73
|
+
tone: addable ? "formAccent" : void 0,
|
|
74
|
+
children: [
|
|
75
|
+
icon,
|
|
76
|
+
" ",
|
|
77
|
+
children
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
) }),
|
|
81
|
+
hasButton ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
82
|
lib_components_Box_Box_cjs.Box,
|
|
60
83
|
{
|
|
61
84
|
flexShrink: 0,
|
|
@@ -64,12 +87,13 @@ const Tag = ({
|
|
|
64
87
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
88
|
lib_components_ButtonIcon_ButtonIcon_cjs.ButtonIcon,
|
|
66
89
|
{
|
|
67
|
-
id: id ? `${id}
|
|
68
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(lib_components_icons_IconClear_IconClear_cjs.IconClear, { tone: "secondary" }),
|
|
69
|
-
label
|
|
90
|
+
id: id ? `${id}-${buttonType}` : void 0,
|
|
91
|
+
icon: addable ? /* @__PURE__ */ jsxRuntime.jsx(lib_components_icons_IconAdd_IconAdd_cjs.IconAdd, {}) : /* @__PURE__ */ jsxRuntime.jsx(lib_components_icons_IconClear_IconClear_cjs.IconClear, { tone: "secondary" }),
|
|
92
|
+
label,
|
|
70
93
|
size: "small",
|
|
94
|
+
tone: addable ? "formAccent" : "neutral",
|
|
71
95
|
variant: "transparent",
|
|
72
|
-
onClick:
|
|
96
|
+
onClick: handler
|
|
73
97
|
}
|
|
74
98
|
)
|
|
75
99
|
}
|
|
@@ -5,6 +5,7 @@ import { Text } from "../Text/Text.mjs";
|
|
|
5
5
|
import { ButtonIcon } from "../ButtonIcon/ButtonIcon.mjs";
|
|
6
6
|
import { buildDataAttributes } from "../private/buildDataAttributes.mjs";
|
|
7
7
|
import { clearGutter } from "./Tag.css.mjs";
|
|
8
|
+
import { IconAdd } from "../icons/IconAdd/IconAdd.mjs";
|
|
8
9
|
import { IconClear } from "../icons/IconClear/IconClear.mjs";
|
|
9
10
|
const tagSizes = ["small", "standard"];
|
|
10
11
|
const paddingXForSize = {
|
|
@@ -12,8 +13,6 @@ const paddingXForSize = {
|
|
|
12
13
|
standard: "small"
|
|
13
14
|
};
|
|
14
15
|
const Tag = ({
|
|
15
|
-
onClear,
|
|
16
|
-
clearLabel = "Clear",
|
|
17
16
|
size = "standard",
|
|
18
17
|
data,
|
|
19
18
|
id,
|
|
@@ -29,6 +28,21 @@ const Tag = ({
|
|
|
29
28
|
!icon || icon.props.size === void 0 || icon.props.tone === void 0,
|
|
30
29
|
"Icons cannot set the 'size' or 'tone' prop when passed to a Tag component"
|
|
31
30
|
);
|
|
31
|
+
let label = "Clear";
|
|
32
|
+
let buttonType = "clear";
|
|
33
|
+
let handler;
|
|
34
|
+
const clearable = "onClear" in restProps && restProps.onClear;
|
|
35
|
+
const addable = "onAdd" in restProps && restProps.onAdd;
|
|
36
|
+
if (clearable) {
|
|
37
|
+
label = restProps.clearLabel;
|
|
38
|
+
handler = restProps.onClear;
|
|
39
|
+
buttonType = "clear";
|
|
40
|
+
} else if (addable) {
|
|
41
|
+
label = restProps.addLabel;
|
|
42
|
+
handler = restProps.onAdd;
|
|
43
|
+
buttonType = "add";
|
|
44
|
+
}
|
|
45
|
+
const hasButton = clearable || addable;
|
|
32
46
|
return /* @__PURE__ */ jsx(
|
|
33
47
|
Box,
|
|
34
48
|
{
|
|
@@ -41,18 +55,27 @@ const Tag = ({
|
|
|
41
55
|
display: "flex",
|
|
42
56
|
minWidth: 0,
|
|
43
57
|
alignItems: "center",
|
|
44
|
-
background: "neutralLight",
|
|
58
|
+
background: addable ? "formAccentSoft" : "neutralLight",
|
|
45
59
|
paddingY: "xxsmall",
|
|
46
60
|
paddingX: paddingXForSize[size],
|
|
47
|
-
paddingRight:
|
|
61
|
+
paddingRight: hasButton ? "xsmall" : paddingXForSize[size],
|
|
48
62
|
borderRadius: "full",
|
|
49
63
|
children: [
|
|
50
|
-
/* @__PURE__ */ jsx(Box, { minWidth: 0, title: children, children: /* @__PURE__ */ jsxs(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
/* @__PURE__ */ jsx(Box, { minWidth: 0, title: children, children: /* @__PURE__ */ jsxs(
|
|
65
|
+
Text,
|
|
66
|
+
{
|
|
67
|
+
size,
|
|
68
|
+
baseline: false,
|
|
69
|
+
maxLines: 1,
|
|
70
|
+
tone: addable ? "formAccent" : void 0,
|
|
71
|
+
children: [
|
|
72
|
+
icon,
|
|
73
|
+
" ",
|
|
74
|
+
children
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
) }),
|
|
78
|
+
hasButton ? /* @__PURE__ */ jsx(
|
|
56
79
|
Box,
|
|
57
80
|
{
|
|
58
81
|
flexShrink: 0,
|
|
@@ -61,12 +84,13 @@ const Tag = ({
|
|
|
61
84
|
children: /* @__PURE__ */ jsx(
|
|
62
85
|
ButtonIcon,
|
|
63
86
|
{
|
|
64
|
-
id: id ? `${id}
|
|
65
|
-
icon: /* @__PURE__ */ jsx(IconClear, { tone: "secondary" }),
|
|
66
|
-
label
|
|
87
|
+
id: id ? `${id}-${buttonType}` : void 0,
|
|
88
|
+
icon: addable ? /* @__PURE__ */ jsx(IconAdd, {}) : /* @__PURE__ */ jsx(IconClear, { tone: "secondary" }),
|
|
89
|
+
label,
|
|
67
90
|
size: "small",
|
|
91
|
+
tone: addable ? "formAccent" : "neutral",
|
|
68
92
|
variant: "transparent",
|
|
69
|
-
onClick:
|
|
93
|
+
onClick: handler
|
|
70
94
|
}
|
|
71
95
|
)
|
|
72
96
|
}
|
|
@@ -8,7 +8,9 @@ const lib_components_Box_BackgroundContext_cjs = require("../Box/BackgroundConte
|
|
|
8
8
|
const lib_components_private_buildDataAttributes_cjs = require("../private/buildDataAttributes.cjs");
|
|
9
9
|
const lib_components_private_touchable_virtualTouchable_css_cjs = require("../private/touchable/virtualTouchable.css.cjs");
|
|
10
10
|
const lib_components_Toggle_Toggle_css_cjs = require("./Toggle.css.cjs");
|
|
11
|
-
const
|
|
11
|
+
const dedent = require("dedent");
|
|
12
|
+
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
13
|
+
const dedent__default = /* @__PURE__ */ _interopDefaultCompat(dedent);
|
|
12
14
|
const handleChange = (onChange) => (event) => {
|
|
13
15
|
if (typeof onChange === "function") {
|
|
14
16
|
onChange(event.target.checked);
|
|
@@ -21,118 +23,152 @@ const Toggle = React.forwardRef(
|
|
|
21
23
|
onChange,
|
|
22
24
|
label,
|
|
23
25
|
align = "left",
|
|
26
|
+
togglePosition,
|
|
24
27
|
size = "standard",
|
|
28
|
+
bleedY = false,
|
|
25
29
|
data,
|
|
26
30
|
...restProps
|
|
27
31
|
}, forwardedRef) => {
|
|
28
32
|
const lightness = lib_components_Box_BackgroundContext_cjs.useBackgroundLightness();
|
|
33
|
+
if (process.env.NODE_ENV !== "production") {
|
|
34
|
+
if (bleedY === void 0) {
|
|
35
|
+
console.warn(
|
|
36
|
+
dedent__default.default`
|
|
37
|
+
Vertical bleed will become standard in a future version, which will affect your layout.
|
|
38
|
+
Please add the "bleedY" prop with a value of "true" and optimise your layout.
|
|
39
|
+
`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
if (bleedY === false) {
|
|
43
|
+
console.warn(
|
|
44
|
+
dedent__default.default`
|
|
45
|
+
Using "bleedY" set to "false" will be deprecated in a future version.
|
|
46
|
+
Please set the "bleedY" prop to "true" and optimise your layout.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const defaultTogglePosition = align === "left" ? "leading" : "trailing";
|
|
51
|
+
const appliedTogglePosition = togglePosition || defaultTogglePosition;
|
|
52
|
+
const alignToEnd = align === "left" && appliedTogglePosition === "trailing" || align !== "left" && appliedTogglePosition === "leading";
|
|
29
53
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
30
54
|
lib_components_Box_Box_cjs.Box,
|
|
31
55
|
{
|
|
32
56
|
position: "relative",
|
|
33
57
|
zIndex: 0,
|
|
34
58
|
display: "flex",
|
|
35
|
-
flexDirection:
|
|
59
|
+
flexDirection: appliedTogglePosition === "trailing" ? "rowReverse" : "row",
|
|
60
|
+
justifyContent: alignToEnd ? "flexEnd" : void 0,
|
|
36
61
|
className: lib_components_Toggle_Toggle_css_cjs.root,
|
|
37
62
|
...lib_components_private_buildDataAttributes_cjs.buildDataAttributes({ data, validateRestProps: restProps }),
|
|
38
63
|
children: [
|
|
39
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40
|
-
lib_components_Box_Box_cjs.Box,
|
|
41
|
-
{
|
|
42
|
-
component: "input",
|
|
43
|
-
type: "checkbox",
|
|
44
|
-
id,
|
|
45
|
-
checked: on,
|
|
46
|
-
onChange: handleChange(onChange),
|
|
47
|
-
position: "absolute",
|
|
48
|
-
zIndex: 1,
|
|
49
|
-
cursor: "pointer",
|
|
50
|
-
opacity: 0,
|
|
51
|
-
className: [
|
|
52
|
-
lib_components_Toggle_Toggle_css_cjs.realField,
|
|
53
|
-
lib_components_Toggle_Toggle_css_cjs.realFieldPosition[size],
|
|
54
|
-
lib_components_Toggle_Toggle_css_cjs.fieldSize[size]
|
|
55
|
-
],
|
|
56
|
-
ref: forwardedRef
|
|
57
|
-
}
|
|
58
|
-
),
|
|
59
64
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
60
65
|
lib_components_Box_Box_cjs.Box,
|
|
61
66
|
{
|
|
62
67
|
position: "relative",
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
className: [
|
|
67
|
-
lib_components_Toggle_Toggle_css_cjs.slideContainer,
|
|
68
|
-
lib_components_Toggle_Toggle_css_cjs.slideContainerSize[size],
|
|
69
|
-
lib_components_Toggle_Toggle_css_cjs.fieldSize[size]
|
|
70
|
-
],
|
|
68
|
+
className: bleedY && lib_components_Toggle_Toggle_css_cjs.bleedToCapHeight[size],
|
|
69
|
+
display: bleedY ? "flex" : void 0,
|
|
70
|
+
alignItems: bleedY ? "center" : void 0,
|
|
71
71
|
children: [
|
|
72
72
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
73
73
|
lib_components_Box_Box_cjs.Box,
|
|
74
74
|
{
|
|
75
|
+
component: "input",
|
|
76
|
+
type: "checkbox",
|
|
77
|
+
id,
|
|
78
|
+
checked: on,
|
|
79
|
+
onChange: handleChange(onChange),
|
|
75
80
|
position: "absolute",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
zIndex: 1,
|
|
82
|
+
cursor: "pointer",
|
|
83
|
+
opacity: 0,
|
|
79
84
|
className: [
|
|
80
|
-
lib_components_Toggle_Toggle_css_cjs.
|
|
81
|
-
lib_components_Toggle_Toggle_css_cjs.
|
|
82
|
-
lib_components_Toggle_Toggle_css_cjs.
|
|
83
|
-
lib_components_Toggle_Toggle_css_cjs.slideTrackBgDarkMode[lightness.darkMode]
|
|
85
|
+
lib_components_Toggle_Toggle_css_cjs.realField,
|
|
86
|
+
!bleedY && lib_components_Toggle_Toggle_css_cjs.realFieldPosition[size],
|
|
87
|
+
lib_components_Toggle_Toggle_css_cjs.fieldSize[size]
|
|
84
88
|
],
|
|
85
|
-
|
|
86
|
-
lib_components_Box_Box_cjs.Box,
|
|
87
|
-
{
|
|
88
|
-
position: "absolute",
|
|
89
|
-
width: "full",
|
|
90
|
-
height: "full",
|
|
91
|
-
background: "formAccent",
|
|
92
|
-
transition: "fast",
|
|
93
|
-
className: lib_components_Toggle_Toggle_css_cjs.slideTrackSelected
|
|
94
|
-
}
|
|
95
|
-
)
|
|
89
|
+
ref: forwardedRef
|
|
96
90
|
}
|
|
97
91
|
),
|
|
98
92
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
99
93
|
lib_components_Box_Box_cjs.Box,
|
|
100
94
|
{
|
|
101
|
-
position: "
|
|
102
|
-
background: "surface",
|
|
103
|
-
transition: "fast",
|
|
95
|
+
position: "relative",
|
|
104
96
|
display: "flex",
|
|
105
97
|
alignItems: "center",
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
flexShrink: 0,
|
|
99
|
+
className: [
|
|
100
|
+
lib_components_Toggle_Toggle_css_cjs.slideContainer,
|
|
101
|
+
lib_components_Toggle_Toggle_css_cjs.slideContainerSize[size],
|
|
102
|
+
lib_components_Toggle_Toggle_css_cjs.fieldSize[size]
|
|
103
|
+
],
|
|
109
104
|
children: [
|
|
110
105
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
111
|
-
|
|
106
|
+
lib_components_Box_Box_cjs.Box,
|
|
112
107
|
{
|
|
113
|
-
|
|
108
|
+
position: "absolute",
|
|
109
|
+
width: "full",
|
|
110
|
+
overflow: "hidden",
|
|
114
111
|
borderRadius: "full",
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
className: [
|
|
113
|
+
lib_components_Toggle_Toggle_css_cjs.slideTrack[size],
|
|
114
|
+
lib_components_Toggle_Toggle_css_cjs.slideTrackMask,
|
|
115
|
+
lib_components_Toggle_Toggle_css_cjs.slideTrackBgLightMode[lightness.lightMode],
|
|
116
|
+
lib_components_Toggle_Toggle_css_cjs.slideTrackBgDarkMode[lightness.darkMode]
|
|
117
|
+
],
|
|
118
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
119
|
+
lib_components_Box_Box_cjs.Box,
|
|
120
|
+
{
|
|
121
|
+
position: "absolute",
|
|
122
|
+
width: "full",
|
|
123
|
+
height: "full",
|
|
124
|
+
background: "formAccent",
|
|
125
|
+
transition: "fast",
|
|
126
|
+
className: lib_components_Toggle_Toggle_css_cjs.slideTrackSelected
|
|
127
|
+
}
|
|
128
|
+
)
|
|
119
129
|
}
|
|
120
130
|
),
|
|
121
|
-
/* @__PURE__ */ jsxRuntime.
|
|
122
|
-
|
|
123
|
-
lib_components_private_FieldOverlay_FieldOverlay_cjs.FieldOverlay,
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
132
|
+
lib_components_Box_Box_cjs.Box,
|
|
124
133
|
{
|
|
125
|
-
|
|
134
|
+
position: "absolute",
|
|
135
|
+
background: "surface",
|
|
136
|
+
transition: "fast",
|
|
137
|
+
display: "flex",
|
|
138
|
+
alignItems: "center",
|
|
139
|
+
justifyContent: "center",
|
|
126
140
|
borderRadius: "full",
|
|
127
|
-
className: lib_components_Toggle_Toggle_css_cjs.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
className: lib_components_Toggle_Toggle_css_cjs.slider[size],
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
+
lib_components_private_FieldOverlay_FieldOverlay_cjs.FieldOverlay,
|
|
145
|
+
{
|
|
146
|
+
variant: on ? "formAccent" : "default",
|
|
147
|
+
borderRadius: "full",
|
|
148
|
+
visible: true,
|
|
149
|
+
className: {
|
|
150
|
+
[lib_components_Toggle_Toggle_css_cjs.sliderThumbOutlineFix]: true,
|
|
151
|
+
[lib_components_Toggle_Toggle_css_cjs.hideBorderOnDarkBackgroundInLightMode]: lightness.lightMode === "dark"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
156
|
+
lib_components_private_FieldOverlay_FieldOverlay_cjs.FieldOverlay,
|
|
157
|
+
{
|
|
158
|
+
variant: "focus",
|
|
159
|
+
borderRadius: "full",
|
|
160
|
+
className: lib_components_Toggle_Toggle_css_cjs.focusOverlay
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
164
|
+
lib_components_private_FieldOverlay_FieldOverlay_cjs.FieldOverlay,
|
|
165
|
+
{
|
|
166
|
+
variant: "formAccent",
|
|
167
|
+
borderRadius: "full",
|
|
168
|
+
className: !on ? lib_components_Toggle_Toggle_css_cjs.hoverOverlay : void 0
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
]
|
|
136
172
|
}
|
|
137
173
|
)
|
|
138
174
|
]
|
|
@@ -146,13 +182,25 @@ const Toggle = React.forwardRef(
|
|
|
146
182
|
{
|
|
147
183
|
component: "label",
|
|
148
184
|
htmlFor: id,
|
|
149
|
-
paddingLeft:
|
|
150
|
-
paddingRight:
|
|
185
|
+
paddingLeft: appliedTogglePosition === "trailing" ? void 0 : "xsmall",
|
|
186
|
+
paddingRight: appliedTogglePosition === "leading" ? void 0 : "xsmall",
|
|
187
|
+
display: "flex",
|
|
188
|
+
flexDirection: "column",
|
|
189
|
+
justifyContent: "center",
|
|
151
190
|
flexGrow: align === "justify" ? 1 : void 0,
|
|
152
191
|
userSelect: "none",
|
|
153
192
|
cursor: "pointer",
|
|
154
|
-
className:
|
|
155
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
193
|
+
className: lib_components_private_touchable_virtualTouchable_css_cjs.virtualTouchable,
|
|
194
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
195
|
+
lib_components_Text_Text_cjs.Text,
|
|
196
|
+
{
|
|
197
|
+
baseline: bleedY,
|
|
198
|
+
weight: on ? "strong" : void 0,
|
|
199
|
+
size,
|
|
200
|
+
align: align === "justify" && appliedTogglePosition === "leading" ? "right" : void 0,
|
|
201
|
+
children: label
|
|
202
|
+
}
|
|
203
|
+
)
|
|
156
204
|
}
|
|
157
205
|
)
|
|
158
206
|
]
|
|
@@ -7,11 +7,20 @@ const lib_components_private_touchable_hitArea_cjs = require("../private/touchab
|
|
|
7
7
|
const lib_components_private_touchable_debugTouchable_cjs = require("../private/touchable/debugTouchable.cjs");
|
|
8
8
|
const polished = require("polished");
|
|
9
9
|
const lib_css_colorModeStyle_cjs = require("../../css/colorModeStyle.cjs");
|
|
10
|
+
const lib_css_responsiveStyle_cjs = require("../../css/responsiveStyle.cjs");
|
|
10
11
|
fileScope.setFileScope("src/lib/components/Toggle/Toggle.css.ts", "braid-design-system");
|
|
11
12
|
const sizes = {
|
|
12
13
|
standard: "standard",
|
|
13
14
|
small: "small"
|
|
14
15
|
};
|
|
16
|
+
const bleedToCapHeight = css.styleVariants(sizes, (size) => lib_css_responsiveStyle_cjs.responsiveStyle({
|
|
17
|
+
mobile: {
|
|
18
|
+
height: lib_themes_vars_css_cjs.vars.textSize[size].mobile.capHeight
|
|
19
|
+
},
|
|
20
|
+
tablet: {
|
|
21
|
+
height: lib_themes_vars_css_cjs.vars.textSize[size].tablet.capHeight
|
|
22
|
+
}
|
|
23
|
+
}), "bleedToCapHeight");
|
|
15
24
|
const toggleWidthRatio = 1.6;
|
|
16
25
|
const root = css.style({
|
|
17
26
|
":hover": {
|
|
@@ -24,13 +33,6 @@ const realField = css.style([{
|
|
|
24
33
|
const realFieldPosition = css.styleVariants(sizes, (size) => ({
|
|
25
34
|
top: cssUtils.calc(lib_components_private_touchable_hitArea_cjs.hitArea).subtract(lib_themes_vars_css_cjs.vars.inlineFieldSize[size]).divide(2).negate().toString()
|
|
26
35
|
}), "realFieldPosition");
|
|
27
|
-
const label = css.styleVariants(sizes, (size) => {
|
|
28
|
-
const padding = cssUtils.calc(lib_themes_vars_css_cjs.vars.inlineFieldSize[size]).subtract(lib_themes_vars_css_cjs.vars.textSize.standard.mobile.lineHeight).divide(2).toString();
|
|
29
|
-
return {
|
|
30
|
-
paddingTop: padding,
|
|
31
|
-
paddingBottom: padding
|
|
32
|
-
};
|
|
33
|
-
}, "label");
|
|
34
36
|
const fieldSize = css.styleVariants(sizes, (size) => ({
|
|
35
37
|
width: cssUtils.calc.multiply(lib_themes_vars_css_cjs.vars.inlineFieldSize[size], toggleWidthRatio)
|
|
36
38
|
}), "fieldSize");
|
|
@@ -97,20 +99,9 @@ const slider = css.styleVariants(sizes, (size) => {
|
|
|
97
99
|
}
|
|
98
100
|
};
|
|
99
101
|
}, "slider");
|
|
100
|
-
const
|
|
101
|
-
transform: "scale(.
|
|
102
|
-
|
|
103
|
-
[`${realField}:active + ${slideContainer} &`]: {
|
|
104
|
-
transform: "scale(.75) rotate(-25deg)"
|
|
105
|
-
},
|
|
106
|
-
[`${realField}:checked + ${slideContainer} &`]: {
|
|
107
|
-
opacity: 1
|
|
108
|
-
},
|
|
109
|
-
[`${realField}:active:checked + ${slideContainer} &`]: {
|
|
110
|
-
transform: "scale(.75) rotate(6deg)"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, "icon");
|
|
102
|
+
const sliderThumbOutlineFix = css.style({
|
|
103
|
+
transform: "scale(1.04)"
|
|
104
|
+
}, "sliderThumbOutlineFix");
|
|
114
105
|
const hideBorderOnDarkBackgroundInLightMode = css.style(lib_css_colorModeStyle_cjs.colorModeStyle({
|
|
115
106
|
lightMode: {
|
|
116
107
|
opacity: 0
|
|
@@ -133,12 +124,11 @@ const hoverOverlay = css.style({
|
|
|
133
124
|
}
|
|
134
125
|
}, "hoverOverlay");
|
|
135
126
|
fileScope.endFileScope();
|
|
127
|
+
exports.bleedToCapHeight = bleedToCapHeight;
|
|
136
128
|
exports.fieldSize = fieldSize;
|
|
137
129
|
exports.focusOverlay = focusOverlay;
|
|
138
130
|
exports.hideBorderOnDarkBackgroundInLightMode = hideBorderOnDarkBackgroundInLightMode;
|
|
139
131
|
exports.hoverOverlay = hoverOverlay;
|
|
140
|
-
exports.icon = icon;
|
|
141
|
-
exports.label = label;
|
|
142
132
|
exports.realField = realField;
|
|
143
133
|
exports.realFieldPosition = realFieldPosition;
|
|
144
134
|
exports.root = root;
|
|
@@ -150,3 +140,4 @@ exports.slideTrackBgLightMode = slideTrackBgLightMode;
|
|
|
150
140
|
exports.slideTrackMask = slideTrackMask;
|
|
151
141
|
exports.slideTrackSelected = slideTrackSelected;
|
|
152
142
|
exports.slider = slider;
|
|
143
|
+
exports.sliderThumbOutlineFix = sliderThumbOutlineFix;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
|
|
2
|
-
import {
|
|
2
|
+
import { styleVariants, style } from "@vanilla-extract/css";
|
|
3
3
|
import { calc } from "@vanilla-extract/css-utils";
|
|
4
4
|
import { vars } from "../../themes/vars.css.mjs";
|
|
5
5
|
import { hitArea } from "../private/touchable/hitArea.mjs";
|
|
6
6
|
import { debugTouchable } from "../private/touchable/debugTouchable.mjs";
|
|
7
7
|
import { rgba } from "polished";
|
|
8
8
|
import { colorModeStyle } from "../../css/colorModeStyle.mjs";
|
|
9
|
+
import { responsiveStyle } from "../../css/responsiveStyle.mjs";
|
|
9
10
|
setFileScope("src/lib/components/Toggle/Toggle.css.ts", "braid-design-system");
|
|
10
11
|
const sizes = {
|
|
11
12
|
standard: "standard",
|
|
12
13
|
small: "small"
|
|
13
14
|
};
|
|
15
|
+
const bleedToCapHeight = styleVariants(sizes, (size) => responsiveStyle({
|
|
16
|
+
mobile: {
|
|
17
|
+
height: vars.textSize[size].mobile.capHeight
|
|
18
|
+
},
|
|
19
|
+
tablet: {
|
|
20
|
+
height: vars.textSize[size].tablet.capHeight
|
|
21
|
+
}
|
|
22
|
+
}), "bleedToCapHeight");
|
|
14
23
|
const toggleWidthRatio = 1.6;
|
|
15
24
|
const root = style({
|
|
16
25
|
":hover": {
|
|
@@ -23,13 +32,6 @@ const realField = style([{
|
|
|
23
32
|
const realFieldPosition = styleVariants(sizes, (size) => ({
|
|
24
33
|
top: calc(hitArea).subtract(vars.inlineFieldSize[size]).divide(2).negate().toString()
|
|
25
34
|
}), "realFieldPosition");
|
|
26
|
-
const label = styleVariants(sizes, (size) => {
|
|
27
|
-
const padding = calc(vars.inlineFieldSize[size]).subtract(vars.textSize.standard.mobile.lineHeight).divide(2).toString();
|
|
28
|
-
return {
|
|
29
|
-
paddingTop: padding,
|
|
30
|
-
paddingBottom: padding
|
|
31
|
-
};
|
|
32
|
-
}, "label");
|
|
33
35
|
const fieldSize = styleVariants(sizes, (size) => ({
|
|
34
36
|
width: calc.multiply(vars.inlineFieldSize[size], toggleWidthRatio)
|
|
35
37
|
}), "fieldSize");
|
|
@@ -96,20 +98,9 @@ const slider = styleVariants(sizes, (size) => {
|
|
|
96
98
|
}
|
|
97
99
|
};
|
|
98
100
|
}, "slider");
|
|
99
|
-
const
|
|
100
|
-
transform: "scale(.
|
|
101
|
-
|
|
102
|
-
[`${realField}:active + ${slideContainer} &`]: {
|
|
103
|
-
transform: "scale(.75) rotate(-25deg)"
|
|
104
|
-
},
|
|
105
|
-
[`${realField}:checked + ${slideContainer} &`]: {
|
|
106
|
-
opacity: 1
|
|
107
|
-
},
|
|
108
|
-
[`${realField}:active:checked + ${slideContainer} &`]: {
|
|
109
|
-
transform: "scale(.75) rotate(6deg)"
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, "icon");
|
|
101
|
+
const sliderThumbOutlineFix = style({
|
|
102
|
+
transform: "scale(1.04)"
|
|
103
|
+
}, "sliderThumbOutlineFix");
|
|
113
104
|
const hideBorderOnDarkBackgroundInLightMode = style(colorModeStyle({
|
|
114
105
|
lightMode: {
|
|
115
106
|
opacity: 0
|
|
@@ -133,12 +124,11 @@ const hoverOverlay = style({
|
|
|
133
124
|
}, "hoverOverlay");
|
|
134
125
|
endFileScope();
|
|
135
126
|
export {
|
|
127
|
+
bleedToCapHeight,
|
|
136
128
|
fieldSize,
|
|
137
129
|
focusOverlay,
|
|
138
130
|
hideBorderOnDarkBackgroundInLightMode,
|
|
139
131
|
hoverOverlay,
|
|
140
|
-
icon,
|
|
141
|
-
label,
|
|
142
132
|
realField,
|
|
143
133
|
realFieldPosition,
|
|
144
134
|
root,
|
|
@@ -149,5 +139,6 @@ export {
|
|
|
149
139
|
slideTrackBgLightMode,
|
|
150
140
|
slideTrackMask,
|
|
151
141
|
slideTrackSelected,
|
|
152
|
-
slider
|
|
142
|
+
slider,
|
|
143
|
+
sliderThumbOutlineFix
|
|
153
144
|
};
|
|
@@ -6,8 +6,8 @@ import { Text } from "../Text/Text.mjs";
|
|
|
6
6
|
import { useBackgroundLightness } from "../Box/BackgroundContext.mjs";
|
|
7
7
|
import { buildDataAttributes } from "../private/buildDataAttributes.mjs";
|
|
8
8
|
import { virtualTouchable } from "../private/touchable/virtualTouchable.css.mjs";
|
|
9
|
-
import { root, realField, realFieldPosition, fieldSize, slideContainer, slideContainerSize, slideTrack, slideTrackMask, slideTrackBgLightMode, slideTrackBgDarkMode, slideTrackSelected, slider,
|
|
10
|
-
import
|
|
9
|
+
import { root, bleedToCapHeight, realField, realFieldPosition, fieldSize, slideContainer, slideContainerSize, slideTrack, slideTrackMask, slideTrackBgLightMode, slideTrackBgDarkMode, slideTrackSelected, slider, sliderThumbOutlineFix, hideBorderOnDarkBackgroundInLightMode, focusOverlay, hoverOverlay } from "./Toggle.css.mjs";
|
|
10
|
+
import dedent from "dedent";
|
|
11
11
|
const handleChange = (onChange) => (event) => {
|
|
12
12
|
if (typeof onChange === "function") {
|
|
13
13
|
onChange(event.target.checked);
|
|
@@ -18,120 +18,154 @@ const Toggle = forwardRef(
|
|
|
18
18
|
id,
|
|
19
19
|
on,
|
|
20
20
|
onChange,
|
|
21
|
-
label
|
|
21
|
+
label,
|
|
22
22
|
align = "left",
|
|
23
|
+
togglePosition,
|
|
23
24
|
size = "standard",
|
|
25
|
+
bleedY = false,
|
|
24
26
|
data,
|
|
25
27
|
...restProps
|
|
26
28
|
}, forwardedRef) => {
|
|
27
29
|
const lightness = useBackgroundLightness();
|
|
30
|
+
if (process.env.NODE_ENV !== "production") {
|
|
31
|
+
if (bleedY === void 0) {
|
|
32
|
+
console.warn(
|
|
33
|
+
dedent`
|
|
34
|
+
Vertical bleed will become standard in a future version, which will affect your layout.
|
|
35
|
+
Please add the "bleedY" prop with a value of "true" and optimise your layout.
|
|
36
|
+
`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (bleedY === false) {
|
|
40
|
+
console.warn(
|
|
41
|
+
dedent`
|
|
42
|
+
Using "bleedY" set to "false" will be deprecated in a future version.
|
|
43
|
+
Please set the "bleedY" prop to "true" and optimise your layout.`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const defaultTogglePosition = align === "left" ? "leading" : "trailing";
|
|
48
|
+
const appliedTogglePosition = togglePosition || defaultTogglePosition;
|
|
49
|
+
const alignToEnd = align === "left" && appliedTogglePosition === "trailing" || align !== "left" && appliedTogglePosition === "leading";
|
|
28
50
|
return /* @__PURE__ */ jsxs(
|
|
29
51
|
Box,
|
|
30
52
|
{
|
|
31
53
|
position: "relative",
|
|
32
54
|
zIndex: 0,
|
|
33
55
|
display: "flex",
|
|
34
|
-
flexDirection:
|
|
56
|
+
flexDirection: appliedTogglePosition === "trailing" ? "rowReverse" : "row",
|
|
57
|
+
justifyContent: alignToEnd ? "flexEnd" : void 0,
|
|
35
58
|
className: root,
|
|
36
59
|
...buildDataAttributes({ data, validateRestProps: restProps }),
|
|
37
60
|
children: [
|
|
38
|
-
/* @__PURE__ */ jsx(
|
|
39
|
-
Box,
|
|
40
|
-
{
|
|
41
|
-
component: "input",
|
|
42
|
-
type: "checkbox",
|
|
43
|
-
id,
|
|
44
|
-
checked: on,
|
|
45
|
-
onChange: handleChange(onChange),
|
|
46
|
-
position: "absolute",
|
|
47
|
-
zIndex: 1,
|
|
48
|
-
cursor: "pointer",
|
|
49
|
-
opacity: 0,
|
|
50
|
-
className: [
|
|
51
|
-
realField,
|
|
52
|
-
realFieldPosition[size],
|
|
53
|
-
fieldSize[size]
|
|
54
|
-
],
|
|
55
|
-
ref: forwardedRef
|
|
56
|
-
}
|
|
57
|
-
),
|
|
58
61
|
/* @__PURE__ */ jsxs(
|
|
59
62
|
Box,
|
|
60
63
|
{
|
|
61
64
|
position: "relative",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
className: [
|
|
66
|
-
slideContainer,
|
|
67
|
-
slideContainerSize[size],
|
|
68
|
-
fieldSize[size]
|
|
69
|
-
],
|
|
65
|
+
className: bleedY && bleedToCapHeight[size],
|
|
66
|
+
display: bleedY ? "flex" : void 0,
|
|
67
|
+
alignItems: bleedY ? "center" : void 0,
|
|
70
68
|
children: [
|
|
71
69
|
/* @__PURE__ */ jsx(
|
|
72
70
|
Box,
|
|
73
71
|
{
|
|
72
|
+
component: "input",
|
|
73
|
+
type: "checkbox",
|
|
74
|
+
id,
|
|
75
|
+
checked: on,
|
|
76
|
+
onChange: handleChange(onChange),
|
|
74
77
|
position: "absolute",
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
zIndex: 1,
|
|
79
|
+
cursor: "pointer",
|
|
80
|
+
opacity: 0,
|
|
78
81
|
className: [
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
slideTrackBgDarkMode[lightness.darkMode]
|
|
82
|
+
realField,
|
|
83
|
+
!bleedY && realFieldPosition[size],
|
|
84
|
+
fieldSize[size]
|
|
83
85
|
],
|
|
84
|
-
|
|
85
|
-
Box,
|
|
86
|
-
{
|
|
87
|
-
position: "absolute",
|
|
88
|
-
width: "full",
|
|
89
|
-
height: "full",
|
|
90
|
-
background: "formAccent",
|
|
91
|
-
transition: "fast",
|
|
92
|
-
className: slideTrackSelected
|
|
93
|
-
}
|
|
94
|
-
)
|
|
86
|
+
ref: forwardedRef
|
|
95
87
|
}
|
|
96
88
|
),
|
|
97
89
|
/* @__PURE__ */ jsxs(
|
|
98
90
|
Box,
|
|
99
91
|
{
|
|
100
|
-
position: "
|
|
101
|
-
background: "surface",
|
|
102
|
-
transition: "fast",
|
|
92
|
+
position: "relative",
|
|
103
93
|
display: "flex",
|
|
104
94
|
alignItems: "center",
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
flexShrink: 0,
|
|
96
|
+
className: [
|
|
97
|
+
slideContainer,
|
|
98
|
+
slideContainerSize[size],
|
|
99
|
+
fieldSize[size]
|
|
100
|
+
],
|
|
108
101
|
children: [
|
|
109
102
|
/* @__PURE__ */ jsx(
|
|
110
|
-
|
|
103
|
+
Box,
|
|
111
104
|
{
|
|
112
|
-
|
|
105
|
+
position: "absolute",
|
|
106
|
+
width: "full",
|
|
107
|
+
overflow: "hidden",
|
|
113
108
|
borderRadius: "full",
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
className: [
|
|
110
|
+
slideTrack[size],
|
|
111
|
+
slideTrackMask,
|
|
112
|
+
slideTrackBgLightMode[lightness.lightMode],
|
|
113
|
+
slideTrackBgDarkMode[lightness.darkMode]
|
|
114
|
+
],
|
|
115
|
+
children: /* @__PURE__ */ jsx(
|
|
116
|
+
Box,
|
|
117
|
+
{
|
|
118
|
+
position: "absolute",
|
|
119
|
+
width: "full",
|
|
120
|
+
height: "full",
|
|
121
|
+
background: "formAccent",
|
|
122
|
+
transition: "fast",
|
|
123
|
+
className: slideTrackSelected
|
|
124
|
+
}
|
|
125
|
+
)
|
|
118
126
|
}
|
|
119
127
|
),
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
|
|
122
|
-
FieldOverlay,
|
|
128
|
+
/* @__PURE__ */ jsxs(
|
|
129
|
+
Box,
|
|
123
130
|
{
|
|
124
|
-
|
|
131
|
+
position: "absolute",
|
|
132
|
+
background: "surface",
|
|
133
|
+
transition: "fast",
|
|
134
|
+
display: "flex",
|
|
135
|
+
alignItems: "center",
|
|
136
|
+
justifyContent: "center",
|
|
125
137
|
borderRadius: "full",
|
|
126
|
-
className:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
className: slider[size],
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
FieldOverlay,
|
|
142
|
+
{
|
|
143
|
+
variant: on ? "formAccent" : "default",
|
|
144
|
+
borderRadius: "full",
|
|
145
|
+
visible: true,
|
|
146
|
+
className: {
|
|
147
|
+
[sliderThumbOutlineFix]: true,
|
|
148
|
+
[hideBorderOnDarkBackgroundInLightMode]: lightness.lightMode === "dark"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
FieldOverlay,
|
|
154
|
+
{
|
|
155
|
+
variant: "focus",
|
|
156
|
+
borderRadius: "full",
|
|
157
|
+
className: focusOverlay
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsx(
|
|
161
|
+
FieldOverlay,
|
|
162
|
+
{
|
|
163
|
+
variant: "formAccent",
|
|
164
|
+
borderRadius: "full",
|
|
165
|
+
className: !on ? hoverOverlay : void 0
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
]
|
|
135
169
|
}
|
|
136
170
|
)
|
|
137
171
|
]
|
|
@@ -145,13 +179,25 @@ const Toggle = forwardRef(
|
|
|
145
179
|
{
|
|
146
180
|
component: "label",
|
|
147
181
|
htmlFor: id,
|
|
148
|
-
paddingLeft:
|
|
149
|
-
paddingRight:
|
|
182
|
+
paddingLeft: appliedTogglePosition === "trailing" ? void 0 : "xsmall",
|
|
183
|
+
paddingRight: appliedTogglePosition === "leading" ? void 0 : "xsmall",
|
|
184
|
+
display: "flex",
|
|
185
|
+
flexDirection: "column",
|
|
186
|
+
justifyContent: "center",
|
|
150
187
|
flexGrow: align === "justify" ? 1 : void 0,
|
|
151
188
|
userSelect: "none",
|
|
152
189
|
cursor: "pointer",
|
|
153
|
-
className:
|
|
154
|
-
children: /* @__PURE__ */ jsx(
|
|
190
|
+
className: virtualTouchable,
|
|
191
|
+
children: /* @__PURE__ */ jsx(
|
|
192
|
+
Text,
|
|
193
|
+
{
|
|
194
|
+
baseline: bleedY,
|
|
195
|
+
weight: on ? "strong" : void 0,
|
|
196
|
+
size,
|
|
197
|
+
align: align === "justify" && appliedTogglePosition === "leading" ? "right" : void 0,
|
|
198
|
+
children: label
|
|
199
|
+
}
|
|
200
|
+
)
|
|
155
201
|
}
|
|
156
202
|
)
|
|
157
203
|
]
|
|
@@ -8,6 +8,9 @@ const snippets = [{
|
|
|
8
8
|
}, {
|
|
9
9
|
name: "Clearable",
|
|
10
10
|
code: '<Inline space="small">\n <Tag onClear={() => {}} clearLabel="Clear">\n Tag\n </Tag>\n <Tag onClear={() => {}} clearLabel="Clear">\n Tag\n </Tag>\n <Tag onClear={() => {}} clearLabel="Clear">\n Tag\n </Tag>\n </Inline>'
|
|
11
|
+
}, {
|
|
12
|
+
name: "Addable",
|
|
13
|
+
code: '<Inline space="small">\n <Tag onAdd={() => {}} addLabel="Add">\n Tag\n </Tag>\n <Tag onAdd={() => {}} addLabel="Add">\n Tag\n </Tag>\n <Tag onAdd={() => {}} addLabel="Add">\n Tag\n </Tag>\n </Inline>'
|
|
11
14
|
}, {
|
|
12
15
|
name: "With icon",
|
|
13
16
|
code: '<Inline space="small">\n <Tag icon={<IconTag />}>Tag</Tag>\n <Tag icon={<IconTag />}>Tag</Tag>\n <Tag icon={<IconTag />}>Tag</Tag>\n </Inline>'
|
|
@@ -7,6 +7,9 @@ const snippets = [{
|
|
|
7
7
|
}, {
|
|
8
8
|
name: "Clearable",
|
|
9
9
|
code: '<Inline space="small">\n <Tag onClear={() => {}} clearLabel="Clear">\n Tag\n </Tag>\n <Tag onClear={() => {}} clearLabel="Clear">\n Tag\n </Tag>\n <Tag onClear={() => {}} clearLabel="Clear">\n Tag\n </Tag>\n </Inline>'
|
|
10
|
+
}, {
|
|
11
|
+
name: "Addable",
|
|
12
|
+
code: '<Inline space="small">\n <Tag onAdd={() => {}} addLabel="Add">\n Tag\n </Tag>\n <Tag onAdd={() => {}} addLabel="Add">\n Tag\n </Tag>\n <Tag onAdd={() => {}} addLabel="Add">\n Tag\n </Tag>\n </Inline>'
|
|
10
13
|
}, {
|
|
11
14
|
name: "With icon",
|
|
12
15
|
code: '<Inline space="small">\n <Tag icon={<IconTag />}>Tag</Tag>\n <Tag icon={<IconTag />}>Tag</Tag>\n <Tag icon={<IconTag />}>Tag</Tag>\n </Inline>'
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const snippets = [{
|
|
3
3
|
name: "Standard",
|
|
4
|
-
code: '<Toggle label="Label" />'
|
|
4
|
+
code: '<Toggle label="Label" bleedY />'
|
|
5
5
|
}, {
|
|
6
6
|
name: "Small",
|
|
7
|
-
code: '<Toggle label="Label" size="small" />'
|
|
7
|
+
code: '<Toggle label="Label" size="small" bleedY />'
|
|
8
8
|
}, {
|
|
9
9
|
name: "Right aligned",
|
|
10
|
-
code: '<Toggle label="Label" align="right" />'
|
|
10
|
+
code: '<Toggle label="Label" align="right" bleedY />'
|
|
11
11
|
}, {
|
|
12
12
|
name: "Justified",
|
|
13
|
-
code: '<Toggle label="Label" align="justify" />'
|
|
13
|
+
code: '<Toggle label="Label" align="justify" bleedY />'
|
|
14
|
+
}, {
|
|
15
|
+
name: "Trailing toggle position",
|
|
16
|
+
code: '<Toggle label="Label" togglePosition="trailing" bleedY />'
|
|
14
17
|
}];
|
|
15
18
|
exports.snippets = snippets;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
const snippets = [{
|
|
2
2
|
name: "Standard",
|
|
3
|
-
code: '<Toggle label="Label" />'
|
|
3
|
+
code: '<Toggle label="Label" bleedY />'
|
|
4
4
|
}, {
|
|
5
5
|
name: "Small",
|
|
6
|
-
code: '<Toggle label="Label" size="small" />'
|
|
6
|
+
code: '<Toggle label="Label" size="small" bleedY />'
|
|
7
7
|
}, {
|
|
8
8
|
name: "Right aligned",
|
|
9
|
-
code: '<Toggle label="Label" align="right" />'
|
|
9
|
+
code: '<Toggle label="Label" align="right" bleedY />'
|
|
10
10
|
}, {
|
|
11
11
|
name: "Justified",
|
|
12
|
-
code: '<Toggle label="Label" align="justify" />'
|
|
12
|
+
code: '<Toggle label="Label" align="justify" bleedY />'
|
|
13
|
+
}, {
|
|
14
|
+
name: "Trailing toggle position",
|
|
15
|
+
code: '<Toggle label="Label" togglePosition="trailing" bleedY />'
|
|
13
16
|
}];
|
|
14
17
|
export {
|
|
15
18
|
snippets
|
|
@@ -18,7 +18,7 @@ const tokens = lib_themes_baseTokens_apac_cjs.makeTokens({
|
|
|
18
18
|
tokenOverrides: {
|
|
19
19
|
legacy: false,
|
|
20
20
|
typography: {
|
|
21
|
-
fontFamily: 'SeekSans, "SeekSans Fallback", Arial',
|
|
21
|
+
fontFamily: 'SeekSans, "SeekSans Fallback", Arial, Tahoma, sans-serif',
|
|
22
22
|
webFont: "https://www.seek.com.au/static/shared-web/seeksans.css",
|
|
23
23
|
fontMetrics: {
|
|
24
24
|
capHeight: 783,
|
|
@@ -17,7 +17,7 @@ const tokens = makeTokens({
|
|
|
17
17
|
tokenOverrides: {
|
|
18
18
|
legacy: false,
|
|
19
19
|
typography: {
|
|
20
|
-
fontFamily: 'SeekSans, "SeekSans Fallback", Arial',
|
|
20
|
+
fontFamily: 'SeekSans, "SeekSans Fallback", Arial, Tahoma, sans-serif',
|
|
21
21
|
webFont: "https://www.seek.com.au/static/shared-web/seeksans.css",
|
|
22
22
|
fontMetrics: {
|
|
23
23
|
capHeight: 783,
|
|
@@ -3703,17 +3703,29 @@ declare const TabPanel: {
|
|
|
3703
3703
|
};
|
|
3704
3704
|
|
|
3705
3705
|
declare const tagSizes: readonly ["small", "standard"];
|
|
3706
|
-
type
|
|
3706
|
+
type CommonProps = {
|
|
3707
3707
|
children: string;
|
|
3708
3708
|
size?: (typeof tagSizes)[number];
|
|
3709
3709
|
data?: DataAttributeMap;
|
|
3710
3710
|
id?: string;
|
|
3711
3711
|
icon?: TextProps['icon'];
|
|
3712
|
-
}
|
|
3713
|
-
|
|
3712
|
+
};
|
|
3713
|
+
interface AddableTag extends CommonProps {
|
|
3714
|
+
onAdd: ButtonIconProps['onClick'];
|
|
3715
|
+
addLabel: string;
|
|
3716
|
+
}
|
|
3717
|
+
interface ClearableTag extends CommonProps {
|
|
3718
|
+
onClear: ButtonIconProps['onClick'];
|
|
3714
3719
|
clearLabel: string;
|
|
3715
|
-
}
|
|
3716
|
-
|
|
3720
|
+
}
|
|
3721
|
+
interface BaseTag extends CommonProps {
|
|
3722
|
+
onClear?: never;
|
|
3723
|
+
clearLabel?: never;
|
|
3724
|
+
onAdd?: never;
|
|
3725
|
+
addLabel?: never;
|
|
3726
|
+
}
|
|
3727
|
+
type TagProps = ClearableTag | AddableTag | BaseTag;
|
|
3728
|
+
declare const Tag$1: ({ size, data, id, icon, children, ...restProps }: TagProps) => JSX.Element;
|
|
3717
3729
|
|
|
3718
3730
|
type NativeTextareaProps = AllHTMLAttributes<HTMLTextAreaElement>;
|
|
3719
3731
|
type TextareaBaseProps = Omit<FieldBaseProps, 'value' | 'secondaryMessage' | 'icon' | 'prefix'> & {
|
|
@@ -3803,7 +3815,9 @@ interface ToggleProps {
|
|
|
3803
3815
|
on: boolean;
|
|
3804
3816
|
onChange: ChangeHandler;
|
|
3805
3817
|
align?: 'left' | 'right' | 'justify';
|
|
3818
|
+
togglePosition?: 'leading' | 'trailing';
|
|
3806
3819
|
size?: Size;
|
|
3820
|
+
bleedY?: boolean;
|
|
3807
3821
|
data?: DataAttributeMap;
|
|
3808
3822
|
}
|
|
3809
3823
|
declare const Toggle$1: React__default.ForwardRefExoticComponent<ToggleProps & React__default.RefAttributes<HTMLInputElement>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braid-design-system",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.20.0",
|
|
4
4
|
"description": "Themeable design system for the SEEK Group",
|
|
5
5
|
"homepage": "https://seek-oss.github.io/braid-design-system/",
|
|
6
6
|
"bugs": {
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
"@svgr/plugin-prettier": "^5.5.0",
|
|
198
198
|
"@testing-library/dom": "^10.0.0",
|
|
199
199
|
"@testing-library/jest-dom": "^6.0.0",
|
|
200
|
-
"@testing-library/react": "^
|
|
200
|
+
"@testing-library/react": "^16.0.0",
|
|
201
201
|
"@testing-library/user-event": "^14.4.3",
|
|
202
202
|
"@types/autosuggest-highlight": "^3.1.1",
|
|
203
203
|
"@types/babel__core": "^7.20.1",
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
"react-dom": "^18.2.0",
|
|
226
226
|
"react-router-dom": "^6.3.0",
|
|
227
227
|
"sanitize-html": "^2.12.1",
|
|
228
|
-
"sku": "12.
|
|
228
|
+
"sku": "12.7.0",
|
|
229
229
|
"svgo": "^2.8.0",
|
|
230
230
|
"title-case": "^3.0.3"
|
|
231
231
|
},
|