fluentui-astro-icons 1.1.339

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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 1.1.339
4
+
5
+ - Initial release of Fluent System Icons as static Astro `<svg>` markup.
6
+ - Version matches `fluentui-web-icons` 1.1.339. Later icon updates keep that same versioning.
7
+ - No client JavaScript; families load on the server during SSG or Node SSR.
package/Icon.astro ADDED
@@ -0,0 +1,20 @@
1
+ ---
2
+ import type { IconName, IconVariant } from 'fluentui-web-icons';
3
+ import { renderIcon } from './src/render.ts';
4
+
5
+ interface Props {
6
+ name: IconName;
7
+ variant?: IconVariant;
8
+ size?: number;
9
+ label?: string;
10
+ flipRtl?: boolean;
11
+ }
12
+
13
+ const html = await renderIcon(Astro.props);
14
+ ---
15
+ <Fragment set:html={html} />
16
+ <style is:global>
17
+ svg.fluent-icon[flip-rtl]:dir(rtl) {
18
+ transform: scaleX(-1);
19
+ }
20
+ </style>
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fluentui-astro-icons contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # fluentui-astro-icons
2
+
3
+ Microsoft's Fluent System Icons as real `<svg>` in Astro HTML. No client
4
+ JavaScript, custom elements, or Shadow DOM.
5
+
6
+ This is an independent wrapper, not an official Microsoft package. The artwork
7
+ is from [Fluent System Icons](https://github.com/microsoft/fluentui-system-icons),
8
+ served through [fluentui-web-icons](https://www.npmjs.com/package/fluentui-web-icons)
9
+ `1.1.339`. Family data is imported on the server; the page gets markup.
10
+
11
+ [![npm](https://img.shields.io/npm/v/fluentui-astro-icons.svg)](https://www.npmjs.com/package/fluentui-astro-icons)
12
+ [![license](https://img.shields.io/npm/l/fluentui-astro-icons.svg)](LICENSE)
13
+
14
+ Demo: [l5z12.github.io/fluentui-astro-icons](https://l5z12.github.io/fluentui-astro-icons/)
15
+
16
+ The web-component sibling is [fluentui-web-icons](https://github.com/l5z12/fluentui-web-icons)
17
+ ([explorer](https://icons.l5z12.dev)). Use that when you want `<fluent-icon>` in
18
+ the browser. Use this package when Astro should bake SVG into the HTML.
19
+
20
+ ## Install
21
+
22
+ ```sh
23
+ npm install fluentui-astro-icons
24
+ ```
25
+
26
+ Also works with `pnpm add`, `yarn add`, and `bun add`. Peer: Astro 4 or later.
27
+ Designed for static builds and Node SSR.
28
+
29
+ ## Quick start
30
+
31
+ ```astro
32
+ ---
33
+ import Icon from 'fluentui-astro-icons';
34
+ ---
35
+ <Icon name="home" />
36
+ <Icon name="mail" variant="color" size={32} label="Inbox" />
37
+ <Icon name="arrow-left" flipRtl />
38
+ ```
39
+
40
+ Do **not** add `client:*` to this component. It loads families with Node APIs
41
+ and must stay on the server. Unknown or invalid names throw at build time.
42
+
43
+ Each family is one module (`home` never loads `mail`). Markup is an `<svg>`
44
+ element: `viewBox`, paths, and color trees (gradients, filters, clipping) match
45
+ `fluentui-web-icons`. Repeated color icons get unique ID prefixes so paint
46
+ servers do not clash.
47
+
48
+ ### Markup helper
49
+
50
+ ```ts
51
+ import { renderIcon } from 'fluentui-astro-icons/render';
52
+
53
+ const html = await renderIcon({ name: 'home', size: 24, label: 'Home' });
54
+ ```
55
+
56
+ If you use `flipRtl` with the helper, include the same CSS `Icon.astro` emits:
57
+
58
+ ```css
59
+ svg.fluent-icon[flip-rtl]:dir(rtl) {
60
+ transform: scaleX(-1);
61
+ }
62
+ ```
63
+
64
+ ## Component API
65
+
66
+ | Prop | Default | Behavior |
67
+ | --- | --- | --- |
68
+ | `name` | required | Kebab-case family; upstream underscores also work. |
69
+ | `variant` | `regular` | `regular`, `filled`, or `color`; invalid values use regular. |
70
+ | `size` | `undefined` | Positive pixel size; omission/invalid values use `1em`. |
71
+ | `label` | `''` | Accessible name; omit for decorative icons. |
72
+ | `flipRtl` | `false` | Mirrors when inherited direction is RTL, via CSS `:dir(rtl)`. |
73
+
74
+ The optical design defaults to 24. An explicit size selects the nearest
75
+ available design in that variant; ties prefer the larger design. Missing
76
+ variants fall back to regular, then filled, then color. Original SVG view
77
+ boxes are kept.
78
+
79
+ ### Styling and accessibility
80
+
81
+ ```css
82
+ .fluent-icon {
83
+ color: rebeccapurple;
84
+ --fluent-icon-size: 1.5rem;
85
+ }
86
+ ```
87
+
88
+ `--fluent-icon-size` overrides visual size only; use the `size` prop to choose
89
+ the optical design. Monochrome paths inherit `currentColor`. The `color`
90
+ variant keeps its original palette.
91
+
92
+ Give meaningful standalone icons a `label`. For icon-only buttons, label the
93
+ **button** and leave the icon decorative:
94
+
95
+ ```astro
96
+ <button aria-label="Open inbox">
97
+ <Icon name="mail" size={20} />
98
+ </button>
99
+ ```
100
+
101
+ Mirroring is opt-in. Some upstream icons have distinct RTL artwork; use those
102
+ named families instead of flipping them.
103
+
104
+ ## Playground
105
+
106
+ ```sh
107
+ bun install
108
+ bun run dev
109
+ ```
110
+
111
+ Pushing `main` publishes that playground to
112
+ [GitHub Pages](https://l5z12.github.io/fluentui-astro-icons/).
113
+
114
+ ```sh
115
+ bun run check
116
+ bun run verify:package
117
+ ```
118
+
119
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for pull requests and [SECURITY.md](SECURITY.md)
120
+ for vulnerability reports.
121
+
122
+ ## Release
123
+
124
+ The first npm version has to be published from a maintainer machine. npm
125
+ cannot attach [trusted publishers](https://docs.npmjs.com/trusted-publishers/)
126
+ until the package exists.
127
+
128
+ ```sh
129
+ npm login
130
+ bun run verify:package
131
+ bun run release:first
132
+ ```
133
+
134
+ Then add trusted publishers on npm for this repository and both `publish.yml`
135
+ and `sync-icons.yml`. Provenance needs a public GitHub repository. After that,
136
+ later versions publish from GitHub Actions.
137
+
138
+ This package's version **matches `fluentui-web-icons`**. Every six hours,
139
+ `.github/workflows/sync-icons.yml` checks npm, updates when that package
140
+ publishes, tags `v{version}`, and publishes — only once this package is already
141
+ on the registry.
142
+
143
+ ```sh
144
+ git tag v1.1.339
145
+ git push origin v1.1.339
146
+ ```
147
+
148
+ ## License
149
+
150
+ MIT for the wrapper and Microsoft artwork. See [LICENSE](LICENSE) and
151
+ [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,32 @@
1
+ # Fluent UI System Icons
2
+
3
+ The generated icon artwork comes from Microsoft's `@fluentui/svg-icons` package
4
+ via `fluentui-web-icons` 1.1.339.
5
+ Source: https://github.com/microsoft/fluentui-system-icons
6
+ Upstream license: https://github.com/microsoft/fluentui-system-icons/blob/main/LICENSE
7
+
8
+ The exact upstream package version is recorded in `bun.lock` as the
9
+ `fluentui-web-icons` dependency. This independent wrapper is not an official
10
+ Microsoft package.
11
+
12
+ MIT License
13
+
14
+ Copyright (c) 2020 Microsoft Corporation
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all
24
+ copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "fluentui-astro-icons",
3
+ "version": "1.1.339",
4
+ "description": "Fluent System Icons for Astro as inline SVG from SSG/SSR. Zero client JavaScript.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "L5Z12 as well as fluentui-astro-icons contributors",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/l5z12/fluentui-astro-icons.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/l5z12/fluentui-astro-icons/issues"
14
+ },
15
+ "homepage": "https://l5z12.github.io/fluentui-astro-icons/",
16
+ "packageManager": "bun@1.3.14",
17
+ "engines": {
18
+ "node": ">=18.17"
19
+ },
20
+ "exports": {
21
+ ".": "./Icon.astro",
22
+ "./render": {
23
+ "types": "./src/render.ts",
24
+ "import": "./src/render.ts",
25
+ "default": "./src/render.ts"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "CHANGELOG.md",
31
+ "Icon.astro",
32
+ "LICENSE",
33
+ "README.md",
34
+ "THIRD_PARTY_NOTICES.md",
35
+ "src"
36
+ ],
37
+ "sideEffects": false,
38
+ "publishConfig": {
39
+ "access": "public",
40
+ "registry": "https://registry.npmjs.org/"
41
+ },
42
+ "scripts": {
43
+ "dev": "astro dev --root playground",
44
+ "build": "astro build --root playground",
45
+ "preview": "astro preview --root playground",
46
+ "test": "bun test tests",
47
+ "typecheck": "tsc --noEmit",
48
+ "check": "bun run typecheck && bun run test && bun run build",
49
+ "verify:package": "bun scripts/verify-package.ts",
50
+ "release:first": "bun scripts/publish-first.ts",
51
+ "icons:check": "bun scripts/check-upstream.ts"
52
+ },
53
+ "dependencies": {
54
+ "fluentui-web-icons": "1.1.339"
55
+ },
56
+ "peerDependencies": {
57
+ "astro": ">=4"
58
+ },
59
+ "devDependencies": {
60
+ "@types/bun": "1.4.2",
61
+ "astro": "7.3.1",
62
+ "publint": "0.3.24",
63
+ "typescript": "5.9.2"
64
+ },
65
+ "keywords": [
66
+ "astro",
67
+ "astro-component",
68
+ "withastro",
69
+ "fluentui",
70
+ "fluent-system-icons",
71
+ "icons",
72
+ "svg",
73
+ "ssg",
74
+ "ssr"
75
+ ]
76
+ }
package/src/load.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { createRequire } from 'node:module';
2
+ import { basename, dirname, join } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { normalizeIconName } from 'fluentui-web-icons';
5
+ import type { IconDefinition } from 'fluentui-web-icons';
6
+
7
+ const require = createRequire(import.meta.url);
8
+ const iconNamePattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
9
+ const loaded = new Map<string, Promise<IconDefinition>>();
10
+
11
+ function iconsDirectory(): string {
12
+ return join(dirname(require.resolve('fluentui-web-icons/package.json')), 'dist', 'generated', 'icons');
13
+ }
14
+
15
+ function iconFile(name: string): string {
16
+ const file = join(iconsDirectory(), `${name}.js`);
17
+ if (basename(file, '.js') !== name) throw new Error(`Unknown Fluent icon: ${name}`);
18
+ return file;
19
+ }
20
+
21
+ async function importIcon(name: string): Promise<IconDefinition> {
22
+ try {
23
+ const href = pathToFileURL(iconFile(name)).href;
24
+ const module = await import(/* @vite-ignore */ href) as { default?: IconDefinition };
25
+ const definition = module.default;
26
+ if (!definition || normalizeIconName(definition.name) !== name) {
27
+ throw new Error(`Unknown Fluent icon: ${name}`);
28
+ }
29
+ return definition;
30
+ } catch (error) {
31
+ if (error instanceof Error && error.message.startsWith('Unknown Fluent icon:')) throw error;
32
+ throw new Error(`Unknown Fluent icon: ${name}`);
33
+ }
34
+ }
35
+
36
+ /** Load one published family module. Invalid names throw; failed loads are retryable. */
37
+ export function loadIconDefinition(name: string): Promise<IconDefinition> {
38
+ const id = normalizeIconName(name);
39
+ if (!iconNamePattern.test(id)) throw new Error(`Unknown Fluent icon: ${name}`);
40
+ let pending = loaded.get(id);
41
+ if (!pending) {
42
+ pending = importIcon(id);
43
+ loaded.set(id, pending);
44
+ pending.catch(() => {
45
+ if (loaded.get(id) === pending) loaded.delete(id);
46
+ });
47
+ }
48
+ return pending;
49
+ }
package/src/render.ts ADDED
@@ -0,0 +1,36 @@
1
+ import { normalizeIconName, selectGlyph } from 'fluentui-web-icons';
2
+ import type { IconDefinition, IconGlyph, IconName, IconSvgNode, IconVariant } from 'fluentui-web-icons';
3
+ import { loadIconDefinition } from './load.ts';
4
+ import { serializeGlyph } from './serialize.ts';
5
+
6
+ export { normalizeIconName, selectGlyph } from 'fluentui-web-icons';
7
+ export { flipRtlCss } from './serialize.ts';
8
+ export type { IconDefinition, IconGlyph, IconName, IconSvgNode, IconVariant };
9
+
10
+ export interface RenderIconOptions {
11
+ name: string;
12
+ variant?: IconVariant | string;
13
+ size?: number | string;
14
+ label?: string;
15
+ flipRtl?: boolean;
16
+ }
17
+
18
+ function resolveSize(value: number | string | undefined): number | undefined {
19
+ const size = typeof value === 'number' ? value : Number(value);
20
+ return Number.isFinite(size) && size > 0 ? size : undefined;
21
+ }
22
+
23
+ function resolveVariant(value: IconVariant | string | undefined): IconVariant {
24
+ return value === 'filled' || value === 'color' ? value : 'regular';
25
+ }
26
+
27
+ /** Server-side SVG markup for one Fluent System Icon. Unknown names throw. */
28
+ export async function renderIcon(options: RenderIconOptions): Promise<string> {
29
+ const name = normalizeIconName(String(options.name ?? ''));
30
+ if (!name) throw new Error(`Unknown Fluent icon: ${String(options.name ?? '')}`);
31
+ const definition = await loadIconDefinition(name);
32
+ const size = resolveSize(options.size);
33
+ const glyph = selectGlyph(definition, size ?? 24, resolveVariant(options.variant));
34
+ if (!glyph) throw new Error(`No glyph available for ${name}`);
35
+ return serializeGlyph(glyph, { label: options.label, size, flipRtl: Boolean(options.flipRtl) });
36
+ }
@@ -0,0 +1,76 @@
1
+ import type { IconGlyph, IconPath, IconSvgNode } from 'fluentui-web-icons';
2
+
3
+ const referencePattern = /^url\(#([\w-]+)\)$/;
4
+ let svgInstance = 0;
5
+
6
+ function escapeAttr(value: string): string {
7
+ return value.replaceAll('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
8
+ }
9
+
10
+ function serializeNodes(nodes: readonly IconSvgNode[], prefix: string): string {
11
+ let html = '';
12
+ for (const node of nodes) {
13
+ let attrs = '';
14
+ for (const [key, value] of Object.entries(node.attributes)) {
15
+ const resolved = key === 'id' ? prefix + value : value.replace(referencePattern, `url(#${prefix}$1)`);
16
+ attrs += ` ${key}="${escapeAttr(resolved)}"`;
17
+ }
18
+ const children = node.children?.length ? serializeNodes(node.children, prefix) : '';
19
+ html += `<${node.tag}${attrs}>${children}</${node.tag}>`;
20
+ }
21
+ return html;
22
+ }
23
+
24
+ function serializePaths(paths: readonly IconPath[]): string {
25
+ let html = '';
26
+ for (const data of paths) {
27
+ let attrs = ` d="${escapeAttr(data.d)}"`;
28
+ if (data.fillRule) attrs += ` fill-rule="${escapeAttr(data.fillRule)}"`;
29
+ if (data.clipRule) attrs += ` clip-rule="${escapeAttr(data.clipRule)}"`;
30
+ if (data.opacity !== undefined) attrs += ` opacity="${escapeAttr(String(data.opacity))}"`;
31
+ if (data.fill !== undefined) attrs += ` fill="${escapeAttr(data.fill)}"`;
32
+ if (data.stroke !== undefined) attrs += ` stroke="${escapeAttr(data.stroke)}"`;
33
+ html += `<path${attrs}></path>`;
34
+ }
35
+ return html;
36
+ }
37
+
38
+ export interface SerializeGlyphOptions {
39
+ label?: string;
40
+ size?: number;
41
+ flipRtl?: boolean;
42
+ }
43
+
44
+ /** Serialize a glyph to an inline SVG string. IDs are unique per call. */
45
+ export function serializeGlyph(glyph: IconGlyph, options: SerializeGlyphOptions = {}): string {
46
+ const prefix = `fi${++svgInstance}-`;
47
+ const viewBox = glyph.viewBox?.join(' ') ?? `0 0 ${glyph.size} ${glyph.size}`;
48
+ const label = options.label?.trim() ?? '';
49
+ const style = [
50
+ options.size !== undefined ? `--_fluent-icon-size:${options.size}px` : undefined,
51
+ 'display:inline-flex',
52
+ 'flex:none',
53
+ 'width:var(--fluent-icon-size,var(--_fluent-icon-size,1em))',
54
+ 'height:var(--fluent-icon-size,var(--_fluent-icon-size,1em))',
55
+ 'vertical-align:-0.125em',
56
+ 'overflow:hidden',
57
+ 'color:inherit',
58
+ glyph.fill !== undefined ? `fill:${glyph.fill}` : 'fill:currentColor',
59
+ ].filter((part): part is string => part !== undefined).join(';');
60
+
61
+ const attrs = [
62
+ 'class="fluent-icon"',
63
+ `viewBox="${escapeAttr(viewBox)}"`,
64
+ 'focusable="false"',
65
+ label
66
+ ? `role="img" aria-label="${escapeAttr(label)}"`
67
+ : 'aria-hidden="true"',
68
+ options.flipRtl ? 'flip-rtl' : undefined,
69
+ `style="${escapeAttr(style)}"`,
70
+ ].filter((part): part is string => part !== undefined);
71
+
72
+ return `<svg ${attrs.join(' ')}>${serializePaths(glyph.paths)}${glyph.nodes ? serializeNodes(glyph.nodes, prefix) : ''}</svg>`;
73
+ }
74
+
75
+ /** CSS used by Icon.astro so flipRtl mirrors under inherited RTL without JavaScript. */
76
+ export const flipRtlCss = 'svg.fluent-icon[flip-rtl]:dir(rtl){transform:scaleX(-1)}';