@noxlovette/material 0.7.0 → 0.7.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.
@@ -2,7 +2,7 @@
2
2
  @component
3
3
  Icon buttons help people take minor actions with one tap.
4
4
 
5
- - Filled: high emphasis (default)
5
+ - Filled: high emphasis (default, except inside an `AppBar`, where it's standard)
6
6
  - Tonal: medium-high emphasis
7
7
  - Outlined: medium emphasis
8
8
  - Standard: low emphasis, no container at rest; for app bars, fields and dense layouts
@@ -17,12 +17,16 @@ Icon buttons help people take minor actions with one tap.
17
17
  import { buttonColor, buttonIcon } from './theme.js';
18
18
  import clsx from 'clsx';
19
19
  import { buttonCorners, shapeMorph } from './shapeMorph.js';
20
+ import { getButtonIconVariant } from './context.js';
20
21
  import Tooltip from '../forms/tooltip/Tooltip.svelte';
21
22
  import { Button, Toggle, type ButtonRootProps, type ToggleRootProps } from 'bits-ui';
22
23
 
24
+ // A container like AppBar can lower the default emphasis; an explicit `variant` still wins.
25
+ const inheritedVariant = getButtonIconVariant();
26
+
23
27
  let {
24
28
  iconProps,
25
- variant = 'filled',
29
+ variant = inheritedVariant ?? 'filled',
26
30
  size = 'sm',
27
31
  shape = 'round',
28
32
  width = 'default',
@@ -2,7 +2,7 @@ import type { ButtonIconProps } from './types.js';
2
2
  /**
3
3
  * Icon buttons help people take minor actions with one tap.
4
4
  *
5
- * - Filled: high emphasis (default)
5
+ * - Filled: high emphasis (default, except inside an `AppBar`, where it's standard)
6
6
  * - Tonal: medium-high emphasis
7
7
  * - Outlined: medium emphasis
8
8
  * - Standard: low emphasis, no container at rest; for app bars, fields and dense layouts
@@ -0,0 +1,10 @@
1
+ import type { ButtonIconProps } from './types.js';
2
+ type ButtonIconVariant = NonNullable<ButtonIconProps['variant']>;
3
+ /**
4
+ * Sets the variant a `ButtonIcon` below this component takes when it's given none, e.g. an
5
+ * app bar's `standard` (M3: icon buttons in app bars have no container). An explicit
6
+ * `variant` on the button always wins.
7
+ */
8
+ export declare const setButtonIconVariant: (variant: ButtonIconVariant) => ButtonIconVariant;
9
+ export declare const getButtonIconVariant: () => ButtonIconVariant | undefined;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ const KEY = Symbol('buttonIconVariant');
3
+ /**
4
+ * Sets the variant a `ButtonIcon` below this component takes when it's given none, e.g. an
5
+ * app bar's `standard` (M3: icon buttons in app bars have no container). An explicit
6
+ * `variant` on the button always wins.
7
+ */
8
+ export const setButtonIconVariant = (variant) => setContext(KEY, variant);
9
+ export const getButtonIconVariant = () => getContext(KEY);
@@ -17,6 +17,9 @@ Publishes its measured height as `--appbar-height` on the document root, so any
17
17
  that amount with no props or wiring on either side — see Pane.svelte's doc
18
18
  comment.
19
19
 
20
+ A `ButtonIcon` anywhere inside it defaults to `variant="standard"`, per M3; pass
21
+ `variant` to override.
22
+
20
23
  @see https://m3.material.io/components/app-bars/specs
21
24
  -->
22
25
  <script lang="ts">
@@ -24,6 +27,7 @@ comment.
24
27
  import type { AppBarProps } from './types.js';
25
28
  import clsx from 'clsx';
26
29
  import ButtonIcon from '../../buttons/ButtonIcon.svelte';
30
+ import { setButtonIconVariant } from '../../buttons/context.js';
27
31
 
28
32
  let {
29
33
  children,
@@ -48,6 +52,10 @@ comment.
48
52
  ...rest
49
53
  }: AppBarProps = $props();
50
54
 
55
+ // M3 app bar icon buttons are standard (no container); a filled one over-emphasizes a back or
56
+ // action button. Applies to buttons passed in `leading`/`trailing`/`children` too.
57
+ setButtonIconVariant('standard');
58
+
51
59
  let scrolled = $state(false);
52
60
  let barHeight = $state(64);
53
61
 
@@ -17,6 +17,9 @@ import type { AppBarProps } from './types.js';
17
17
  * that amount with no props or wiring on either side — see Pane.svelte's doc
18
18
  * comment.
19
19
  *
20
+ * A `ButtonIcon` anywhere inside it defaults to `variant="standard"`, per M3; pass
21
+ * `variant` to override.
22
+ *
20
23
  * @see https://m3.material.io/components/app-bars/specs
21
24
  */
22
25
  declare const AppBar: import("svelte").Component<AppBarProps, {}, "query">;
@@ -141,12 +141,23 @@ export const appbar = tv({
141
141
  // 1fr side columns centre a small bar's title on the bar, not between uneven button groups.
142
142
  center: { row: 'grid-cols-[1fr_auto_1fr]', textContainer: 'items-center text-center' }
143
143
  },
144
+ /*
145
+ From medium up, a Pane rounds its top corners (md:rounded-t-*) and sits as a surface card
146
+ on the App's surface-container, beside a surface-container Rail. The bar is part of that
147
+ chrome there, so it stays surface-container whether scrolled or not: a surface bar
148
+ would read as a strip glued over the card, with the App's colour showing through the
149
+ pane's corners beneath it. Below medium the pane is flat and full-bleed, so the bar keeps
150
+ M3's surface → surface-container on-scroll change.
151
+ */
144
152
  scrolled: {
145
153
  true: {
146
154
  base: 'bg-md-sys-color-surface-container',
147
155
  search: 'bg-md-sys-color-surface-container-highest'
148
156
  },
149
- false: { base: 'bg-md-sys-color-surface', search: 'bg-md-sys-color-surface-container' }
157
+ false: {
158
+ base: 'bg-md-sys-color-surface md:bg-md-sys-color-surface-container',
159
+ search: 'bg-md-sys-color-surface-container md:bg-md-sys-color-surface-container-highest'
160
+ }
150
161
  },
151
162
  // Search app bar: the search container fills the text column, 8dp from the buttons.
152
163
  searchContainer: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noxlovette/material",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "description": "A Material Design 3 component library for Svelte, built on Bits UI.",
6
6
  "keywords": [