@solidrt/components 0.0.39 → 0.0.41

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 CHANGED
@@ -75,13 +75,14 @@ Most components group props into two objects, plus top-level event handlers:
75
75
  `moduleSize`/`margin`/`radius`/`level` (L/M/Q/H). Paints black-on-white by
76
76
  default (NOT the theme) to stay scannable; override `color`/`background` only
77
77
  if contrast holds. Deps on `qrcode-generator`.
78
- - `Icon` - thin themed wrapper over the core `<svg>` document primitive. `src`
79
- is an SVG string (an imported `.svg` asset, a `lucide-static` string export, or
80
- an inline literal); `size` sets a square box (default 24); `color` drives
81
- `currentColor` (default `theme.color.text`). Carries no icon set of its own and
82
- no icon-name registry: pass the SVG string in, so any currentColor set (Lucide,
83
- Feather, Heroicons) works and only used icons are bundled. Multi-color
84
- documents keep their own fills. Reach for `<svg>` directly for a non-square box.
78
+ - `Icon` - thin themed wrapper over the core `parseSvg` primitive (draws mapped
79
+ to `<d-path>` in a `viewBox`-fitted box). `src` is an SVG string (an imported
80
+ `.svg` asset, a `lucide-static` string export, or an inline literal); `size`
81
+ sets a square box (default 24); `color` drives `currentColor` (default
82
+ `theme.color.text`). Carries no icon set of its own and no icon-name registry:
83
+ pass the SVG string in, so any currentColor set (Lucide, Feather, Heroicons)
84
+ works and only used icons are bundled. Multi-color documents keep their own
85
+ fills. Reach for `parseSvg` directly for a non-square box.
85
86
  - `SafeArea` - pads children clear of system UI (notches, status bars); top and
86
87
  bottom on by default, pass `false`/a number per edge.
87
88
  - `theme` / `setTheme` / `darkTheme` / `lightTheme` - shared REACTIVE appearance
package/README.md CHANGED
@@ -598,7 +598,7 @@ import { QrCode } from "@solidrt/components"
598
598
 
599
599
  ### Icon
600
600
 
601
- A thin themed wrapper over the core `<svg>` primitive. `src` is a whole SVG document as a string; the component draws it in a square box and, for monochrome icons that stroke/fill with `currentColor`, recolors it from the theme. It carries no icon set and no name registry, so any `currentColor` SVG works (Lucide, Feather, Heroicons) and only the icons you import are bundled. Multi-color documents keep their own fills. For a non-square box, use `<svg>` directly.
601
+ A thin themed wrapper over the core `parseSvg` primitive. `src` is a whole SVG document as a string; the component parses it once (memoized), maps the draws to `<d-path>` in a square `viewBox`-fitted box and, for monochrome icons that stroke/fill with `currentColor`, recolors it from the theme. It carries no icon set and no name registry, so any `currentColor` SVG works (Lucide, Feather, Heroicons) and only the icons you import are bundled. Multi-color documents keep their own fills. For a non-square box, use `parseSvg` directly.
602
602
 
603
603
  Icons are just SVG strings. Import them as assets (`import House from "lucide-static/icons/house.svg"`, resolved to a string), pull them from a string export, or inline a literal:
604
604
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/components",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "license": "MIT",
5
5
  "author": "Antoine van Wel",
6
6
  "type": "module",
@@ -18,6 +18,6 @@
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@solidjs/signals": "2.0.0-beta.26",
21
- "@solidrt/core": "0.0.39"
21
+ "@solidrt/core": "0.0.41"
22
22
  }
23
23
  }
package/src/icon.tsx CHANGED
@@ -1,3 +1,4 @@
1
+ import { createMemo, parseSvg, For } from "@solidrt/core"
1
2
  import type { LayoutProps } from "@solidrt/core"
2
3
  import { theme } from "./theme"
3
4
 
@@ -16,22 +17,28 @@ export interface IconProps {
16
17
 
17
18
  const SIZE = 24
18
19
 
19
- // A themed wrapper over the core <svg> document primitive: a square box sized to
20
- // `size` and colored from the theme by default. This is the only value it adds
21
- // over `<svg src>` directly, so reach for the primitive when you need a
22
- // non-square box or want no theme coupling.
20
+ // A themed wrapper over parseSvg: the document parsed once per src/color (a
21
+ // memo), its draws mapped to <d-path> in a square viewBox-fitted box colored
22
+ // from the theme by default. That is the only value it adds, so reach for
23
+ // parseSvg plus your own <view viewBox> when you need a non-square box or
24
+ // want no theme coupling. The plain repaintBoundary keeps the static subtree
25
+ // from re-recording alongside animating siblings; pointerEvents="all" makes
26
+ // the box one hit unit (and skips per-path outline tests) - an icon's shapes
27
+ // are never individual targets.
23
28
  export function Icon(props: IconProps) {
24
29
  let size = () => props.size ?? SIZE
30
+ let doc = createMemo(() => parseSvg(props.src, { color: props.color ?? theme.color.text }))
25
31
 
26
32
  return (
27
- <view repaintBoundary>
28
- <svg
29
- width={size()}
30
- height={size()}
31
- src={props.src}
32
- color={props.color ?? theme.color.text}
33
- {...props.layout}
34
- />
33
+ <view
34
+ repaintBoundary
35
+ pointerEvents="all"
36
+ width={size()}
37
+ height={size()}
38
+ viewBox={[doc().width, doc().height]}
39
+ {...props.layout}
40
+ >
41
+ <For each={doc().draws}>{(draw) => <d-path {...draw} />}</For>
35
42
  </view>
36
43
  )
37
44
  }