@f-ewald/components 1.44.0 → 1.46.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"dag-layout.js","sourceRoot":"","sources":["../../src/utils/dag-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE/C,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,uDAAuD;AACvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,sCAAsC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,QAAQ,GAAG,GAAG,CAAC;AAQrB,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;AAqC7E,iEAAiE;AACjE,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,QAAgB,EAAE,OAAoB;IAC3E,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,OAAO,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,QAAQ;QAAE,GAAG,IAAI,CAAC,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IAAI,CAAC,MAAM,CAAE,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAE,CAAC,IAAI,CAAC;SAClF,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import { Graph, layout } from \"@dagrejs/dagre\";\n\n/** Height of every node card, in pixels. */\nexport const DAG_NODE_HEIGHT = 24;\n/** Space before a node's label: left padding, 14px icon, and gap. */\nexport const DAG_LABEL_OFFSET = 26;\n/** Space before a node's label when it has no icon. */\nexport const DAG_LABEL_OFFSET_PLAIN = 8;\nconst LABEL_PADDING_END = 10;\n/** Narrowest node card, in pixels. */\nexport const DAG_MIN_NODE_WIDTH = 48;\n/** Widest node card, in pixels; longer labels are shortened with an ellipsis. */\nexport const DAG_MAX_NODE_WIDTH = 200;\nconst RANK_GAP = 90;\nconst NODE_GAP = 6;\nconst ELLIPSIS = \"…\";\n\n/** Flow direction of the layers: left to right or top to bottom. */\nexport type DagDirection = \"LR\" | \"TB\";\n\n/** Returns the rendered width of a label in pixels. */\nexport type MeasureText = (text: string) => number;\n\n/** Width estimate used when the browser cannot measure text (no 2D canvas). */\nexport const approximateTextWidth: MeasureText = (text) => text.length * 6.2;\n\n/** A point in layout coordinates. */\nexport interface DagPoint {\n x: number;\n y: number;\n}\n\n/** One node to lay out. */\nexport interface DagLayoutInput {\n id: string;\n label: string;\n /** Whether the node shows an icon before its label. */\n hasIcon: boolean;\n}\n\n/** A positioned node: centered at `(x, y)` and sized to its (possibly shortened) label. */\nexport interface DagLayoutNode extends DagPoint {\n id: string;\n width: number;\n label: string;\n}\n\n/** A routed edge; `backward` edges run against the flow direction and close a cycle. */\nexport interface DagLayoutEdge {\n source: string;\n target: string;\n points: DagPoint[];\n backward: boolean;\n}\n\n/** Positioned nodes and routed edges, in input-independent order. */\nexport interface DagLayout {\n nodes: DagLayoutNode[];\n edges: DagLayoutEdge[];\n}\n\n/** Shortens `text` with an ellipsis until it fits `maxWidth`. */\nexport function fitLabel(text: string, maxWidth: number, measure: MeasureText): string {\n if (measure(text) <= maxWidth) return text;\n let end = text.length - 1;\n while (end > 1 && measure(text.slice(0, end) + ELLIPSIS) > maxWidth) end -= 1;\n return text.slice(0, end) + ELLIPSIS;\n}\n\nfunction nodeSize(node: DagLayoutInput, measure: MeasureText): { label: string; width: number } {\n const offset = node.hasIcon ? DAG_LABEL_OFFSET : DAG_LABEL_OFFSET_PLAIN;\n const label = fitLabel(node.label, DAG_MAX_NODE_WIDTH - offset - LABEL_PADDING_END, measure);\n const width = Math.ceil(offset + measure(label) + LABEL_PADDING_END);\n return { label, width: Math.min(DAG_MAX_NODE_WIDTH, Math.max(DAG_MIN_NODE_WIDTH, width)) };\n}\n\n/**\n * Lays out a directed graph in layers (Sugiyama-style, via dagre) so every edge points along `direction`.\n *\n * Cycles are broken only to assign layers: every edge is returned, and the ones that close a cycle are marked\n * `backward`. Edges whose endpoints are not both in `nodes`, self-edges, and duplicates are ignored. The result\n * does not depend on input order.\n */\nexport function layoutDag(\n nodes: DagLayoutInput[],\n edges: Array<{ source: string; target: string }>,\n direction: DagDirection = \"LR\",\n measure: MeasureText = approximateTextWidth,\n): DagLayout {\n if (nodes.length === 0) return { nodes: [], edges: [] };\n const graph = new Graph();\n graph.setGraph({\n rankdir: direction,\n ranksep: RANK_GAP,\n nodesep: NODE_GAP,\n edgesep: 4,\n marginx: 0,\n marginy: 0,\n });\n graph.setDefaultEdgeLabel(() => ({}));\n const sorted = [...nodes].sort((a, b) => a.id.localeCompare(b.id));\n const sizes = new Map(sorted.map((node) => [node.id, nodeSize(node, measure)]));\n for (const node of sorted) {\n graph.setNode(node.id, { width: sizes.get(node.id)!.width, height: DAG_NODE_HEIGHT });\n }\n const known = new Set(sizes.keys());\n const unique = new Map(\n edges\n .filter((edge) => known.has(edge.source) && known.has(edge.target) && edge.source !== edge.target)\n .map((edge) => [`${edge.source}\\u0000${edge.target}`, { source: edge.source, target: edge.target }]),\n );\n const kept = [...unique.values()].sort(\n (a, b) => a.source.localeCompare(b.source) || a.target.localeCompare(b.target),\n );\n for (const edge of kept) graph.setEdge(edge.source, edge.target);\n layout(graph);\n const positioned = new Map(\n sorted.map((node) => {\n const { x, y } = graph.node(node.id) as DagPoint;\n return [node.id, { id: node.id, x, y, ...sizes.get(node.id)! }];\n }),\n );\n const axis = direction === \"LR\" ? \"x\" : \"y\";\n return {\n nodes: [...positioned.values()],\n edges: kept.map((edge) => ({\n ...edge,\n points: (graph.edge(edge.source, edge.target).points as DagPoint[]).map(({ x, y }) => ({ x, y })),\n backward: positioned.get(edge.target)![axis] < positioned.get(edge.source)![axis],\n })),\n };\n}\n"]}
1
+ {"version":3,"file":"dag-layout.js","sourceRoot":"","sources":["../../src/utils/dag-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE/C,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,uDAAuD;AACvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,sCAAsC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AACtC,gDAAgD;AAChD,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,kEAAkE;AAClE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,sFAAsF;AACtF,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,QAAQ,GAAG,GAAG,CAAC;AAQrB,+EAA+E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AAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACnD,QAAQ,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAE,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAE,CAAC,IAAI,CAAC;gBACjF,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,CAAE,EAAE,CAAC,EAAE,MAAM,CAAC,CAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACtE,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { Graph, layout } from \"@dagrejs/dagre\";\n\n/** Height of every node card, in pixels. */\nexport const DAG_NODE_HEIGHT = 24;\n/** Space before a node's label: left padding, 14px icon, and gap. */\nexport const DAG_LABEL_OFFSET = 26;\n/** Space before a node's label when it has no icon. */\nexport const DAG_LABEL_OFFSET_PLAIN = 8;\nconst LABEL_PADDING_END = 10;\n/** Narrowest node card, in pixels. */\nexport const DAG_MIN_NODE_WIDTH = 48;\n/** Widest node card, in pixels; longer labels are shortened with an ellipsis. */\nexport const DAG_MAX_NODE_WIDTH = 200;\n/** Height of an edge label's box, in pixels. */\nexport const DAG_EDGE_LABEL_HEIGHT = 16;\n/** Space on each side of an edge label's text, inside its box. */\nexport const DAG_EDGE_LABEL_PADDING = 4;\n/** Widest edge label box, in pixels; longer labels are shortened with an ellipsis. */\nexport const DAG_MAX_EDGE_LABEL_WIDTH = 140;\nconst RANK_GAP = 90;\nconst NODE_GAP = 6;\nconst ELLIPSIS = \"…\";\n\n/** Flow direction of the layers: left to right or top to bottom. */\nexport type DagDirection = \"LR\" | \"TB\";\n\n/** Returns the rendered width of a label in pixels. */\nexport type MeasureText = (text: string) => number;\n\n/** Width estimate used when the browser cannot measure text (no 2D canvas). */\nexport const approximateTextWidth: MeasureText = (text) => text.length * 6.2;\n\n/** A point in layout coordinates. */\nexport interface DagPoint {\n x: number;\n y: number;\n}\n\n/** One node to lay out. */\nexport interface DagLayoutInput {\n id: string;\n label: string;\n /** Whether the node shows an icon before its label. */\n hasIcon: boolean;\n}\n\n/** A positioned node: centered at `(x, y)` and sized to its (possibly shortened) label. */\nexport interface DagLayoutNode extends DagPoint {\n id: string;\n width: number;\n label: string;\n}\n\n/** One edge to lay out; a `label` gets room of its own between the two nodes. */\nexport interface DagLayoutEdgeInput {\n source: string;\n target: string;\n label?: string;\n}\n\n/** A positioned edge label: its box is centered at `(x, y)` and sized to its (possibly shortened) text. */\nexport interface DagLayoutEdgeLabel extends DagPoint {\n text: string;\n width: number;\n}\n\n/** A routed edge; `backward` edges run against the flow direction and close a cycle. */\nexport interface DagLayoutEdge {\n source: string;\n target: string;\n points: DagPoint[];\n backward: boolean;\n /** Present when the input edge has a non-empty label. */\n label?: DagLayoutEdgeLabel;\n}\n\n/** Positioned nodes and routed edges, in input-independent order. */\nexport interface DagLayout {\n nodes: DagLayoutNode[];\n edges: DagLayoutEdge[];\n}\n\n/** Shortens `text` with an ellipsis until it fits `maxWidth`. */\nexport function fitLabel(text: string, maxWidth: number, measure: MeasureText): string {\n if (measure(text) <= maxWidth) return text;\n let end = text.length - 1;\n while (end > 1 && measure(text.slice(0, end) + ELLIPSIS) > maxWidth) end -= 1;\n return text.slice(0, end) + ELLIPSIS;\n}\n\nfunction nodeSize(node: DagLayoutInput, measure: MeasureText): { label: string; width: number } {\n const offset = node.hasIcon ? DAG_LABEL_OFFSET : DAG_LABEL_OFFSET_PLAIN;\n const label = fitLabel(node.label, DAG_MAX_NODE_WIDTH - offset - LABEL_PADDING_END, measure);\n const width = Math.ceil(offset + measure(label) + LABEL_PADDING_END);\n return { label, width: Math.min(DAG_MAX_NODE_WIDTH, Math.max(DAG_MIN_NODE_WIDTH, width)) };\n}\n\nfunction edgeLabelSize(text: string, measure: MeasureText): { text: string; width: number } {\n const fitted = fitLabel(text, DAG_MAX_EDGE_LABEL_WIDTH - 2 * DAG_EDGE_LABEL_PADDING, measure);\n return { text: fitted, width: Math.ceil(measure(fitted) + 2 * DAG_EDGE_LABEL_PADDING) };\n}\n\n/**\n * Lays out a directed graph in layers (Sugiyama-style, via dagre) so every edge points along `direction`.\n *\n * Cycles are broken only to assign layers: every edge is returned, and the ones that close a cycle are marked\n * `backward`. Edges whose endpoints are not both in `nodes`, self-edges, and duplicates are ignored (the last\n * duplicate wins). Labeled edges reserve room for their label midway along the edge. The result does not depend\n * on input order.\n */\nexport function layoutDag(\n nodes: DagLayoutInput[],\n edges: DagLayoutEdgeInput[],\n direction: DagDirection = \"LR\",\n measure: MeasureText = approximateTextWidth,\n): DagLayout {\n if (nodes.length === 0) return { nodes: [], edges: [] };\n const graph = new Graph();\n graph.setGraph({\n rankdir: direction,\n ranksep: RANK_GAP,\n nodesep: NODE_GAP,\n edgesep: 4,\n marginx: 0,\n marginy: 0,\n });\n graph.setDefaultEdgeLabel(() => ({}));\n const sorted = [...nodes].sort((a, b) => a.id.localeCompare(b.id));\n const sizes = new Map(sorted.map((node) => [node.id, nodeSize(node, measure)]));\n for (const node of sorted) {\n graph.setNode(node.id, { width: sizes.get(node.id)!.width, height: DAG_NODE_HEIGHT });\n }\n const known = new Set(sizes.keys());\n const unique = new Map(\n edges\n .filter((edge) => known.has(edge.source) && known.has(edge.target) && edge.source !== edge.target)\n .map((edge) => [`${edge.source}\\u0000${edge.target}`, edge]),\n );\n const kept = [...unique.values()].sort(\n (a, b) => a.source.localeCompare(b.source) || a.target.localeCompare(b.target),\n );\n const labels = new Map(\n kept\n .filter((edge) => edge.label)\n .map((edge) => [edge, edgeLabelSize(edge.label!, measure)]),\n );\n for (const edge of kept) {\n const label = labels.get(edge);\n graph.setEdge(\n edge.source,\n edge.target,\n label ? { width: label.width, height: DAG_EDGE_LABEL_HEIGHT, labelpos: \"c\" } : {},\n );\n }\n layout(graph);\n const positioned = new Map(\n sorted.map((node) => {\n const { x, y } = graph.node(node.id) as DagPoint;\n return [node.id, { id: node.id, x, y, ...sizes.get(node.id)! }];\n }),\n );\n const axis = direction === \"LR\" ? \"x\" : \"y\";\n return {\n nodes: [...positioned.values()],\n edges: kept.map((edge) => {\n const routed = graph.edge(edge.source, edge.target) as { points: DagPoint[]; x?: number; y?: number };\n const label = labels.get(edge);\n return {\n source: edge.source,\n target: edge.target,\n points: routed.points.map(({ x, y }) => ({ x, y })),\n backward: positioned.get(edge.target)![axis] < positioned.get(edge.source)![axis],\n ...(label ? { label: { ...label, x: routed.x!, y: routed.y! } } : {}),\n };\n }),\n };\n}\n"]}
package/docs/dag-graph.md CHANGED
@@ -10,6 +10,9 @@ Each node is a compact card sized to its label, with an optional icon, color, an
10
10
  focus on the graph, arrow keys pan, `+`/`-` zoom, and `0` fits the graph. Clicking a node, or pressing
