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-skeleton

v1.3.1

Published

Simple implementation of SVG skeletons in Svelte 3

Downloads

2,742

Readme

svelte-skeleton

NPM version NPM downloads Svelte v3

Simple implementation of SVG skeletons in Svelte 3

example

:rocket: Features

This is Svelte's component to create custom SVG skeletons to improve level of UX of loading images and interface.

  • Easy to use (Svelte component allow to use any SVG forms, such as <rect /> and <circle />)
  • Fully customizable: you can adjust the colors, sizes and speed :t-rex:
  • Works fine with SSR
  • Light size :fire:
  • Pure SVG: any custom SVG shapes can be used
  • All backgrounds within one Svelte component will be synchronized

P.S. It's recommended to use this package only for middle or large images. If you want to achieve the best UX for icons, use this package with animate = false. Also you can use svelte-image-loader (NPM package) to smooth the moment the image appears.

Install

npm i svelte-skeleton

Usage

Please note that you should import .svelte file to compile it with your project's Svelte version (you can use compiled svelte-skeleton/index.js, but there could be errors with different versions of Svelte in your project and in this package)

<script>
  import Skeleton from 'svelte-skeleton/Skeleton.svelte'

  ...
</script>

<Skeleton height="360" width="360">
  <rect width="96" height="72" x="0" y="0" rx="12" ry="12" />
  <rect width="260" height="10" x="108" y="19" rx="5" ry="5" />
  <rect width="150" height="10" x="108" y="43" rx="5" ry="5" />

  <rect width="96" height="72" x="0" y="96" rx="12" ry="12" />
  <rect width="260" height="10" x="108" y="115" rx="5" ry="5" />
  <rect width="150" height="10" x="108" y="139" rx="5" ry="5" />

  <!-- Any custom SVG shapes -->
</Skeleton>

Also you can combine it with Svelte's {#await ...}:

{#await promise}
<!-- promise is pending -->
<Skeleton height="360" width="360">
  <rect width="96" height="72" x="0" y="0" rx="12" ry="12" />
  <rect width="260" height="10" x="108" y="19" rx="5" ry="5" />
  <rect width="150" height="10" x="108" y="43" rx="5" ry="5" />
</Skeleton>
{:then value}
<!-- promise was fulfilled -->
<YourCoolComponent {value} />
{:catch error}
<!-- promise was rejected -->
<Error title="{error.message}" />
{/await}

API

Parameters

| Name | Type | Default | Description | | -------------------------- | ------- | ----------- | ---------------------------------- | | primaryColor | string | '#ebecef' | Main background color | | secondaryColor | string | '#f5f5f7' | Animation line color | | height | number | 200 | | | width | number | 400 | | | speed | number | 2 | | | animate | boolean | true | | | secondaryColorPercentWidth | number | 100 | Initial secondaryColor-part offset | | ariaLabel | string | null | Aria Label |

Please note that some older browsers (like Internet Explorer 11) do not support SVG animations. They will only show the background color without the animation line. To create skeletons for these browsers, you need to write your own CSS animations.

License

MIT © Denis Stasyev