@microbit/ui 0.1.0-alpha.10 → 0.1.0-alpha.12
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/package.json +1 -1
- package/src/ButtonGroup.tsx +10 -3
- package/src/Divider.tsx +39 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microbit/ui",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.12",
|
|
4
4
|
"description": "micro:bit design-system primitives: react-aria-components + Panda CSS with a design language ported from Chakra UI v2. Ships as source; see README for the consumption setup.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/ButtonGroup.tsx
CHANGED
|
@@ -32,9 +32,12 @@ export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
|
32
32
|
display: "inline-flex",
|
|
33
33
|
alignItems: "center",
|
|
34
34
|
// Buttons are position: relative, so without this an attached
|
|
35
|
-
// sibling paints over the focused button's focus-ring shadow
|
|
36
|
-
//
|
|
37
|
-
|
|
35
|
+
// sibling paints over the focused button's focus-ring shadow.
|
|
36
|
+
// Chakra raised on :focus, but with the attached -1px overlap a
|
|
37
|
+
// raised button also paints over a seam its neighbour draws
|
|
38
|
+
// (e.g. a solid split button's white borderLeft), so raise only
|
|
39
|
+
// when the ring is actually shown.
|
|
40
|
+
"& > *": { _focusVisible: { zIndex: 1 } },
|
|
38
41
|
}),
|
|
39
42
|
isAttached
|
|
40
43
|
? css({
|
|
@@ -42,11 +45,15 @@ export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
|
42
45
|
// :first-child/:last-child, not :first-of-type: attached
|
|
43
46
|
// groups can mix element types (e.g. select + button), and
|
|
44
47
|
// -of-type matches per element type.
|
|
48
|
+
// marginEnd -1px (Chakra parity): overlaps adjacent borders
|
|
49
|
+
// so two 1px inner edges read as a single 1px seam.
|
|
45
50
|
"& > *:first-child:not(:last-child)": {
|
|
46
51
|
borderEndRadius: 0,
|
|
52
|
+
marginEnd: "-1px",
|
|
47
53
|
},
|
|
48
54
|
"& > *:not(:first-child):not(:last-child)": {
|
|
49
55
|
borderRadius: 0,
|
|
56
|
+
marginEnd: "-1px",
|
|
50
57
|
},
|
|
51
58
|
"& > *:not(:first-child):last-child": {
|
|
52
59
|
borderStartRadius: 0,
|
package/src/Divider.tsx
CHANGED
|
@@ -15,33 +15,66 @@ const StyledDivider = styled("hr", {
|
|
|
15
15
|
variants: {
|
|
16
16
|
orientation: {
|
|
17
17
|
horizontal: {
|
|
18
|
-
borderBottomWidth: "1px",
|
|
19
18
|
borderBottomStyle: "solid",
|
|
20
19
|
width: "100%",
|
|
21
20
|
},
|
|
22
21
|
vertical: {
|
|
23
|
-
borderLeftWidth: "1px",
|
|
24
22
|
borderLeftStyle: "solid",
|
|
25
23
|
height: "100%",
|
|
26
24
|
},
|
|
27
25
|
},
|
|
26
|
+
// Rule weight, on the orientation's drawn edge (see compoundVariants).
|
|
27
|
+
// Semantic rather than a raw border width so call sites don't need to
|
|
28
|
+
// know which edge an orientation draws with.
|
|
29
|
+
thickness: {
|
|
30
|
+
thin: {},
|
|
31
|
+
thick: {},
|
|
32
|
+
},
|
|
28
33
|
},
|
|
29
|
-
|
|
34
|
+
compoundVariants: [
|
|
35
|
+
{
|
|
36
|
+
orientation: "horizontal",
|
|
37
|
+
thickness: "thin",
|
|
38
|
+
css: { borderBottomWidth: "1px" },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
orientation: "horizontal",
|
|
42
|
+
thickness: "thick",
|
|
43
|
+
css: { borderBottomWidth: "2px" },
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
orientation: "vertical",
|
|
47
|
+
thickness: "thin",
|
|
48
|
+
css: { borderLeftWidth: "1px" },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
orientation: "vertical",
|
|
52
|
+
thickness: "thick",
|
|
53
|
+
css: { borderLeftWidth: "2px" },
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
defaultVariants: { orientation: "horizontal", thickness: "thin" },
|
|
30
57
|
});
|
|
31
58
|
|
|
32
59
|
export interface DividerProps extends ComponentProps<typeof StyledDivider> {}
|
|
33
60
|
|
|
34
61
|
/**
|
|
35
62
|
* Divider — a hairline rule matching Chakra's <Divider> (60% opacity; set
|
|
36
|
-
* `borderColor` to tint
|
|
37
|
-
* layout, e.g. a stretched
|
|
38
|
-
* relied on `height: 100%`).
|
|
63
|
+
* `borderColor` to tint, `thickness="thick"` for a 2px rule).
|
|
64
|
+
* `orientation="vertical"` needs a height from the layout, e.g. a stretched
|
|
65
|
+
* flex row (Chakra's vertical divider likewise relied on `height: 100%`).
|
|
66
|
+
*
|
|
67
|
+
* Decorative by default: hidden from assistive tech, since a visual rule
|
|
68
|
+
* between sections is noise as an announced separator (and every call site
|
|
69
|
+
* was opting out by hand). Pass `aria-hidden={false}` for a divider that
|
|
70
|
+
* should be exposed as a semantic separator.
|
|
39
71
|
*/
|
|
40
72
|
export const Divider = forwardRef<HTMLHRElement, DividerProps>(
|
|
41
73
|
function Divider(props, ref) {
|
|
42
74
|
return (
|
|
43
75
|
<StyledDivider
|
|
44
76
|
ref={ref}
|
|
77
|
+
aria-hidden
|
|
45
78
|
aria-orientation={
|
|
46
79
|
props.orientation === "vertical" ? "vertical" : "horizontal"
|
|
47
80
|
}
|