svelte-fluentui 1.3.1 → 1.3.2

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 CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  A comprehensive Svelte wrapper library for Microsoft FluentUI web components (v2.6.x), providing a seamless way to use FluentUI components in Svelte applications.
4
4
 
5
+ ## What's New in v1.3.2
6
+
7
+ - **`TopNav` — hamburger flexibility via `menuToggleSize` + `menuToggleTemplate`** — `menuToggleSize` (default `42`) flows through a `--topnav-toggle-size` CSS variable so the glyph and close-icon scale proportionally with the box. `menuToggleTemplate: Snippet<[{open, toggle}]>` lets consumers render any button shape — text + chevron, brand-styled accent button, custom SVG — and still wire up state correctly. Both paths render inside a wrapper that owns the visibility/order/collapse rules, so custom templates automatically inherit hide-when-wide / show-when-narrow / stay-visible-when-pinned behavior.
8
+ - **`TopNav` — default hamburger is now a plain `<button>` instead of a fluent-button** — the previous default rendered `<Button appearance="stealth">` which still carried button chrome (hover background fill, boxed visual weight). Replaced with a vanilla `<button>` styled `background: transparent; border: none; padding: 0`, with `opacity: 0.7` on hover and a `:focus-visible` accent outline for keyboard nav. Reads as just the icon, not a button containing an icon. Click target still fills the full `menuToggleSize` box for touch reachability.
9
+ - **`Badge` — new `radius` prop overrides the binary rounded-rect / pill shape with an arbitrary border-radius** — Badge had exactly two shape modes (default 4px corner / `circular={true}` pill) mirroring Microsoft's FluentUI Badge `shape` prop. The new `radius?: string` accepts any CSS length (`8px`, `0.5rem`, `var(--my-radius)`) and emits inline `border-radius`, winning over both class rules via CSS specificity. Plays nicely with `circular={true}` — the circular sizing wins, the radius wins, so you get pill-sized badges with non-pill corners if you want.
10
+
5
11
  ## What's New in v1.3.1
6
12
 
7
13
  - **`Panel` — new `pinned` prop renders the panel as an inline `<aside>` instead of a portal'd overlay** — flips the rendering entirely: no portal, no backdrop, no transforms, no escape/outside-click handlers, `position: relative` so it participates in the parent's flex/grid layout, `align-self: stretch` so it fills its grid cell vertically. `open` is still respected so the panel can hide and let its grid cell collapse. Explicit z-index forms its own stacking context so overlay Panels opened on top still layer above as expected.
