anvilui 0.4.0 → 0.4.1
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/AGENTS.md +3 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +1 -1
- package/dist/index.cjs +76 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +76 -9
- package/dist/index.js.map +1 -1
- package/docs/llms-index.md +1 -0
- package/docs/styling.md +40 -0
- package/docs/theming.md +1 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -423,6 +423,8 @@ There is no `Alert` or `Banner`. For a message after an action, use a snackbar (
|
|
|
423
423
|
|
|
424
424
|
Inside AnvilRoot: `var(--avl-color-background)`, `var(--avl-color-on-background)`, `var(--avl-color-on-background-muted)`, `var(--avl-color-primary)`, `var(--avl-color-surface)`, `var(--avl-color-divider)`, spacing `var(--avl-spacing-x1…x20)` (4px steps), radius `var(--avl-radius-medium)`. Custom brand: `createTheme('#0B6E4F')` → `<AnvilRoot lightTheme={t.light} darkTheme={t.dark}>` ([theming.md](docs/theming.md)).
|
|
425
425
|
|
|
426
|
+
Overriding a component's CSS: target only its root class (`.avl-<component>`, e.g. `.avl-card`, `.avl-menu-item`) and Base UI `data-*` state, together with your own class. Part classes (`.avl-switch-thumb`), size/color classes and component variables (`--avl-button-height`) are internal and change between releases. Details: [styling.md](docs/styling.md).
|
|
427
|
+
|
|
426
428
|
## Common mistakes
|
|
427
429
|
|
|
428
430
|
| Wrong (other libraries) | Right (AnvilUI) |
|
|
@@ -456,6 +458,7 @@ Inside AnvilRoot: `var(--avl-color-background)`, `var(--avl-color-on-background)
|
|
|
456
458
|
| `snackbar.show({ message, severity: 'success' })` | no severity; put it in the message |
|
|
457
459
|
| `<Typography variant="h4">` | `<Typography type="h4">` |
|
|
458
460
|
| `<Skeleton variant="circular">` | `<Skeleton type="circular">` |
|
|
461
|
+
| CSS on `.avl-button-size-big`, `.avl-fill-outlined`, `.avl-switch-thumb` | props (`size`, `fillType`), or the root class (`.avl-button`) with your own class |
|
|
459
462
|
| `<AppBar title="Inbox">` / `<AppBar>Inbox</AppBar>` | `<AppBar label="Inbox" />` |
|
|
460
463
|
| `<ListItem>Text</ListItem>` / `primary=` / `secondary=` | `<ListItem label="Text" description="More" />` |
|
|
461
464
|
| `<ListItem onClick={…} />` expecting a button | `<ListItem label="…" render={<button type="button" onClick={…} />} />` |
|
|
@@ -31,7 +31,7 @@ export type FloatingToolbarButtonProps = IconButtonProps;
|
|
|
31
31
|
* An `IconButton` that joins the toolbar's arrow-key navigation. Text style
|
|
32
32
|
* by default; `fillType="filled"` makes it the wider, highlighted one.
|
|
33
33
|
*/
|
|
34
|
-
export declare function FloatingToolbarButton({ fillType, color, disabled, ...props }: FloatingToolbarButtonProps): import("react").JSX.Element;
|
|
34
|
+
export declare function FloatingToolbarButton({ fillType, color, disabled, className, ...props }: FloatingToolbarButtonProps): import("react").JSX.Element;
|
|
35
35
|
export type FloatingToolbarSeparatorProps = BaseToolbar.Separator.Props;
|
|
36
36
|
/** A thin line between groups of buttons. */
|
|
37
37
|
export declare function FloatingToolbarSeparator({ className, ...props }: FloatingToolbarSeparatorProps): import("react").JSX.Element;
|
package/dist/index.cjs
CHANGED
|
@@ -2379,7 +2379,7 @@ function FABMenu({
|
|
|
2379
2379
|
ref: mergeRefs(trigger, ref),
|
|
2380
2380
|
"aria-label": ariaLabel,
|
|
2381
2381
|
className: cx(
|
|
2382
|
-
"avl-fab avl-fab-size-normal avl-fab-menu-trigger",
|
|
2382
|
+
"avl-fab avl-fab-size-normal avl-fab-menu avl-fab-menu-trigger",
|
|
2383
2383
|
colorClass(color, fillType),
|
|
2384
2384
|
className
|
|
2385
2385
|
),
|
|
@@ -2701,7 +2701,10 @@ function MenuSubmenuTrigger({
|
|
|
2701
2701
|
import_menu2.Menu.SubmenuTrigger,
|
|
2702
2702
|
{
|
|
2703
2703
|
...props,
|
|
2704
|
-
className: withClass(
|
|
2704
|
+
className: withClass(
|
|
2705
|
+
"avl-menu-item avl-menu-submenu-trigger",
|
|
2706
|
+
className
|
|
2707
|
+
),
|
|
2705
2708
|
children: [
|
|
2706
2709
|
startIcon && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Icon, { name: startIcon }),
|
|
2707
2710
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "avl-menu-item-label", children }),
|
|
@@ -3012,7 +3015,7 @@ function PreviewCardPopup({
|
|
|
3012
3015
|
{
|
|
3013
3016
|
...props,
|
|
3014
3017
|
className: withClass(
|
|
3015
|
-
"avl-menu-popup avl-popover-popup",
|
|
3018
|
+
"avl-menu-popup avl-popover-popup avl-preview-card-popup",
|
|
3016
3019
|
className
|
|
3017
3020
|
)
|
|
3018
3021
|
}
|
|
@@ -4093,7 +4096,10 @@ function ComboboxItem({
|
|
|
4093
4096
|
import_combobox.Combobox.Item,
|
|
4094
4097
|
{
|
|
4095
4098
|
...props,
|
|
4096
|
-
className: withClass(
|
|
4099
|
+
className: withClass(
|
|
4100
|
+
"avl-menu-item avl-select-item avl-combobox-item",
|
|
4101
|
+
className
|
|
4102
|
+
),
|
|
4097
4103
|
children: [
|
|
4098
4104
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "avl-menu-item-label", children }),
|
|
4099
4105
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_combobox.Combobox.ItemIndicator, { className: "avl-select-item-indicator", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Icon, { name: "check" }) })
|
|
@@ -4317,7 +4323,7 @@ function SearchItem({
|
|
|
4317
4323
|
import_autocomplete.Autocomplete.Item,
|
|
4318
4324
|
{
|
|
4319
4325
|
...props,
|
|
4320
|
-
className: withClass("avl-menu-item", className),
|
|
4326
|
+
className: withClass("avl-menu-item avl-search-item", className),
|
|
4321
4327
|
children: [
|
|
4322
4328
|
startIcon && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: startIcon }),
|
|
4323
4329
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "avl-menu-item-label", children })
|
|
@@ -4776,13 +4782,25 @@ function FloatingToolbarButton({
|
|
|
4776
4782
|
// Filled means highlighted: primary stands out on the toolbar's surface
|
|
4777
4783
|
color = fillType === "filled" ? "primary" : "container",
|
|
4778
4784
|
disabled,
|
|
4785
|
+
className,
|
|
4779
4786
|
...props
|
|
4780
4787
|
}) {
|
|
4781
4788
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4782
4789
|
import_toolbar.Toolbar.Button,
|
|
4783
4790
|
{
|
|
4784
4791
|
disabled,
|
|
4785
|
-
render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4792
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4793
|
+
IconButton,
|
|
4794
|
+
{
|
|
4795
|
+
...props,
|
|
4796
|
+
color,
|
|
4797
|
+
fillType,
|
|
4798
|
+
className: withClass(
|
|
4799
|
+
"avl-floating-toolbar-button",
|
|
4800
|
+
className
|
|
4801
|
+
)
|
|
4802
|
+
}
|
|
4803
|
+
)
|
|
4786
4804
|
}
|
|
4787
4805
|
);
|
|
4788
4806
|
}
|
|
@@ -5313,23 +5331,72 @@ var neutralRoles = [
|
|
|
5313
5331
|
"inverseSurface",
|
|
5314
5332
|
"inverseOnSurface"
|
|
5315
5333
|
];
|
|
5334
|
+
var statusSwaps = [
|
|
5335
|
+
{
|
|
5336
|
+
roles: [
|
|
5337
|
+
"success",
|
|
5338
|
+
"onSuccess",
|
|
5339
|
+
"successContainer",
|
|
5340
|
+
"onSuccessContainer"
|
|
5341
|
+
],
|
|
5342
|
+
from: 105,
|
|
5343
|
+
to: 190,
|
|
5344
|
+
hue: 255
|
|
5345
|
+
},
|
|
5346
|
+
{
|
|
5347
|
+
roles: ["error", "onError", "errorContainer", "onErrorContainer"],
|
|
5348
|
+
from: 10,
|
|
5349
|
+
to: 60,
|
|
5350
|
+
hue: 350
|
|
5351
|
+
},
|
|
5352
|
+
// Only yellow/gold: past orange there's no hue left that still reads as
|
|
5353
|
+
// a warning without looking like the error color
|
|
5354
|
+
{
|
|
5355
|
+
roles: [
|
|
5356
|
+
"warning",
|
|
5357
|
+
"onWarning",
|
|
5358
|
+
"warningContainer",
|
|
5359
|
+
"onWarningContainer"
|
|
5360
|
+
],
|
|
5361
|
+
from: 75,
|
|
5362
|
+
to: 105,
|
|
5363
|
+
hue: 55
|
|
5364
|
+
}
|
|
5365
|
+
];
|
|
5316
5366
|
var reference = toOklch(parseHex(baseLightTheme.primary));
|
|
5317
5367
|
function generate(base, primary, secondary) {
|
|
5318
5368
|
const theme = { ...base };
|
|
5369
|
+
const roleOf = (key) => toOklch(parseHex(base[key]));
|
|
5370
|
+
const write = (key, l, c, h) => {
|
|
5371
|
+
;
|
|
5372
|
+
theme[key] = toHex(l, c, h);
|
|
5373
|
+
};
|
|
5319
5374
|
const set = (keys, seed, neutral) => {
|
|
5320
5375
|
const scale = seed.c / reference.c;
|
|
5321
5376
|
for (const key of keys) {
|
|
5322
|
-
const role =
|
|
5377
|
+
const role = roleOf(key);
|
|
5323
5378
|
const c = role.c * (neutral ? Math.min(scale, 1) : scale);
|
|
5324
|
-
|
|
5325
|
-
theme[key] = toHex(role.l, c, h);
|
|
5379
|
+
write(key, role.l, c, seed.h + role.h - reference.h);
|
|
5326
5380
|
}
|
|
5327
5381
|
};
|
|
5328
5382
|
set(primaryRoles, primary, false);
|
|
5329
5383
|
set(tonalRoles, secondary, false);
|
|
5330
5384
|
set(neutralRoles, primary, true);
|
|
5385
|
+
if (primary.c >= 0.04) {
|
|
5386
|
+
for (const swap of statusSwaps) {
|
|
5387
|
+
if (!hueInRange(primary.h, swap.from, swap.to)) continue;
|
|
5388
|
+
const shift = swap.hue - roleOf(swap.roles[0]).h;
|
|
5389
|
+
for (const key of swap.roles) {
|
|
5390
|
+
const role = roleOf(key);
|
|
5391
|
+
write(key, role.l, role.c, role.h + shift);
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5394
|
+
}
|
|
5331
5395
|
return theme;
|
|
5332
5396
|
}
|
|
5397
|
+
function hueInRange(h, from, to) {
|
|
5398
|
+
return from <= to ? h >= from && h <= to : h >= from || h <= to;
|
|
5399
|
+
}
|
|
5333
5400
|
function mainColors(pixels) {
|
|
5334
5401
|
const bins = Array.from({ length: 36 }, () => ({ w: 0, l: 0, a: 0, b: 0 }));
|
|
5335
5402
|
const grey = { w: 0, l: 0, a: 0, b: 0 };
|