11
11
  Enter/Space on it, selects it. A toolbar in the top-right corner offers the `controls` you enable.
12
12
 
13
+ Edges can carry an optional `label`, drawn midway along the edge, and an optional `weight`, which draws the
14
+ edge thicker in proportion to the heaviest weight in the graph.
15
+
13
16
  Set `static` to present a fixed picture: the graph is always fitted into view, panning and zooming
14
17
  are off, and the toolbar is hidden; nodes can still be selected.
15
18
 
@@ -41,8 +44,8 @@ import "@f-ewald/components/dag-graph.js";
41
44
  { id: "requests", label: "requests", kind: "package" },
42
45
  ];
43
46
  graph.edges = [
44
- { source: "web", target: "auth" },
45
- { source: "auth", target: "requests" },
47
+ { source: "web", target: "auth", weight: 42 },
48
+ { source: "auth", target: "requests", label: "^2.31", weight: 15 },
46
49
  ];
47
50
  graph.addEventListener("node-select", (e) => console.log(e.detail.id));
48
51
  </script>
@@ -70,9 +70,9 @@ defines the details used when creating or reviewing components.
70
70
  - Plain SVG presentation attributes may use literal token fallback values when
71
71
  CSS variables are not practical. User-provided marker/chart colors are an
72
72
  explicit exception.