@@ -9,15 +15,6 @@ A comprehensive Svelte wrapper library for Microsoft FluentUI web components (v2
9
15
  - **Docs layout switched to a single nav surface at every width via `drawerPinned`** — the duplicate desktop sidebar `GridItem` is gone; TopNav's drawer now renders as a pinned `<aside>` at ≥1024px and collapses to the hamburger overlay below. The layout uses CSS Grid with `grid-template-areas` and a `matchMedia` listener to drive `drawerPinned`. The pinned rail is `position: sticky` below the topnav and the scrollbar sits flush with the rail's inside edge.
10
16
  - **`TopNav` — tightened horizontal padding from `1.5rem` to `0.5rem`** — the bar's inside edges felt cramped relative to the rest of the content. Brand + hamburger now sit closer to the inline-start edge and the action slot sits closer to the inline-end edge.
11
17
 
12
- ## What's New in v1.3.0
13
-
14
- - **`Panel` — new slide-in side-panel primitive** — fixed-position, edge-anchored container with a single `children` slot and CSS-driven open/close transitions. Props cover physical sides (`left`/`right`), logical sides (`start`/`end` that follow RTL), `width`, `overlay`, `closeOnOutsideClick`, `closeOnEscape`, and a new `top` offset so the panel + overlay can sit below a sticky header (e.g. TopNav) and leave the trigger button clickable. Portals to `document.body` with direction captured before portal so locally-RTL wrappers still anchor correctly. First-class demo at `/components/navigation-layout/panel`.
15
- - **`TopNav` drawer rebuilt on `Panel`; container queries replace media queries** — the bespoke `.mobile-sidebar` div with hand-rolled `left: -280px` / `transition` CSS is gone, replaced with `<Panel side="start" width="280px" top="{height}px">` so Escape-close, portal, overlay outside-click, and `aria-modal` all come for free. The collapse breakpoint is now an `@container topnav (max-width: 960px)` query keyed on the nav's own width (aligns with Grid's `md`), so behavior is intrinsic to the bar regardless of where it's mounted. `items` auto-populate the drawer, the hamburger only renders when there's content to open, and the action slot now stays visible at every width.
16
- - **`TopNav` — `brandTemplate`, `drawerContent`, and `collapse` snippets/props** — `brandTemplate` replaces the default `<a>` brand rendering so consumers can compose logo + wordmark + version badge as one unit; `drawerContent: Snippet<[() => void]>` renders custom content inside the mobile drawer and receives a `closeDrawer` callback so link clicks can dismiss the drawer before navigation; `collapse: "auto" | "always" | "never"` overrides the container-query state when the consumer drives sidebar visibility from its own responsive breakpoint. First demo page added at `/components/navigation-layout/topnav`.
17
- - **`Footer` — `start` / `center` / `end` named snippets with a truly-centered grid layout** — Footer previously had a single `children` slot, so a "© left, brand center, version right" arrangement required inline `justify-content: space-between` and hoping the middle item floated where you wanted. The new snippets switch Footer into a CSS Grid (`1fr auto 1fr`) where the center column is genuinely centered regardless of side-section widths, with explicit `grid-column` placement so a missing section doesn't reflow the others. New `stack` prop (default `true`) collapses to a single inline-start column below 600px via a container query keyed on the footer itself. RTL flips `start` ↔ `end` automatically.
18
- - **`Footer` — class namespaced as `.fluent-footer`, wired to the dedicated theme tokens, thin-strip bug fixed** — the rendered class went from generic `.footer` (collided with anything else using that name) to `.fluent-footer`, the rule now reads from `--fluent-footer-bg/text/border` (which were defined in the theme system but unused) with the previous neutral-layer values as fallback, a duplicate Blazor-port `.footer` rule was deleted, and `min-height: 48px` + `padding: 0.75rem 1rem` replaces the original horizontal-only padding so a default Footer is no longer a ~24px thin strip. First dedicated demo page at `/components/navigation-layout/footer`.
19
- - **Docs site dogfoods the new primitives** — the hand-rolled `<div class="topnav">` with ~90 lines of parallel CSS is replaced with `<TopNav class="docs-topnav" collapse="always">` using `brandTemplate` for the brand+version pair and `drawerContent` for the mobile sidebar nav. The sidebar nav is extracted into a single `{#snippet sidebarNav(closeDrawer)}` rendered both as the desktop sidebar and inside the TopNav drawer, with the sidebar/hamburger handoff at `lg` (1280px) instead of `md` so laptops at 1280×800 stay roomy. The footer at the bottom of every page now uses the three-part layout (© + MIT / attribution / GitHub + npm + version chip).
20
-
21
18
  ## Features
22
19
 
23
20
  - 🎨 **Complete FluentUI Component Set** - Wraps all major FluentUI web components
@@ -18,6 +18,7 @@
18
18
  fill?: string
19
19
  appearance?: BadgeAppearance
20
20
  circular?: boolean
21
+ radius?: string
21
22
  children?: SlotType
22
23
  onclick?: (ev: MouseEvent) => void
23
24
  class?: string
@@ -29,6 +30,7 @@
29
30
  fill = undefined,
30
31
  appearance = "lightweight",
31
32
  circular = false,
33
+ radius = undefined,
32
34
  children = undefined,
33
35
  onclick = undefined,
34
36
  class: className = "",
@@ -51,7 +53,9 @@
51
53
  return styles
52
54
  })
53
55
 
54
- let computedStyle = $derived([colorStyles, style].filter(Boolean).join(" "))
56
+ let radiusStyle = $derived(radius ? `border-radius: ${radius};` : "")
57
+
58
+ let computedStyle = $derived([colorStyles, radiusStyle, style].filter(Boolean).join(" "))
55
59
 
