1
0
mirror of https://github.com/tabler/tabler-icons.git synced 2025-01-17 04:38:28 +01:00

Add <title> to <svg> in SolidJS (#1156)

Adds <title> child tag & title property in built package, but still doesn't show it on hover.

Co-authored-by: Bartłomiej Gawęda <bgaweda@abis.krakow.pl>
This commit is contained in:
BG-Software 2024-06-13 22:10:57 +02:00 committed by GitHub
parent c898ade0f0
commit b6591cec2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -10,13 +10,14 @@ const createSolidComponent = (
iconNode: IconNode, iconNode: IconNode,
) => { ) => {
const Component = (props: IconProps) => { const Component = (props: IconProps) => {
const [localProps, rest] = splitProps(props, ['color', 'size', 'stroke', 'children', 'class']), const [localProps, rest] = splitProps(props, ['color', 'size', 'stroke', 'title', 'children', 'class']),
attributes = defaultAttributes[type]; attributes = defaultAttributes[type];
const svgProps = { const svgProps = {
...attributes, ...attributes,
width: () => (localProps.size != null ? localProps.size : attributes.width), width: () => (localProps.size != null ? localProps.size : attributes.width),
height: () => (localProps.size != null ? localProps.size : attributes.height), height: () => (localProps.size != null ? localProps.size : attributes.height),
title: () => localProps.title != null ? localProps.title : undefined,
...(type === 'filled' ...(type === 'filled'
? { ? {
fill: () => (localProps.color != null ? localProps.color : 'currentColor'), fill: () => (localProps.color != null ? localProps.color : 'currentColor'),
@ -33,7 +34,11 @@ const createSolidComponent = (
return h( return h(
'svg', 'svg',
[svgProps, rest], [svgProps, rest],
[...iconNode.map(([tag, attrs]) => h(tag, attrs)), localProps.children], [
localProps.title && h('title', {}, localProps.title),
...iconNode.map(([tag, attrs]) => h(tag, attrs)),
localProps.children
],
); );
}; };

View File

@ -8,5 +8,6 @@ export interface IconProps extends SVGAttributes {
color?: string; color?: string;
size?: string | number; size?: string | number;
strokeWidth?: string | number; strokeWidth?: string | number;
title?: string;
class?: string; class?: string;
} }