@microbit/ui 0.1.0-alpha.12 → 0.1.0-alpha.14
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 +9 -2
- package/src/Button.recipe.ts +8 -4
- package/src/Toast.tsx +11 -9
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.14",
|
|
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",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"panda": "panda codegen",
|
|
27
27
|
"typecheck": "npm run panda && tsc --noEmit",
|
|
28
|
+
"pretest": "npm run panda",
|
|
29
|
+
"test": "vitest run",
|
|
28
30
|
"prestorybook": "npm run panda",
|
|
29
31
|
"storybook": "storybook dev -p 6006 --no-open",
|
|
30
32
|
"prebuild-storybook": "npm run panda",
|
|
@@ -40,9 +42,13 @@
|
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@pandacss/dev": "^1.11.4",
|
|
42
44
|
"@storybook/react-vite": "^10.5.2",
|
|
45
|
+
"@testing-library/react": "^16.3.2",
|
|
46
|
+
"@testing-library/user-event": "^14.6.1",
|
|
47
|
+
"@types/node": "^26.1.1",
|
|
43
48
|
"@types/react": "^18.3.3",
|
|
44
49
|
"@types/react-dom": "^18.3.0",
|
|
45
50
|
"@vitejs/plugin-react": "^4.5.2",
|
|
51
|
+
"jsdom": "^29.1.1",
|
|
46
52
|
"react": "^18.3.1",
|
|
47
53
|
"react-aria-components": "^1.19.0",
|
|
48
54
|
"react-dom": "^18.3.1",
|
|
@@ -50,7 +56,8 @@
|
|
|
50
56
|
"react-intl": "^6.6.8",
|
|
51
57
|
"storybook": "^10.5.2",
|
|
52
58
|
"typescript": "^5.4.2",
|
|
53
|
-
"vite": "^6.3.5"
|
|
59
|
+
"vite": "^6.3.5",
|
|
60
|
+
"vitest": "^4.1.10"
|
|
54
61
|
},
|
|
55
62
|
"publishConfig": {
|
|
56
63
|
"tag": "alpha"
|
package/src/Button.recipe.ts
CHANGED
|
@@ -120,13 +120,17 @@ export const button = defineRecipe({
|
|
|
120
120
|
_hover: { bg: "brand.600", _disabled: { bg: "brand.500" } },
|
|
121
121
|
_active: { bg: "brand.700" },
|
|
122
122
|
},
|
|
123
|
+
// 600/700, matching what python-editor's Chakra outline + red
|
|
124
|
+
// colorScheme resolved to. (Extracted from ml-trainer at 500/600, but
|
|
125
|
+
// its one warning button tolerates the darkening; python-editor's
|
|
126
|
+
// "Reset project" was visibly lighter than its Chakra self.)
|
|
123
127
|
warning: {
|
|
124
128
|
borderWidth: "2px",
|
|
125
|
-
borderColor: "danger.
|
|
126
|
-
color: "danger.
|
|
129
|
+
borderColor: "danger.600",
|
|
130
|
+
color: "danger.600",
|
|
127
131
|
bg: "transparent",
|
|
128
|
-
_hover: { borderColor: "danger.
|
|
129
|
-
_active: { bg: "danger.50"
|
|
132
|
+
_hover: { borderColor: "danger.700", color: "danger.700" },
|
|
133
|
+
_active: { bg: "danger.50" },
|
|
130
134
|
},
|
|
131
135
|
// Chakra's built-in solid + red colorScheme (destructive confirm
|
|
132
136
|
// buttons). Same values as `record` today, but a separate variant so
|
package/src/Toast.tsx
CHANGED
|
@@ -102,11 +102,13 @@ export const ToastProvider = () => {
|
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
export interface ToastOptions extends ToastContent {
|
|
105
|
+
/** Auto-dismiss after this many ms. Default 5000. Ignored when `persistent`. */
|
|
106
|
+
duration?: number;
|
|
105
107
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
+
* Never auto-dismiss. The close button is forced on so the toast is not
|
|
109
|
+
* permanent and unremovable.
|
|
108
110
|
*/
|
|
109
|
-
|
|
111
|
+
persistent?: boolean;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
export interface ToastFn {
|
|
@@ -123,8 +125,9 @@ export interface ToastFn {
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
/**
|
|
126
|
-
* useToast — imperative toast trigger
|
|
127
|
-
*
|
|
128
|
+
* useToast — imperative toast trigger in the shape of Chakra's `useToast()`
|
|
129
|
+
* call sites: `toast({ title, description, status, duration })`. Unlike
|
|
130
|
+
* Chakra there is no `duration: null`; use `persistent: true` instead.
|
|
128
131
|
*/
|
|
129
132
|
export const useToast = (): ToastFn =>
|
|
130
133
|
useMemo(() => {
|
|
@@ -137,6 +140,7 @@ export const useToast = (): ToastFn =>
|
|
|
137
140
|
status,
|
|
138
141
|
isClosable,
|
|
139
142
|
duration,
|
|
143
|
+
persistent,
|
|
140
144
|
}: ToastOptions) => {
|
|
141
145
|
if (id && isActive(id)) {
|
|
142
146
|
return;
|
|
@@ -147,11 +151,9 @@ export const useToast = (): ToastFn =>
|
|
|
147
151
|
title,
|
|
148
152
|
description,
|
|
149
153
|
status,
|
|
150
|
-
|
|
151
|
-
// permanent and unremovable; force the close button on.
|
|
152
|
-
isClosable: isClosable || duration == null,
|
|
154
|
+
isClosable: isClosable || persistent,
|
|
153
155
|
},
|
|
154
|
-
{ timeout: duration ??
|
|
156
|
+
{ timeout: persistent ? undefined : duration ?? 5000 },
|
|
155
157
|
);
|
|
156
158
|
};
|
|
157
159
|
const update = (id: string, options: ToastOptions) => {
|