56
60
  let classes = $derived.by(() => {
57
61
  let cls = ["badge"]
@@ -15,6 +15,7 @@ type Props = {
15
15
  fill?: string;
16
16
  appearance?: BadgeAppearance;
17
17
  circular?: boolean;
18
+ radius?: string;
18
19
  children?: SlotType;
19
20
  onclick?: (ev: MouseEvent) => void;
20
21
  class?: string;
@@ -764,7 +764,7 @@ declare function $$render<T>(): {
764
764
  row: T;
765
765
  rowIndex: number;
766
766
  }) => void | Promise<void>) | undefined;
767
- }, "title" | "group" | "icon" | "id" | "row">> & Omit<{
767
+ }, "group" | "title" | "icon" | "id" | "row">> & Omit<{
768
768
  id: string;
769
769
  icon: string;
770
770
  title: string;
@@ -778,7 +778,7 @@ declare function $$render<T>(): {
778
778
  row: T;
779
779
  rowIndex: number;
780
780
  }) => void | Promise<void>) | undefined;
781
- }, "title" | "group" | "icon" | "id" | "row">;
781
+ }, "group" | "title" | "icon" | "id" | "row">;
782
782
  rowIndex: number;
783
783
  row: T;
784
784
  }) => void) | undefined;
@@ -1,6 +1,5 @@
1
1
  <script lang="ts">
2
2
  import type {SlotType} from "../../types/index.js"
3
- import Button from "../Button.svelte"
4
3
  import Panel from "./Panel.svelte"
5
4
  import NavMenu from "../nav/NavMenu.svelte"
6
5
  import NavGroup from "../nav/NavGroup.svelte"
@@ -34,6 +33,8 @@
34
33
  drawerPinned?: boolean
35
34
  drawerWidth?: string
36
35
  height?: number
36
+ menuToggleSize?: number
37
+ menuToggleTemplate?: SlotType
37
38
  class?: string
38
39
  style?: string
39
40
  }
@@ -50,6 +51,8 @@
50
51
  drawerPinned = false,
51
52
  drawerWidth = "280px",
52
53
  height = 60,
54
+ menuToggleSize = 42,
55
+ menuToggleTemplate = undefined,
53
56
  class: className = "",
54
57
  style = ""
55
58
  }: Props = $props()
@@ -92,25 +95,29 @@
92
95
  class:topnav--force-collapse={collapse === "always"}
93
96
  class:topnav--force-expand={collapse === "never"}
94
97
  class:topnav--drawer-pinned={drawerPinned}
95
- style="height: {height}px; {style}"
98
+ style="height: {height}px; --topnav-toggle-size: {menuToggleSize}px; {style}"
96
99
  >
97
100
  <div class="topnav-container">
