3.0.1 • Published 1 year ago

svelte-hover-draw-svg v3.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

A lightweight Svelte component to draw SVG on hover.

REPL Commitizen friendly NPM version npm bundle size CI Release license


Features

  • 🤏 Lightweight: Wrapper component with only svelte as dev dependency
  • 😌 Straightforward: Just put your SVG or component with SVG under the component
  • 📦 Encapsulated: Expose hovering for extra hover effects & conditionals
  • 🛠 Customizable: CSS variable --duration to set the duration

Blog post @hashnode: Build a Svelte Component To Draw SVG On Hover

Install

npm install --save-dev svelte-hover-draw-svg

yarn add -D svelte-hover-draw-svg

pnpm add -D svelte-hover-draw-svg

Prerequisite:

SVG shape must have a stroke

<svg stroke="#000" stroke-width="2">
  <path />
</svg>

This library works better with "Outlined" SVGs.

Usage

  • Inline SVG:
<script>
  import HoverDrawSVG from 'svelte-hover-draw-svg';
</script>

<HoverDrawSVG>
  <svg>
    <path />
  </svg>
</HoverDrawSVG>
  • SVG Component (set draw time to 2s, default is 1s):
<script>
  import HoverDrawSVG from 'svelte-hover-draw-svg';
</script>

<HoverDrawSVG --duration="2">
  <SvgComponent />
</HoverDrawSVG>
  • Nested elements (expose hovering status):
<script>
  import HoverDrawSVG from 'svelte-hover-draw-svg';
</script>

<HoverDrawSVG let:hovering>
  <a href="/" class:hoverEffect={hovering}>
    <svg>
      <path />
    </svg>
  </a>
</HoverDrawSVG>
3.0.1

1 year ago

3.0.0

1 year ago

2.1.6

1 year ago

2.1.5

2 years ago

2.1.7

1 year ago

2.1.2

2 years ago

2.1.3

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago