npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-svg-transform

v1.0.1

Published

<div align="center">

Downloads

114

Readme

🖍️svelte-svg-transform

Live Demo

A tiny library that makes it easier for you to add SVGs and tranform them in your svelte project. You won't need to rename your .svg files to .svelte and manually edit them. Independent from DOMParser, so it works just fine during server-side rendering.

release version weekly download count primary language procentage workflow build status last commit badge licence badge

Requirements

"vite": "^4.3.0",
"svelte": "^3.54.0",

Install

npm install svelte-svg-transform

Usage

  • Import in your component and pass it your SVG
  • Import your Icon's raw markup
  • Pass the icon to the component and transform it using props
// important! include the ?raw at the end of your SVG import
import MyIcon from '../path/to/icon.svg?raw';
// component is default exported so you can call it whatever you want!
import SvgTransform from 'svelte-svg-transform';

<span class="text-red-500">
	<SvgTransform
		svg={MyIcon}
		width={32}
		strokeWidth={3}
		stroke="currentColor"
	/>
</span>;
// => outputs a 32px x 32px INLINE svg
// => with 3px thick stroke of same color as parent's text

Props

The component exposes some props that make it easier to manipulate SVG type files. Make sure to pass your SVG's raw markup to the component like so:

import SvgIcon from 'svelte-svg-transform';
import MyIcon from '../path/to/icon.svg?raw';

<SvgIcon svg={MyIcon} />;

From there you can use these props on the component:

svg

Type: string (svg markup) Required

Accepts only raw svg markup that you want to transform.

width

Type: number Default: 20

Sets svg's width to desired pixels.

height

Type: number Default: Same as width

Sets svg's height to desired pixels, if not passed will use the same as width.

fill

Type: string

Override any hard-coded fill colors except none

stroke

Type: string

Override any hard-coded stroke colors except none

fillOpacity

Type: number Range: 0-1 Optional

Change svg's internal fill-opacity properties (except none) to any value you want.

strokeWidth

Type: number Optional

Change svg's internal stroke-width properties (except none) to any value you want.

strokeLineCap

Type: string Optional

Change svg's internal stroke-line-cap properties (except none) to any value you want.

strokeOpacity

Type: number Range: 0-1 Optional

Change svg's internal stroke-opacity properties (except none) to any value you want.

Licence

MIT