98
101
  {#if hasDrawerContent}
99
- <Button
100
- appearance="stealth"
101
- class="mobile-menu-toggle"
102
- onclick={toggleMobileMenu}
103
- aria-label={mobileMenuOpen ? "Close menu" : "Open menu"}
104
- aria-expanded={mobileMenuOpen}
105
- >
106
- <span class="hamburger-icon">
107
- {#if mobileMenuOpen}
108
- <DismissIcon size={20} />
109
- {:else}
110
-
111
- {/if}
112
- </span>
113
- </Button>
102
+ <div class="topnav-menu-toggle">
103
+ {#if menuToggleTemplate}
104
+ {@render menuToggleTemplate({open: mobileMenuOpen, toggle: toggleMobileMenu})}
105
+ {:else}
106
+ <button
107
+ type="button"
108
+ class="mobile-menu-toggle"
109
+ onclick={toggleMobileMenu}
110
+ aria-label={mobileMenuOpen ? "Close menu" : "Open menu"}
111
+ aria-expanded={mobileMenuOpen}
112
+ >
113
+ {#if mobileMenuOpen}
114
+ <DismissIcon size={Math.round(menuToggleSize * 0.48)} />
115
+ {:else}
116
+ <span class="hamburger-glyph">☰</span>
117
+ {/if}
118
+ </button>
119
+ {/if}
120
+ </div>
114
121
  {/if}
115
122
 
116
123
  {#if brandTemplate}
@@ -238,31 +245,46 @@
238
245
  flex-shrink: 0;
239
246
  }
240
247
 
241
- /* Mobile menu toggle button hidden by default, shown when container is narrow */
242
- :global(.topnav .mobile-menu-toggle) {
248
+ /* Wrapper slotowns visibility + position so a custom menuToggleTemplate
249
+ gets the same collapse behavior as the default button without consumers
250
+ needing to know about the internal rules. */
251
+ .topnav-menu-toggle {
243
252
  display: none;
244
253
  order: -1;
245
254
  flex-shrink: 0;
246
- width: 42px;
247
- min-width: 42px;
248
- height: 42px;
255
+ align-items: center;
249
256
  }
250
257
 
251
- /* Override fluent-button's internal control padding/min-height so the
252
- hamburger fills the fixed 42×42 box and the icon centers in it. */
253
- :global(.topnav .mobile-menu-toggle::part(control)) {
254
- width: 100%;
255
- height: 100%;
256
- min-width: 0;
257
- min-height: 0;
258
+ /* Default toggle plain icon target, no button chrome. Sized via
259
+ --topnav-toggle-size (set inline from the menuToggleSize prop).
260
+ Custom templates render at their natural size. */
261
+ .mobile-menu-toggle {
262
+ width: var(--topnav-toggle-size, 42px);
263
+ height: var(--topnav-toggle-size, 42px);
264
+ display: inline-flex;
265
+ align-items: center;
266
+ justify-content: center;
258
267
  padding: 0;
268
+ background: transparent;
269
+ border: none;
270
+ color: inherit;
271
+ cursor: pointer;
272
+ border-radius: var(--fluent-border-radius-md, 4px);
273
+ transition: opacity 0.15s, background-color 0.15s;
274
+ }
275
+
276
+ .mobile-menu-toggle:hover {
277
+ opacity: 0.7;
259
278
  }
260
279
 
261
- .hamburger-icon {
262
- font-size: 1.5rem;
280
+ .mobile-menu-toggle:focus-visible {
281
+ outline: 2px solid var(--accent-fill-rest, currentColor);
282
+ outline-offset: 2px;
283
+ }
284
+
285
+ .hamburger-glyph {
286
+ font-size: calc(var(--topnav-toggle-size, 42px) * 0.55);
263
287
  line-height: 1;
264
- display: flex;
265
- align-items: center;
266
288
  }
267
289
 
268
290
  /* Trailing flex group: items + divider + actions. `margin-left: auto`
@@ -343,7 +365,7 @@
343
365
  }
344
366
 
345
367
  @container topnav (max-width: 960px) {
346
- :global(.topnav .mobile-menu-toggle) {
368
+ .topnav-menu-toggle {
347
369
  display: flex;
348
370
  }
349
371
 
@@ -359,14 +381,14 @@
359
381
  }
360
382
  }
361
383
 
362
- /* collapse="always" — force hamburger visible + items hidden regardless of width */
363
- :global(.topnav.topnav--force-collapse .mobile-menu-toggle) {
384
+ /* collapse="always" — force toggle visible + items hidden regardless of width */
385
+ .topnav--force-collapse .topnav-menu-toggle {
364
386
  display: flex;
365
387
  }
366
388
 
367
- /* When drawer is pinned the hamburger acts as a show/hide toggle for the
389
+ /* When drawer is pinned the toggle acts as a show/hide control for the
368
390
  pinned rail itself, so it must stay visible at every width. */
369
- :global(.topnav.topnav--drawer-pinned .mobile-menu-toggle) {
391
+ .topnav--drawer-pinned .topnav-menu-toggle {
370
392
  display: flex;
371
393
  }
372
394
 
@@ -375,8 +397,8 @@
375
397
  display: none;
376
398
  }
377
399
 
378
- /* collapse="never" — force items/divider visible + hamburger hidden regardless of width */
379
- :global(.topnav.topnav--force-expand .mobile-menu-toggle) {
400
+ /* collapse="never" — force items/divider visible + toggle hidden regardless of width */
401
+ .topnav--force-expand .topnav-menu-toggle {
380
402
  display: none;
381
403
  }
382
404
 
@@ -26,6 +26,8 @@ type Props = {
26
26
  drawerPinned?: boolean;
27
27
  drawerWidth?: string;
28
28
  height?: number;
29
+ menuToggleSize?: number;
30
+ menuToggleTemplate?: SlotType;
29
31
  class?: string;
30
32
  style?: string;
31
33
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.3.1";
1
+ export declare const VERSION = "1.3.2";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Auto-generated by scripts/pre-package.js — do NOT edit by hand.
2
2
  // In dev this file holds whatever value was committed last; on each `npm run package`
3
3
  // the pre-package script overwrites it with the current package.json version.
4
- export const VERSION = "1.3.1";
4
+ export const VERSION = "1.3.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-fluentui",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "A Svelte wrapper library for Microsoft FluentUI web components",
5
5
  "license": "MIT",
6
6
  "author": "KeenMate",