@microbit/ui 0.1.0-alpha.21 → 0.1.0-alpha.23
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.md +5 -5
- package/README.md +29 -13
- package/lang/ui.ca.json +12 -12
- package/lang/ui.cy.json +4 -4
- package/lang/ui.de.json +6 -6
- package/lang/ui.es-es.json +5 -5
- package/lang/ui.fr.json +6 -6
- package/lang/ui.ga-ie.json +6 -6
- package/lang/ui.it.json +4 -4
- package/lang/ui.ja.json +7 -7
- package/lang/ui.ko.json +6 -6
- package/lang/ui.lo.json +58 -0
- package/lang/ui.nl.json +9 -9
- package/lang/ui.pl.json +8 -8
- package/lang/ui.pt-br.json +7 -7
- package/lang/ui.vi.json +58 -0
- package/lang/ui.zh-cn.json +6 -6
- package/lang/ui.zh-tw.json +7 -7
- package/package.json +1 -1
- package/src/Avatar.recipe.ts +16 -20
- package/src/Avatar.tsx +31 -29
- package/src/Breadcrumb.recipe.ts +3 -7
- package/src/Breadcrumb.tsx +6 -8
- package/src/Button.recipe.ts +22 -33
- package/src/Button.tsx +10 -12
- package/src/ButtonGroup.tsx +10 -9
- package/src/Card.recipe.ts +1 -2
- package/src/Card.tsx +2 -1
- package/src/Checkbox.recipe.ts +7 -9
- package/src/Checkbox.tsx +2 -3
- package/src/CheckboxGroup.tsx +5 -7
- package/src/CloseButton.tsx +2 -2
- package/src/CloseIcon.tsx +6 -4
- package/src/Code.tsx +1 -1
- package/src/Collapse.tsx +13 -14
- package/src/Divider.tsx +3 -3
- package/src/Drawer.recipe.ts +4 -5
- package/src/Drawer.tsx +3 -4
- package/src/Fade.tsx +6 -10
- package/src/Field.recipe.ts +9 -12
- package/src/Field.tsx +16 -18
- package/src/GridList.recipe.ts +1 -2
- package/src/Heading.recipe.ts +5 -5
- package/src/Heading.tsx +3 -3
- package/src/Icon.tsx +7 -11
- package/src/IconButton.tsx +1 -1
- package/src/Image.tsx +1 -1
- package/src/Input.recipe.ts +5 -6
- package/src/Input.tsx +4 -4
- package/src/InputGroup.tsx +4 -5
- package/src/Kbd.tsx +1 -1
- package/src/Link.tsx +2 -2
- package/src/LinkBox.tsx +2 -3
- package/src/LinkButton.tsx +4 -4
- package/src/List.tsx +5 -7
- package/src/Menu.recipe.ts +15 -16
- package/src/Menu.tsx +9 -13
- package/src/Modal.recipe.ts +7 -8
- package/src/Modal.tsx +19 -24
- package/src/NativeSelect.tsx +16 -16
- package/src/NumberField.recipe.ts +25 -11
- package/src/NumberField.tsx +4 -4
- package/src/PopoverArrow.tsx +1 -2
- package/src/ProgressBar.tsx +2 -4
- package/src/Radio.recipe.ts +8 -9
- package/src/Radio.tsx +2 -2
- package/src/RadioGroup.tsx +4 -5
- package/src/Select.recipe.ts +9 -9
- package/src/Select.tsx +8 -9
- package/src/Skeleton.tsx +13 -15
- package/src/Slide.tsx +2 -2
- package/src/Slider.recipe.ts +11 -14
- package/src/Slider.tsx +3 -7
- package/src/Spinner.tsx +6 -9
- package/src/Svg.tsx +2 -3
- package/src/Switch.recipe.ts +4 -5
- package/src/Switch.tsx +3 -4
- package/src/Text.recipe.ts +4 -7
- package/src/Text.tsx +2 -2
- package/src/TextField.tsx +3 -4
- package/src/Toast.recipe.ts +43 -11
- package/src/Toast.tsx +69 -40
- package/src/Tooltip.recipe.ts +4 -9
- package/src/Tooltip.tsx +48 -10
- package/src/TooltipButton.tsx +229 -0
- package/src/UnmountCallback.tsx +2 -2
- package/src/VisuallyHidden.tsx +1 -1
- package/src/base-preset.ts +38 -43
- package/src/button-icon.ts +2 -3
- package/src/dense-preset.ts +6 -7
- package/src/hooks/useBreakpointValue.ts +4 -4
- package/src/hooks/useClipboard.ts +5 -6
- package/src/hooks/useDisclosure.ts +4 -5
- package/src/hooks/useMediaQuery.ts +3 -4
- package/src/hooks/usePrevious.ts +1 -4
- package/src/index.ts +4 -3
- package/src/system.ts +2 -2
package/src/Button.tsx
CHANGED
|
@@ -16,11 +16,11 @@ import { buttonIcon } from "./button-icon";
|
|
|
16
16
|
import { uiMessage } from "./messages";
|
|
17
17
|
import { Spinner } from "./Spinner";
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
19
|
+
// A 1em spinner centred over the hidden label. Out of flow, so the label alone
|
|
20
|
+
// sets the button's size; the recipe's base `position: relative` is what it
|
|
21
|
+
// anchors to. Its own component so useIntl runs only while a button is
|
|
22
|
+
// actually loading — a bare Button must keep working without an IntlProvider
|
|
23
|
+
// (test renders commonly lack one).
|
|
24
24
|
const ButtonSpinner = () => {
|
|
25
25
|
const intl = useIntl();
|
|
26
26
|
return (
|
|
@@ -47,16 +47,14 @@ export interface ButtonProps
|
|
|
47
47
|
/** Per-instance style overrides, merged after the recipe. */
|
|
48
48
|
css?: SystemStyleObject;
|
|
49
49
|
className?: string;
|
|
50
|
-
/** Icon rendered before the label
|
|
50
|
+
/** Icon rendered before the label. */
|
|
51
51
|
leftIcon?: ReactNode;
|
|
52
|
-
/** Icon rendered after the label
|
|
52
|
+
/** Icon rendered after the label. */
|
|
53
53
|
rightIcon?: ReactNode;
|
|
54
54
|
/**
|
|
55
|
-
* Show a spinner in place of the label and disable interaction
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* `loadingText`/`spinnerPlacement` (a visible label beside the spinner) are
|
|
59
|
-
* unported — no app in the family used them.
|
|
55
|
+
* Show a spinner in place of the label and disable interaction: the label
|
|
56
|
+
* stays in the layout but invisible, so the button keeps its size, and the
|
|
57
|
+
* dimmed disabled look applies.
|
|
60
58
|
*/
|
|
61
59
|
isLoading?: boolean;
|
|
62
60
|
children?: ReactNode;
|
package/src/ButtonGroup.tsx
CHANGED
|
@@ -9,8 +9,8 @@ import { SystemStyleObject } from "styled-system/types";
|
|
|
9
9
|
|
|
10
10
|
export interface ButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
11
11
|
/**
|
|
12
|
-
* Square the inner radii so adjacent buttons form one control
|
|
13
|
-
*
|
|
12
|
+
* Square the inner radii so adjacent buttons form one control. Otherwise
|
|
13
|
+
* buttons get a small gap.
|
|
14
14
|
*/
|
|
15
15
|
isAttached?: boolean;
|
|
16
16
|
/** Per-instance style overrides. */
|
|
@@ -20,7 +20,7 @@ export interface ButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* ButtonGroup — lays out related buttons in a row. Works with any button
|
|
23
|
-
* elements (shared-ui or native).
|
|
23
|
+
* elements (shared-ui or native).
|
|
24
24
|
*/
|
|
25
25
|
export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
26
26
|
function ButtonGroup({ isAttached, css: cssProp, className, ...rest }, ref) {
|
|
@@ -33,10 +33,10 @@ export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
|
33
33
|
alignItems: "center",
|
|
34
34
|
// Buttons are position: relative, so without this an attached
|
|
35
35
|
// sibling paints over the focused button's focus-ring shadow.
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
// (e.g. a solid split button's white
|
|
39
|
-
//
|
|
36
|
+
// Raise only on :focus-visible, when the ring is actually shown:
|
|
37
|
+
// with the attached -1px overlap a raised button also paints over
|
|
38
|
+
// a seam its neighbour draws (e.g. a solid split button's white
|
|
39
|
+
// borderLeft).
|
|
40
40
|
"& > *": { _focusVisible: { zIndex: 1 } },
|
|
41
41
|
}),
|
|
42
42
|
isAttached
|
|
@@ -45,8 +45,9 @@ export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
|
45
45
|
// :first-child/:last-child, not :first-of-type: attached
|
|
46
46
|
// groups can mix element types (e.g. select + button), and
|
|
47
47
|
// -of-type matches per element type.
|
|
48
|
-
// marginEnd -1px
|
|
49
|
-
//
|
|
48
|
+
// marginEnd -1px overlaps adjacent borders so two 1px inner
|
|
49
|
+
// edges read as a single 1px seam. That assumes 1px borders;
|
|
50
|
+
// the bordered variants are 2px (microbit-foundation/ui#22).
|
|
50
51
|
"& > *:first-child:not(:last-child)": {
|
|
51
52
|
borderEndRadius: 0,
|
|
52
53
|
marginEnd: "-1px",
|
package/src/Card.recipe.ts
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
import { defineSlotRecipe } from "@pandacss/dev";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Card slot recipe
|
|
10
|
-
* the `elevated` (default) and `outline` variants this app uses.
|
|
9
|
+
* Card slot recipe, with `elevated` (default) and `outline` variants.
|
|
11
10
|
*
|
|
12
11
|
* Registered in the base preset (base-preset.ts); `variant` is
|
|
13
12
|
* forwarded as a runtime prop so the variants are generated via `staticCss`.
|
package/src/Card.tsx
CHANGED
|
@@ -16,7 +16,8 @@ export interface CardProps
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Card —
|
|
19
|
+
* Card — a container styled with the `card` config recipe (md size). Place a
|
|
20
|
+
* CardBody inside.
|
|
20
21
|
*/
|
|
21
22
|
export const Card = forwardRef<HTMLDivElement, CardProps>(function Card(
|
|
22
23
|
{ variant, css: cssProp, className, ...rest },
|
package/src/Checkbox.recipe.ts
CHANGED
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
import { defineSlotRecipe } from "@pandacss/dev";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Checkbox slot recipe
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Chakra's convention for tinting the box from the call site.
|
|
9
|
+
* Checkbox slot recipe with an sm/md/lg size scale. The control's
|
|
10
|
+
* `borderColor: inherit` picks up a `borderColor` set on the root, so call
|
|
11
|
+
* sites can tint the box from there.
|
|
13
12
|
*
|
|
14
13
|
* State styling keys off data attributes stamped on the control by the
|
|
15
14
|
* shared-ui Checkbox (react-aria provides the state via render props).
|
|
@@ -56,8 +55,8 @@ export const checkbox = defineSlotRecipe({
|
|
|
56
55
|
borderColor: "controlCheckedHoverBg",
|
|
57
56
|
},
|
|
58
57
|
},
|
|
59
|
-
//
|
|
60
|
-
//
|
|
58
|
+
// Disabled greys; the selected block restates _hover so the widened
|
|
59
|
+
// native-:hover condition can't re-tint a disabled control.
|
|
61
60
|
"&[data-disabled]": {
|
|
62
61
|
bg: "gray.100",
|
|
63
62
|
borderColor: "gray.100",
|
|
@@ -83,9 +82,8 @@ export const checkbox = defineSlotRecipe({
|
|
|
83
82
|
},
|
|
84
83
|
},
|
|
85
84
|
variants: {
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
// resolved to rem.
|
|
85
|
+
// The icon dimensions are the 1.2em-wide check glyph at each size's icon
|
|
86
|
+
// fontSize (3xs/2xs/2xs), resolved to rem.
|
|
89
87
|
size: {
|
|
90
88
|
sm: {
|
|
91
89
|
control: { width: "3", height: "3" },
|
package/src/Checkbox.tsx
CHANGED
|
@@ -53,9 +53,8 @@ export interface CheckboxProps
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* Checkbox — react-aria-components <Checkbox
|
|
57
|
-
*
|
|
58
|
-
* icon-less checkboxes.
|
|
56
|
+
* Checkbox — a styled react-aria-components <Checkbox>. Children render as
|
|
57
|
+
* the label; wrap them in a visually-hidden span for icon-less checkboxes.
|
|
59
58
|
*/
|
|
60
59
|
export const Checkbox = ({
|
|
61
60
|
size,
|
package/src/CheckboxGroup.tsx
CHANGED
|
@@ -16,8 +16,8 @@ export interface CheckboxGroupProps
|
|
|
16
16
|
extends Omit<RACCheckboxGroupProps, "className" | "style">,
|
|
17
17
|
FieldSupportProps {
|
|
18
18
|
/**
|
|
19
|
-
* Visible label for the group
|
|
20
|
-
*
|
|
19
|
+
* Visible label for the group. Use `aria-label` instead where the design
|
|
20
|
+
* has none.
|
|
21
21
|
*/
|
|
22
22
|
label?: ReactNode;
|
|
23
23
|
/** Label style overrides. */
|
|
@@ -30,11 +30,9 @@ export interface CheckboxGroupProps
|
|
|
30
30
|
/**
|
|
31
31
|
* CheckboxGroup — react-aria-components <CheckboxGroup> for a set of
|
|
32
32
|
* Checkboxes sharing one value array (each Checkbox's `value` marks its
|
|
33
|
-
* entry). Beyond the optional field chrome (label/helperText/errorMessage
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* context provider, so ported call sites gain the chrome rather than
|
|
37
|
-
* restating it around the group.
|
|
33
|
+
* entry). Beyond the optional field chrome (label/helperText/errorMessage)
|
|
34
|
+
* it carries no styling of its own: compose with Stack for layout, as
|
|
35
|
+
* RadioGroup does.
|
|
38
36
|
*/
|
|
39
37
|
export const CheckboxGroup = ({
|
|
40
38
|
label,
|
package/src/CloseButton.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import { CloseIcon } from "./CloseIcon";
|
|
|
10
10
|
|
|
11
11
|
export interface CloseButtonProps
|
|
12
12
|
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "className"> {
|
|
13
|
-
/**
|
|
13
|
+
/** sm is a 24px box, md 32px (default). */
|
|
14
14
|
size?: "sm" | "md";
|
|
15
15
|
/**
|
|
16
16
|
* Grow the touch target 8px beyond the visible button on every side via an
|
|
@@ -24,7 +24,7 @@ export interface CloseButtonProps
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* CloseButton —
|
|
27
|
+
* CloseButton — a standalone X button. A plain button (not react-aria)
|
|
28
28
|
* so call sites can extend the hit area with pseudo-elements, which
|
|
29
29
|
* react-aria's press bounding-rect check would defeat.
|
|
30
30
|
*/
|
package/src/CloseIcon.tsx
CHANGED
|
@@ -12,10 +12,12 @@ export interface CloseIconProps {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* CloseIcon — the "✕" glyph used on close buttons (dialogs, toasts).
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* CloseIcon — the "✕" glyph used on close buttons (dialogs, toasts). Sized to
|
|
16
|
+
* `1em` and `fill: currentColor` like the other icons. Reused wherever a
|
|
17
|
+
* close control is needed.
|
|
18
|
+
*
|
|
19
|
+
* The path is Chakra UI's CloseButton icon, inlined for visual parity with
|
|
20
|
+
* the apps' original look (see the notice in LICENSE.md).
|
|
19
21
|
*/
|
|
20
22
|
export const CloseIcon = ({ css: cssProp, className }: CloseIconProps) => (
|
|
21
23
|
<svg
|
package/src/Code.tsx
CHANGED
package/src/Collapse.tsx
CHANGED
|
@@ -15,13 +15,13 @@ import { css, cx } from "styled-system/css";
|
|
|
15
15
|
import { SystemStyleObject } from "styled-system/types";
|
|
16
16
|
|
|
17
17
|
export interface CollapseProps {
|
|
18
|
-
/** Expanded when true
|
|
18
|
+
/** Expanded when true. */
|
|
19
19
|
isOpen: boolean;
|
|
20
|
-
/** Height when collapsed
|
|
20
|
+
/** Height when collapsed. */
|
|
21
21
|
startingHeight?: number | string;
|
|
22
22
|
/**
|
|
23
|
-
* Height when expanded (
|
|
24
|
-
*
|
|
23
|
+
* Height when expanded (defaults to the measured content height, tracked
|
|
24
|
+
* with a ResizeObserver so nested expansion works).
|
|
25
25
|
*/
|
|
26
26
|
endingHeight?: number | string;
|
|
27
27
|
/** Remove the content from the DOM once the exit transition finishes. */
|
|
@@ -36,15 +36,14 @@ const toCssSize = (v: number | string) =>
|
|
|
36
36
|
typeof v === "number" ? `${v}px` : v;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Collapse —
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* Collapse — an expand/collapse transition: the content is measured and the
|
|
40
|
+
* wrapper's height (and opacity, when collapsing to zero) transitions between
|
|
41
|
+
* the collapsed and expanded sizes. Content stays mounted unless
|
|
42
|
+
* `unmountOnExit` is set.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* outer animation.
|
|
44
|
+
* Only `isOpen` changes animate: initial mounts render at rest, and height
|
|
45
|
+
* corrections (late measurement, content growth) snap — otherwise a collapse
|
|
46
|
+
* mounted inside an entering view morphs during the outer animation.
|
|
48
47
|
*/
|
|
49
48
|
export const Collapse = ({
|
|
50
49
|
isOpen,
|
|
@@ -155,8 +154,8 @@ export const Collapse = ({
|
|
|
155
154
|
height: displayOpen ? expanded : collapsed,
|
|
156
155
|
opacity: displayOpen || !hideWhenCollapsed ? 1 : 0,
|
|
157
156
|
// At rest fully-collapsed, remove the content from the a11y tree
|
|
158
|
-
// and tab order
|
|
159
|
-
//
|
|
157
|
+
// and tab order (kept visible while animating so the exit
|
|
158
|
+
// transition shows).
|
|
160
159
|
visibility:
|
|
161
160
|
displayOpen || animating || !hideWhenCollapsed ? undefined : "hidden",
|
|
162
161
|
...style,
|
package/src/Divider.tsx
CHANGED
|
@@ -59,10 +59,10 @@ const StyledDivider = styled("hr", {
|
|
|
59
59
|
export interface DividerProps extends ComponentProps<typeof StyledDivider> {}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Divider — a hairline rule
|
|
63
|
-
* `
|
|
62
|
+
* Divider — a hairline rule (60% opacity; set `borderColor` to tint,
|
|
63
|
+
* `thickness="thick"` for a 2px rule).
|
|
64
64
|
* `orientation="vertical"` needs a height from the layout, e.g. a stretched
|
|
65
|
-
* flex row
|
|
65
|
+
* flex row.
|
|
66
66
|
*
|
|
67
67
|
* Decorative by default: hidden from assistive tech, since a visual rule
|
|
68
68
|
* between sections is noise as an announced separator (and every call site
|
package/src/Drawer.recipe.ts
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
import { defineSlotRecipe } from "@pandacss/dev";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Drawer slot recipe —
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Drawer slot recipe — a 20rem (`xs`) side panel. Consumed by the shared-ui
|
|
10
|
+
* Drawer, which maps the slots onto react-aria-components' ModalOverlay /
|
|
11
|
+
* Modal / Dialog.
|
|
12
12
|
*
|
|
13
|
-
* The enter transition
|
|
14
|
-
* stiffness 180) with a decelerating tween; exit matches its 0.15s ease-in-out
|
|
13
|
+
* The enter transition is a decelerating tween; the exit a 0.15s ease-in-out
|
|
15
14
|
* tween.
|
|
16
15
|
*
|
|
17
16
|
* Registered in the base preset (base-preset.ts); `placement` is
|
package/src/Drawer.tsx
CHANGED
|
@@ -24,7 +24,7 @@ export interface DrawerProps extends DrawerVariantProps {
|
|
|
24
24
|
onClose: () => void;
|
|
25
25
|
/**
|
|
26
26
|
* Called after the drawer has fully closed (exit transition done and the
|
|
27
|
-
* drawer removed).
|
|
27
|
+
* drawer removed).
|
|
28
28
|
*/
|
|
29
29
|
onCloseComplete?: () => void;
|
|
30
30
|
/** Allow closing by clicking the backdrop / pressing Escape (default true). */
|
|
@@ -39,9 +39,8 @@ export interface DrawerProps extends DrawerVariantProps {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Drawer — a focus-trapping panel that slides in from the side
|
|
43
|
-
*
|
|
44
|
-
* DrawerHeader and DrawerBody inside.
|
|
42
|
+
* Drawer — a focus-trapping panel that slides in from the side, in a single
|
|
43
|
+
* shell; place DrawerHeader and DrawerBody inside.
|
|
45
44
|
*/
|
|
46
45
|
export const Drawer = ({
|
|
47
46
|
isOpen,
|
package/src/Fade.tsx
CHANGED
|
@@ -10,12 +10,9 @@ import { SystemStyleObject } from "styled-system/types";
|
|
|
10
10
|
export interface FadeProps {
|
|
11
11
|
/** Visible when true; faded out (but mounted) when false. */
|
|
12
12
|
isOpen: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Fade-in time in seconds (Chakra's `transition.enter.duration`).
|
|
15
|
-
* Default 0.2, Chakra's.
|
|
16
|
-
*/
|
|
13
|
+
/** Fade-in time in seconds. Default 0.2. */
|
|
17
14
|
enterDuration?: number;
|
|
18
|
-
/** Fade-out time in seconds
|
|
15
|
+
/** Fade-out time in seconds. Default 0.2. */
|
|
19
16
|
exitDuration?: number;
|
|
20
17
|
css?: SystemStyleObject;
|
|
21
18
|
className?: string;
|
|
@@ -23,8 +20,8 @@ export interface FadeProps {
|
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
/**
|
|
26
|
-
* Fade —
|
|
27
|
-
*
|
|
23
|
+
* Fade — a CSS opacity transition (see Slide for the pattern). Content stays
|
|
24
|
+
* mounted throughout.
|
|
28
25
|
*/
|
|
29
26
|
export const Fade = ({
|
|
30
27
|
isOpen,
|
|
@@ -37,9 +34,8 @@ export const Fade = ({
|
|
|
37
34
|
<div
|
|
38
35
|
data-open={isOpen ? "" : undefined}
|
|
39
36
|
// Runtime values, so an inline custom property rather than the css()
|
|
40
|
-
// object
|
|
41
|
-
//
|
|
42
|
-
// picks up the direction's own duration.
|
|
37
|
+
// object. The var switches in the same commit as the opacity, so the
|
|
38
|
+
// transition picks up the direction's own duration.
|
|
43
39
|
style={
|
|
44
40
|
{
|
|
45
41
|
"--fade-duration": `${isOpen ? enterDuration : exitDuration}s`,
|
package/src/Field.recipe.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import { defineSlotRecipe } from "@pandacss/dev";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Field slot recipe —
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Field slot recipe — the label/helper/error chrome, mapped onto
|
|
10
|
+
* react-aria-components' Label/Text/FieldError by `FieldLabel` and
|
|
11
|
+
* `FieldSupport`. Every labelled
|
|
12
12
|
* field in the library draws its chrome from here, including Select and
|
|
13
13
|
* ComboBox, whose own recipe styles only the dropdown pair; the input itself is
|
|
14
14
|
* styled by the `input` recipe (Input.recipe.ts).
|
|
@@ -35,10 +35,9 @@ export const field = defineSlotRecipe({
|
|
|
35
35
|
label: {
|
|
36
36
|
display: "block",
|
|
37
37
|
fontSize: "md",
|
|
38
|
-
// Deliberately not
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
// (settings rows). See the playbook's expected behavioural deltas.
|
|
38
|
+
// Deliberately `normal`, not `medium`: no font in the family's stack
|
|
39
|
+
// has a 500 face (the two render identically on macOS and Windows),
|
|
40
|
+
// and the call sites that cared (settings rows) want `normal`.
|
|
42
41
|
fontWeight: "normal",
|
|
43
42
|
marginEnd: "3",
|
|
44
43
|
mb: "2",
|
|
@@ -46,7 +45,7 @@ export const field = defineSlotRecipe({
|
|
|
46
45
|
transitionDuration: "normal",
|
|
47
46
|
// RAC stamps `data-disabled` on the field root and on the control, never
|
|
48
47
|
// on the label, so an `&[data-disabled]` rule here matches nothing — it
|
|
49
|
-
// has to come down from the root
|
|
48
|
+
// has to come down from the root. Direct child rather than a
|
|
50
49
|
// descendant selector, as the select recipe's invalid rule: an app's own
|
|
51
50
|
// disabled form wrapper must not be able to dim every label inside it.
|
|
52
51
|
"[data-disabled] > &": { opacity: 0.4 },
|
|
@@ -58,7 +57,7 @@ export const field = defineSlotRecipe({
|
|
|
58
57
|
helperText: {
|
|
59
58
|
// RAC's Text renders a span, and RadioGroup/CheckboxGroup roots are not
|
|
60
59
|
// flex containers to blockify it, where an inline box would drop the
|
|
61
|
-
// margin below
|
|
60
|
+
// margin below.
|
|
62
61
|
display: "block",
|
|
63
62
|
mt: "2",
|
|
64
63
|
fontSize: "sm",
|
|
@@ -77,9 +76,7 @@ export const field = defineSlotRecipe({
|
|
|
77
76
|
variants: {
|
|
78
77
|
// The label follows its control's size (the control itself is sized by
|
|
79
78
|
// the `input`/`select` recipes), so one `size` prop scales the whole row.
|
|
80
|
-
//
|
|
81
|
-
// field-chrome notes. Helper and error text stay `sm` at every size, as
|
|
82
|
-
// Chakra's did.
|
|
79
|
+
// Helper and error text stay `sm` at every size.
|
|
83
80
|
size: {
|
|
84
81
|
lg: { label: { fontSize: "lg" } },
|
|
85
82
|
md: { label: { fontSize: "md" } },
|
package/src/Field.tsx
CHANGED
|
@@ -15,15 +15,15 @@ import { field, FieldVariantProps } from "styled-system/recipes";
|
|
|
15
15
|
import { SystemStyleObject } from "styled-system/types";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* The
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* The helper/error chrome every labelled form field shares — TextField,
|
|
19
|
+
* Select, ComboBox, NumberField, RadioGroup and CheckboxGroup carry the same
|
|
20
|
+
* props (data-microbit-org's forms attach helper and error text to all of
|
|
21
|
+
* these).
|
|
22
22
|
*/
|
|
23
23
|
export interface FieldSupportProps {
|
|
24
|
-
/** Help text below the field
|
|
24
|
+
/** Help text below the field. */
|
|
25
25
|
helperText?: ReactNode;
|
|
26
|
-
/** Shown below the field when invalid
|
|
26
|
+
/** Shown below the field when invalid. */
|
|
27
27
|
errorMessage?: ReactNode;
|
|
28
28
|
/** Per-instance style overrides for the helper text. */
|
|
29
29
|
helperTextCss?: SystemStyleObject;
|
|
@@ -87,8 +87,8 @@ interface FieldTextProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* Context-free helper text
|
|
91
|
-
*
|
|
90
|
+
* Context-free helper text for a control react-aria isn't wiring — a native
|
|
91
|
+
* select or a masked input. Inside a RAC field
|
|
92
92
|
* container use `FieldSupport`, which wires `aria-describedby` and validation
|
|
93
93
|
* for free; here the caller owns that wiring: give this an `id` and reference
|
|
94
94
|
* it from the control's `aria-describedby` (as `NativeSelectField` does).
|
|
@@ -111,8 +111,8 @@ export const FieldHelperText = ({
|
|
|
111
111
|
);
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* Context-free error message
|
|
115
|
-
*
|
|
114
|
+
* Context-free error message, the counterpart to `FieldHelperText` — see its
|
|
115
|
+
* note on the wiring the caller owns. RAC's
|
|
116
116
|
* `FieldError` renders only while its field is invalid; here that decision is
|
|
117
117
|
* the caller's too: render it conditionally.
|
|
118
118
|
*/
|
|
@@ -134,9 +134,9 @@ export const FieldErrorMessage = ({
|
|
|
134
134
|
);
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
|
-
* The required-field asterisk
|
|
138
|
-
*
|
|
139
|
-
*
|
|
137
|
+
* The required-field asterisk. Render inside the field's label when
|
|
138
|
+
* `isRequired`; aria-hidden because react-aria already announces requiredness
|
|
139
|
+
* from the input itself.
|
|
140
140
|
*/
|
|
141
141
|
export const FieldRequiredIndicator = () => (
|
|
142
142
|
<span aria-hidden className={field().requiredIndicator}>
|
|
@@ -158,11 +158,9 @@ export interface FieldLabelProps
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
* A field's visible label
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* previously carried a near-identical `label` slot on the `select` recipe,
|
|
165
|
-
* which is how the two drifted.
|
|
161
|
+
* A field's visible label, asterisk included. Every labelled field in the
|
|
162
|
+
* library renders its label through this, so the `field` recipe is the single
|
|
163
|
+
* answer to what a label looks like.
|
|
166
164
|
*
|
|
167
165
|
* Also exported for app-side composites: inside a RAC field container the
|
|
168
166
|
* association is automatic, and outside one (a masked or native input) pass
|
package/src/GridList.recipe.ts
CHANGED
|
@@ -11,8 +11,7 @@ import { defineSlotRecipe } from "@pandacss/dev";
|
|
|
11
11
|
* a listbox: the roving tab index moves through rows, and the controls inside
|
|
12
12
|
* a row are reachable without leaving it).
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* here are the family's neutral list styling, and an app with a strong
|
|
14
|
+
* The greys here are the family's neutral list styling; an app with a strong
|
|
16
15
|
* selection colour restates them (classroom's roster does).
|
|
17
16
|
*
|
|
18
17
|
* Registered in the base preset (base-preset.ts), which also has the
|
package/src/Heading.recipe.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { defineRecipe } from "@pandacss/dev";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Heading recipe —
|
|
9
|
+
* Heading recipe — a bold heading-font base + responsive sizes.
|
|
10
10
|
* A config recipe for the same reasons as `button` (see Button.recipe.ts);
|
|
11
11
|
* the `marketing` variant is token-driven via the `display` font, so brands
|
|
12
12
|
* only override tokens.
|
|
@@ -50,10 +50,10 @@ export const heading = defineRecipe({
|
|
|
50
50
|
//
|
|
51
51
|
// `fontSize` goes through a doubled selector because `size` sets it too,
|
|
52
52
|
// responsively. Source order can't settle that: Panda hoists media
|
|
53
|
-
// queries below the base rules
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
53
|
+
// queries below the base rules and emits variant rules in the order it
|
|
54
|
+
// meets them, so which of the two wins would depend on the breakpoint
|
|
55
|
+
// and on what other call sites exist. Two classes beat one at every
|
|
56
|
+
// width instead.
|
|
57
57
|
label: {
|
|
58
58
|
"&&": { fontSize: "4xl" },
|
|
59
59
|
color: "headingAccent",
|
package/src/Heading.tsx
CHANGED
|
@@ -7,8 +7,8 @@ import { styled } from "styled-system/jsx";
|
|
|
7
7
|
import { heading } from "styled-system/recipes";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Heading —
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Heading — a heading backed by the `heading` config recipe (so the private
|
|
11
|
+
* preset can add brand variants). Defaults to an <h2>; pass `as` to change
|
|
12
|
+
* the element and `size` to pick the type scale.
|
|
13
13
|
*/
|
|
14
14
|
export const Heading = styled("h2", heading);
|
package/src/Icon.tsx
CHANGED
|
@@ -11,8 +11,7 @@ import { SystemStyleObject } from "styled-system/types";
|
|
|
11
11
|
* Any component that renders an `<svg>` from svg props. Deliberately no
|
|
12
12
|
* narrower than the props `Icon` actually passes, so it accepts both
|
|
13
13
|
* react-icons' `IconType` and svgr components (`import X from "./x.svg?react"`,
|
|
14
|
-
* which the apps use for their custom-path icons
|
|
15
|
-
* took either).
|
|
14
|
+
* which the apps use for their custom-path icons).
|
|
16
15
|
*/
|
|
17
16
|
export type IconComponent = ComponentType<
|
|
18
17
|
Pick<
|
|
@@ -32,10 +31,9 @@ export interface IconProps {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
|
-
* Icon — renders a react-icons glyph inline at `1em
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* like Chakra's icons rather than defaulting to black.
|
|
34
|
+
* Icon — renders a react-icons glyph inline at `1em`. `fill: currentColor`
|
|
35
|
+
* means the glyph follows the surrounding text colour rather than defaulting
|
|
36
|
+
* to black (set `css={{ color: ... }}` to override).
|
|
39
37
|
*
|
|
40
38
|
* Unlabelled icons are treated as decorative and hidden from assistive tech;
|
|
41
39
|
* a labelled icon gets `role="img"` (a bare svg aria-label is unreliably
|
|
@@ -57,11 +55,9 @@ export const Icon = ({
|
|
|
57
55
|
lineHeight: "1em",
|
|
58
56
|
flexShrink: 0,
|
|
59
57
|
fill: "currentColor",
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
// flipped — classroom measured the difference at its kill-switch,
|
|
64
|
-
// where the preflight arrived and moved every icon back.
|
|
58
|
+
// Set on the element itself: an inline-block icon sits ~3px off
|
|
59
|
+
// without it. Don't rely on Panda's preflight happening to set it on
|
|
60
|
+
// every svg.
|
|
65
61
|
verticalAlign: "middle",
|
|
66
62
|
...cssProp,
|
|
67
63
|
}),
|
package/src/IconButton.tsx
CHANGED
|
@@ -11,7 +11,7 @@ export interface IconButtonProps
|
|
|
11
11
|
/** Icon-only buttons have no visible label, so this is required. */
|
|
12
12
|
"aria-label": string;
|
|
13
13
|
/**
|
|
14
|
-
* Circular rather than the recipe's border-radius
|
|
14
|
+
* Circular rather than the recipe's border-radius.
|
|
15
15
|
* Usually a visual no-op here: the 2rem `button` radius already renders
|
|
16
16
|
* square icon buttons as circles. Kept for ported call sites and for
|
|
17
17
|
* variants/overrides with a smaller radius (e.g. `unstyled`).
|
package/src/Image.tsx
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { styled } from "styled-system/jsx";
|
|
7
7
|
|
|
8
|
-
/** Image — an <img> accepting Panda style props.
|
|
8
|
+
/** Image — an <img> accepting Panda style props. */
|
|
9
9
|
export const Image = styled("img", {
|
|
10
10
|
base: { maxWidth: "100%" },
|
|
11
11
|
});
|