@microbit/ui 0.1.0-alpha.6 → 0.1.0-alpha.8
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/README.md +13 -0
- package/package.json +3 -1
- package/reset.css +23 -0
- package/src/Collapse.tsx +13 -1
- package/src/base-preset.ts +6 -4
package/README.md
CHANGED
|
@@ -44,22 +44,35 @@ an app must do:
|
|
|
44
44
|
4. **Generate and load the CSS** with Panda's PostCSS plugin. Keep Vite's
|
|
45
45
|
default transformer — do **not** set `css.transformer: "lightningcss"`,
|
|
46
46
|
which disables PostCSS. Add a `postcss.config.cjs`:
|
|
47
|
+
|
|
47
48
|
```js
|
|
48
49
|
module.exports = { plugins: { "@pandacss/dev/postcss": {} } };
|
|
49
50
|
```
|
|
51
|
+
|
|
50
52
|
Run `panda codegen` as a `prepare`/`predev` step so the `styled-system/*`
|
|
51
53
|
helpers exist before `tsc`; the plugin generates the CSS during the bundle.
|
|
52
54
|
Import **one** entry stylesheet — first, before app styles — that declares
|
|
53
55
|
the cascade-layer order; the plugin injects the generated CSS into it (the
|
|
54
56
|
declaration must list all of Panda's layers, hence ≥5 names):
|
|
57
|
+
|
|
55
58
|
```css
|
|
56
59
|
/* e.g. src/layers.css, imported once at the app root */
|
|
57
60
|
@layer reset, vendor, base, tokens, recipes, utilities;
|
|
61
|
+
|
|
62
|
+
@import "@microbit/ui/reset.css" layer(reset);
|
|
58
63
|
```
|
|
64
|
+
|
|
65
|
+
The `reset.css` import is **required**: it carries the Chakra-parity
|
|
66
|
+
`* { border-color; word-wrap }` defaults, which must sit in the bottom
|
|
67
|
+
layer (the legacy-Safari cascade-layer flattening specificity-boosts
|
|
68
|
+
higher layers above CSS it can't see — runtime-injected styles, other
|
|
69
|
+
files; playbook gotcha #28). Without it, elements that set a border
|
|
70
|
+
width but no colour render `currentColor` borders.
|
|
59
71
|
The `vendor` layer is for third-party stylesheets: import any vendor CSS
|
|
60
72
|
with `@import "..." layer(vendor)` so it beats the preflight reset but
|
|
61
73
|
loses to app styling. See `.storybook/{layers.css,preview.tsx,main.ts}` +
|
|
62
74
|
`postcss.config.cjs` for the worked example.
|
|
75
|
+
|
|
63
76
|
5. **react-intl**: an `IntlProvider` above any shared-ui usage. English
|
|
64
77
|
works with no setup (components carry inline `defaultMessage`); for
|
|
65
78
|
other locales compile this package's `lang/ui.<locale>.json` into the
|
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.8",
|
|
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",
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
"./base-tokens": "./src/base-tokens.ts",
|
|
11
11
|
"./messages": "./src/messages.ts",
|
|
12
12
|
"./postcss-legacy-safari": "./postcss-legacy-safari.cjs",
|
|
13
|
+
"./reset.css": "./reset.css",
|
|
13
14
|
"./lang/*": "./lang/*"
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
16
17
|
"src",
|
|
17
18
|
"lang",
|
|
18
19
|
"postcss-legacy-safari.cjs",
|
|
20
|
+
"reset.css",
|
|
19
21
|
"README.md",
|
|
20
22
|
"LICENSE.md"
|
|
21
23
|
],
|
package/reset.css
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (c) 2026, Micro:bit Educational Foundation and contributors
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Chakra-reset parity that must live in the `reset` cascade layer: import
|
|
7
|
+
* from the app's layers.css with
|
|
8
|
+
*
|
|
9
|
+
* @import "@microbit/ui/reset.css" layer(reset);
|
|
10
|
+
*
|
|
11
|
+
* Deliberately not in the preset's globalCss: globalCss emits into the
|
|
12
|
+
* `base` layer, and the legacy-Safari cascade-layer flattening
|
|
13
|
+
* specificity-boosts base+ rules above CSS it can't see (runtime-injected
|
|
14
|
+
* styles such as CodeMirror themes, and other per-file-processed app CSS).
|
|
15
|
+
* A reset must stay at the bottom of the cascade in production exactly as
|
|
16
|
+
* it is in dev — see playbook gotcha #28.
|
|
17
|
+
*/
|
|
18
|
+
*,
|
|
19
|
+
*::before,
|
|
20
|
+
*::after {
|
|
21
|
+
border-color: var(--colors-gray-200);
|
|
22
|
+
word-wrap: break-word;
|
|
23
|
+
}
|
package/src/Collapse.tsx
CHANGED
|
@@ -162,7 +162,19 @@ export const Collapse = ({
|
|
|
162
162
|
...style,
|
|
163
163
|
}}
|
|
164
164
|
>
|
|
165
|
-
<div
|
|
165
|
+
<div
|
|
166
|
+
ref={contentRef}
|
|
167
|
+
// flow-root: the measured element must be a block formatting
|
|
168
|
+
// context, or children's margins collapse through it and
|
|
169
|
+
// scrollHeight under-measures — the outer (overflow: hidden)
|
|
170
|
+
// wrapper IS a BFC and needs the full height, so the mismatch
|
|
171
|
+
// clips the last line of margined content (python-editor's API
|
|
172
|
+
// docs). Rendering is unchanged: the margins always displayed
|
|
173
|
+
// inside the outer BFC.
|
|
174
|
+
className={css({ display: "flow-root" })}
|
|
175
|
+
>
|
|
176
|
+
{children}
|
|
177
|
+
</div>
|
|
166
178
|
</div>
|
|
167
179
|
);
|
|
168
180
|
};
|
package/src/base-preset.ts
CHANGED
|
@@ -211,10 +211,12 @@ export const basePreset = definePreset({
|
|
|
211
211
|
"*::placeholder": {
|
|
212
212
|
color: "gray.500",
|
|
213
213
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
// The `* { border-color; word-wrap }` Chakra-reset parity lives in
|
|
215
|
+
// ../reset.css, imported into the `reset` layer by consumers'
|
|
216
|
+
// layers.css — NOT here: globalCss emits into the `base` layer, which
|
|
217
|
+
// the legacy-Safari cascade-layer flattening specificity-boosts above
|
|
218
|
+
// runtime-injected CSS (CodeMirror themes) and other app CSS files.
|
|
219
|
+
// Resets must stay at the bottom (playbook gotcha #28).
|
|
218
220
|
// Panda's preflight, unlike Chakra's reset, doesn't set the pointer
|
|
219
221
|
// cursor on buttons. Recipes' disabled states (cursor: not-allowed)
|
|
220
222
|
// override this from the higher recipes layer.
|