73
- - White map rings, image-overlay controls, avatar foregrounds, and celebratory
74
- confetti may remain literal when their contrast is intentionally independent
75
- of the surrounding theme.
73
+ - White map rings, image-overlay controls, avatar foregrounds, celebratory
74
+ confetti, and `pixel-fire`'s retro fire palette may remain literal when their
75
+ contrast is intentionally independent of the surrounding theme.
76
76
  - There is no dedicated secondary accent color. `tab-bar`'s inactive-tab
77
77
  indicator reuses `--ui-border` (a shared line beneath the whole strip, with
78
78
  the active tab's `--ui-primary` line drawn on top of it) rather than
@@ -0,0 +1,51 @@
1
+ # `<pixel-fire>`
2
+
3
+ Pixelated, 8-bit style fire in the manner of old computer games. By default
4
+ it is pinned full width to the bottom of the viewport as a decorative,
5
+ click-through overlay; `contained` pins it to the bottom of the nearest
6
+ positioned ancestor instead.
7
+
8
+ The strip's height is set with `--pixel-fire-height` (default `8rem`). It
9
+ paints at `z-index: 30`, above ordinary page content but below `app-shell`'s
10
+ chrome and every dialog or popover. Under `prefers-reduced-motion: reduce`
11
+ it draws one still frame instead of animating. The canvas is hidden from
12
+ assistive technology.
13
+
14
+ ## Install
15
+
16
+ ```js
17
+ import "@f-ewald/components/pixel-fire.js";
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```html
23
+ <!-- Full width along the bottom of the viewport -->
24
+ <pixel-fire></pixel-fire>
25
+
26
+ <!-- Along the bottom of a positioned container, chunkier and lower -->
27
+ <div style="position: relative; height: 12rem">
28
+ <pixel-fire contained pixel-size="8" intensity="0.6"
29
+ style="--pixel-fire-height: 6rem"></pixel-fire>
30
+ </div>
31
+ ```
32
+
33
+ ## Attributes / properties
34
+
35
+ | Property | Attribute | Type | Default | Description |
36
+ | --- | --- | --- | --- | --- |
37
+ | `pixelSize` | `pixel-size` | `number` | `4` | Size of one fire pixel in CSS pixels; larger values look chunkier. |
38
+ | `intensity` | `intensity` | `number` | `1` | Heat of the fire's source, from `0` to `1`. Lowering it shortens the flames; `0` lets the fire burn out. |
39
+ | `contained` | `contained` | `boolean` | `false` | Pins the fire to the bottom of the nearest positioned ancestor instead of the viewport. |
40
+
41
+ ## Events
42
+
43
+ _None._
44
+
45
+ ## Slots
46
+
47
+ _None._
48
+
49
+ ## CSS custom properties
50
+
51
+ _None._
package/llms.txt CHANGED
@@ -976,6 +976,9 @@ Each node is a compact card sized to its label, with an optional icon, color, an
976
976
  focus on the graph, arrow keys pan, `+`/`-` zoom, and `0` fits the graph. Clicking a node, or pressing
977
977
  Enter/Space on it, selects it. A toolbar in the top-right corner offers the `controls` you enable.
978
978
 
979
+ Edges can carry an optional `label`, drawn midway along the edge, and an optional `weight`, which draws the
980
+ edge thicker in proportion to the heaviest weight in the graph.
981
+
979
982
  Set `static` to present a fixed picture: the graph is always fitted into view, panning and zooming
980
983
  are off, and the toolbar is hidden; nodes can still be selected.
981
984
 
@@ -1006,8 +1009,8 @@ Example:
1006
1009
  { id: "requests", label: "requests", kind: "package" },
1007
1010
  ];
1008
1011
  graph.edges = [
1009
- { source: "web", target: "auth" },
1010
- { source: "auth", target: "requests" },
1012
+ { source: "web", target: "auth", weight: 42 },
1013
+ { source: "auth", target: "requests", label: "^2.31", weight: 15 },
1011
1014
  ];
1012
1015
  graph.addEventListener("node-select", (e) => console.log(e.detail.id));
1013
1016
  </script>
@@ -2067,6 +2070,37 @@ Example:
2067
2070
  </script>
2068
2071
  ```
2069
2072
 
2073
+ ## <pixel-fire>
2074
+
2075
+ Pixelated, 8-bit style fire in the manner of old computer games. By default
2076
+ it is pinned full width to the bottom of the viewport as a decorative,
2077
+ click-through overlay; `contained` pins it to the bottom of the nearest
2078
+ positioned ancestor instead.
2079
+
2080
+ The strip's height is set with `--pixel-fire-height` (default `8rem`). It
2081
+ paints at `z-index: 30`, above ordinary page content but below `app-shell`'s
2082
+ chrome and every dialog or popover. Under `prefers-reduced-motion: reduce`
2083
+ it draws one still frame instead of animating. The canvas is hidden from
2084
+ assistive technology.
2085
+
2086
+ Import: `import "@f-ewald/components/pixel-fire.js";`
2087
+
2088
+ Properties: `pixelSize` (attribute `pixel-size`) : number, default 4; `intensity` (attribute `intensity`) : number, default 1; `contained` (attribute `contained`) : boolean, default false
2089
+ Events: none
2090
+ CSS custom properties: none
2091
+
2092
+ Example:
2093
+ ```html
2094
+ <!-- Full width along the bottom of the viewport -->
2095
+ <pixel-fire></pixel-fire>
2096
+
2097
+ <!-- Along the bottom of a positioned container, chunkier and lower -->
2098
+ <div style="position: relative; height: 12rem">
2099
+ <pixel-fire contained pixel-size="8" intensity="0.6"
2100
+ style="--pixel-fire-height: 6rem"></pixel-fire>
2101
+ </div>
2102
+ ```
2103
+
2070
2104
  ## <popover-panel>
2071
2105
 
2072
2106
  Generic anchored popover shell: a floating card positioned relative to its
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@f-ewald/components",
3
3
  "private": false,
4
- "version": "1.44.0",
4
+ "version": "1.46.0",
5
5
  "description": "A collection of universally usable web components for various tasks.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",