-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extends SVGAttributes<SVGElement>
- Loading branch information
Showing
337 changed files
with
15,120 additions
and
56,260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte-heros-v2': patch | ||
--- | ||
|
||
feat: extends SVGAttributes<SVGElement> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,221 +1,68 @@ | ||
<script lang="ts"> | ||
import { getContext } from 'svelte'; | ||
type TitleType = { | ||
id?: string; | ||
title?: string; | ||
}; | ||
type DescType = { | ||
id?: string; | ||
desc?: string; | ||
}; | ||
interface BaseProps { | ||
size?: string; | ||
role?: string; | ||
color?: string; | ||
variation?: 'solid' | 'outline' | 'mini' | 'micro'; | ||
strokeWidth?: string; | ||
withEvents?: boolean; | ||
onclick?: (event: MouseEvent) => void; | ||
onkeydown?: (event: KeyboardEvent) => void; | ||
onkeyup?: (event: KeyboardEvent) => void; | ||
class?: string; | ||
} | ||
interface CtxType extends BaseProps {} | ||
interface Props extends BaseProps { | ||
title?: TitleType; | ||
desc?: DescType; | ||
ariaLabel?: string; | ||
} | ||
import type { CtxType, Props } from './types' | ||
const ctx: CtxType = getContext('iconCtx') ?? {}; | ||
let { | ||
size = ctx.size || '24', | ||
role = ctx.role || 'img', | ||
color = ctx.color || 'currentColor', | ||
variation = ctx.variation || 'outline', | ||
let { | ||
size = ctx.size || '24', | ||
role = ctx.role || 'img', | ||
color = ctx.color || 'currentColor', | ||
variation = ctx.variation || "outline", | ||
strokeWidth = ctx.strokeWidth || '1.5', | ||
withEvents = ctx.withEvents || false, | ||
title, | ||
desc, | ||
class: classname, | ||
ariaLabel = 'archive box', | ||
onclick, | ||
onkeydown, | ||
onkeyup, | ||
...restProps | ||
title, | ||
desc, | ||
ariaLabel = "archive box", | ||
...restProps | ||
}: Props = $props(); | ||
let ariaDescribedby = `${title?.id || ''} ${desc?.id || ''}`; | ||
const hasDescription = $derived(!!(title?.id || desc?.id)); | ||
let viewBox: string = $state(''); | ||
let viewBox: string = $state(''); | ||
$effect(() => { | ||
if (variation === 'mini') { | ||
size = size || '20'; | ||
size = size || "20"; | ||
viewBox = '0 0 20 20'; | ||
} else if (variation === 'micro') { | ||
size = size || '16'; | ||
} else if (variation === 'micro'){ | ||
size = size || "16"; | ||
viewBox = '0 0 16 16'; | ||
} else { | ||
size = size || '24'; | ||
size = size || "24"; | ||
viewBox = '0 0 24 24'; | ||
} | ||
}); | ||
}) | ||
</script> | ||
|
||
{#if withEvents} | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...restProps} | ||
{role} | ||
width={size} | ||
height={size} | ||
class={classname} | ||
fill="none" | ||
aria-label={ariaLabel} | ||
aria-describedby={hasDescription ? ariaDescribedby : undefined} | ||
{viewBox} | ||
stroke-width={strokeWidth} | ||
{onclick} | ||
{onkeydown} | ||
{onkeyup} | ||
> | ||
{#if title?.id && title.title} | ||
<title id={title.id}>{title.title}</title> | ||
{/if} | ||
{#if desc?.id && desc.desc} | ||
<desc id={desc.id}>{desc.desc}</desc> | ||
{/if} | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...restProps} | ||
{role} | ||
width={size} | ||
height={size} | ||
fill="none" | ||
aria-label={ariaLabel} | ||
aria-describedby={hasDescription ? ariaDescribedby : undefined} | ||
{viewBox} | ||
stroke-width={strokeWidth} | ||
> | ||
{#if title?.id && title.title} | ||
<title id="{title.id}">{title.title}</title> | ||
{/if} | ||
{#if desc?.id && desc.desc} | ||
<desc id="{desc.id}">{desc.desc}</desc> | ||
{/if} | ||
{#if variation === 'outline'} | ||
<path | ||
d="M20.25 7.5L19.6246 18.1321C19.5546 19.3214 18.5698 20.25 17.3785 20.25H6.62154C5.43022 20.25 4.44538 19.3214 4.37542 18.1321L3.75 7.5M9.99976 11.25H13.9998M3.375 7.5H20.625C21.2463 7.5 21.75 6.99632 21.75 6.375V4.875C21.75 4.25368 21.2463 3.75 20.625 3.75H3.375C2.75368 3.75 2.25 4.25368 2.25 4.875V6.375C2.25 6.99632 2.75368 7.5 3.375 7.5Z" | ||
stroke={color} | ||
stroke-width={strokeWidth} | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
<path d="M20.25 7.5L19.6246 18.1321C19.5546 19.3214 18.5698 20.25 17.3785 20.25H6.62154C5.43022 20.25 4.44538 19.3214 4.37542 18.1321L3.75 7.5M9.99976 11.25H13.9998M3.375 7.5H20.625C21.2463 7.5 21.75 6.99632 21.75 6.375V4.875C21.75 4.25368 21.2463 3.75 20.625 3.75H3.375C2.75368 3.75 2.25 4.25368 2.25 4.875V6.375C2.25 6.99632 2.75368 7.5 3.375 7.5Z" stroke="{color}" stroke-width="{strokeWidth}" stroke-linecap="round" stroke-linejoin="round"/> | ||
{:else if variation === 'mini'} | ||
<path | ||
d="M2 3C1.44772 3 1 3.44772 1 4V5C1 5.55228 1.44772 6 2 6H18C18.5523 6 19 5.55228 19 5V4C19 3.44772 18.5523 3 18 3H2Z" | ||
fill={color} | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M2 7.5H18L17.1885 15.2094C17.0813 16.2273 16.223 17 15.1995 17H4.80052C3.77701 17 2.91866 16.2273 2.81151 15.2094L2 7.5ZM7 11C7 10.4477 7.44772 10 8 10H12C12.5523 10 13 10.4477 13 11C13 11.5523 12.5523 12 12 12H8C7.44772 12 7 11.5523 7 11Z" | ||
fill={color} | ||
/> | ||
<path d="M2 3C1.44772 3 1 3.44772 1 4V5C1 5.55228 1.44772 6 2 6H18C18.5523 6 19 5.55228 19 5V4C19 3.44772 18.5523 3 18 3H2Z" fill="{color}"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M2 7.5H18L17.1885 15.2094C17.0813 16.2273 16.223 17 15.1995 17H4.80052C3.77701 17 2.91866 16.2273 2.81151 15.2094L2 7.5ZM7 11C7 10.4477 7.44772 10 8 10H12C12.5523 10 13 10.4477 13 11C13 11.5523 12.5523 12 12 12H8C7.44772 12 7 11.5523 7 11Z" fill="{color}"/> | ||
{:else if variation === 'micro'} | ||
<path | ||
d="M3 2C2.44772 2 2 2.44772 2 3V4C2 4.55228 2.44772 5 3 5H13C13.5523 5 14 4.55228 14 4V3C14 2.44772 13.5523 2 13 2H3Z" | ||
fill={color} | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M3 6H13V12C13 13.1046 12.1046 14 11 14H5C3.89543 14 3 13.1046 3 12V6ZM6 8.75C6 8.33579 6.33579 8 6.75 8H9.25C9.66421 8 10 8.33579 10 8.75C10 9.16421 9.66421 9.5 9.25 9.5H6.75C6.33579 9.5 6 9.16421 6 8.75Z" | ||
fill={color} | ||
/> | ||
<path d="M3 2C2.44772 2 2 2.44772 2 3V4C2 4.55228 2.44772 5 3 5H13C13.5523 5 14 4.55228 14 4V3C14 2.44772 13.5523 2 13 2H3Z" fill="{color}"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 6H13V12C13 13.1046 12.1046 14 11 14H5C3.89543 14 3 13.1046 3 12V6ZM6 8.75C6 8.33579 6.33579 8 6.75 8H9.25C9.66421 8 10 8.33579 10 8.75C10 9.16421 9.66421 9.5 9.25 9.5H6.75C6.33579 9.5 6 9.16421 6 8.75Z" fill="{color}"/> | ||
{:else} | ||
<path | ||
d="M3.375 3C2.33947 3 1.5 3.83947 1.5 4.875V5.625C1.5 6.66053 2.33947 7.5 3.375 7.5H20.625C21.6605 7.5 22.5 6.66053 22.5 5.625V4.875C22.5 3.83947 21.6605 3 20.625 3H3.375Z" | ||
fill={color} | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M3.08679 9L3.62657 18.1762C3.71984 19.7619 5.03296 21 6.62139 21H17.3783C18.9667 21 20.2799 19.7619 20.3731 18.1762L20.9129 9H3.08679ZM9.24976 12.75C9.24976 12.3358 9.58554 12 9.99976 12H13.9998C14.414 12 14.7498 12.3358 14.7498 12.75C14.7498 13.1642 14.414 13.5 13.9998 13.5H9.99976C9.58554 13.5 9.24976 13.1642 9.24976 12.75Z" | ||
fill={color} | ||
/> | ||
{/if} | ||
</svg> | ||
{:else} | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...restProps} | ||
{role} | ||
width={size} | ||
height={size} | ||
class={classname} | ||
fill="none" | ||
aria-label={ariaLabel} | ||
aria-describedby={hasDescription ? ariaDescribedby : undefined} | ||
{viewBox} | ||
stroke-width={strokeWidth} | ||
> | ||
{#if title?.id && title.title} | ||
<title id={title.id}>{title.title}</title> | ||
<path d="M3.375 3C2.33947 3 1.5 3.83947 1.5 4.875V5.625C1.5 6.66053 2.33947 7.5 3.375 7.5H20.625C21.6605 7.5 22.5 6.66053 22.5 5.625V4.875C22.5 3.83947 21.6605 3 20.625 3H3.375Z" fill="{color}"/> <path fill-rule="evenodd" clip-rule="evenodd" d="M3.08679 9L3.62657 18.1762C3.71984 19.7619 5.03296 21 6.62139 21H17.3783C18.9667 21 20.2799 19.7619 20.3731 18.1762L20.9129 9H3.08679ZM9.24976 12.75C9.24976 12.3358 9.58554 12 9.99976 12H13.9998C14.414 12 14.7498 12.3358 14.7498 12.75C14.7498 13.1642 14.414 13.5 13.9998 13.5H9.99976C9.58554 13.5 9.24976 13.1642 9.24976 12.75Z" fill="{color}"/> | ||
{/if} | ||
{#if desc?.id && desc.desc} | ||
<desc id={desc.id}>{desc.desc}</desc> | ||
{/if} | ||
{#if variation === 'outline'} | ||
<path | ||
d="M20.25 7.5L19.6246 18.1321C19.5546 19.3214 18.5698 20.25 17.3785 20.25H6.62154C5.43022 20.25 4.44538 19.3214 4.37542 18.1321L3.75 7.5M9.99976 11.25H13.9998M3.375 7.5H20.625C21.2463 7.5 21.75 6.99632 21.75 6.375V4.875C21.75 4.25368 21.2463 3.75 20.625 3.75H3.375C2.75368 3.75 2.25 4.25368 2.25 4.875V6.375C2.25 6.99632 2.75368 7.5 3.375 7.5Z" | ||
stroke={color} | ||
stroke-width={strokeWidth} | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
{:else if variation === 'mini'} | ||
<path | ||
d="M2 3C1.44772 3 1 3.44772 1 4V5C1 5.55228 1.44772 6 2 6H18C18.5523 6 19 5.55228 19 5V4C19 3.44772 18.5523 3 18 3H2Z" | ||
fill={color} | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M2 7.5H18L17.1885 15.2094C17.0813 16.2273 16.223 17 15.1995 17H4.80052C3.77701 17 2.91866 16.2273 2.81151 15.2094L2 7.5ZM7 11C7 10.4477 7.44772 10 8 10H12C12.5523 10 13 10.4477 13 11C13 11.5523 12.5523 12 12 12H8C7.44772 12 7 11.5523 7 11Z" | ||
fill={color} | ||
/> | ||
{:else if variation === 'micro'} | ||
<path | ||
d="M3 2C2.44772 2 2 2.44772 2 3V4C2 4.55228 2.44772 5 3 5H13C13.5523 5 14 4.55228 14 4V3C14 2.44772 13.5523 2 13 2H3Z" | ||
fill={color} | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M3 6H13V12C13 13.1046 12.1046 14 11 14H5C3.89543 14 3 13.1046 3 12V6ZM6 8.75C6 8.33579 6.33579 8 6.75 8H9.25C9.66421 8 10 8.33579 10 8.75C10 9.16421 9.66421 9.5 9.25 9.5H6.75C6.33579 9.5 6 9.16421 6 8.75Z" | ||
fill={color} | ||
/> | ||
{:else} | ||
<path | ||
d="M3.375 3C2.33947 3 1.5 3.83947 1.5 4.875V5.625C1.5 6.66053 2.33947 7.5 3.375 7.5H20.625C21.6605 7.5 22.5 6.66053 22.5 5.625V4.875C22.5 3.83947 21.6605 3 20.625 3H3.375Z" | ||
fill={color} | ||
/> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M3.08679 9L3.62657 18.1762C3.71984 19.7619 5.03296 21 6.62139 21H17.3783C18.9667 21 20.2799 19.7619 20.3731 18.1762L20.9129 9H3.08679ZM9.24976 12.75C9.24976 12.3358 9.58554 12 9.99976 12H13.9998C14.414 12 14.7498 12.3358 14.7498 12.75C14.7498 13.1642 14.414 13.5 13.9998 13.5H9.99976C9.58554 13.5 9.24976 13.1642 9.24976 12.75Z" | ||
fill={color} | ||
/> | ||
{/if} | ||
</svg> | ||
{/if} | ||
</svg> | ||
|
||
|
||
|
||
<!-- | ||
@component | ||
[Go to docs](https://svelte-heros-v2.codewithshin.com/) | ||
## Props | ||
@prop size = ctx.size || '24' | ||
@prop role = ctx.role || 'img' | ||
@prop color = ctx.color || 'currentColor' | ||
@prop variation = ctx.variation || 'outline' | ||
@prop strokeWidth = ctx.strokeWidth || '1.5' | ||
@prop withEvents = ctx.withEvents || false | ||
@prop title | ||
@prop desc | ||
@prop class: classname | ||
@prop ariaLabel = 'archive box' | ||
@prop onclick | ||
@prop onkeydown | ||
@prop onkeyup | ||
@prop ...restProps | ||
--> |
Oops, something went wrong.