1.0.15 • Published 2 months ago

svelte-heart v1.0.15

Weekly downloads
-
License
LIL
Repository
github
Last release
2 months ago

A simple SVG icon that comes with an animation on the fly. Add a cool additive to the like buttons on your Svelte app.

How it works

Svelte Heart is basically an SVG icon component with the keyframe animation built in. This works by binding your like variable to bind:value. It detects the change, and triggers the heart animation when it changes to true.

Demo

HeartStarThumb

Installation

npm install svelte-heart

Usage

<script>
import { SvelteHeart } from 'svelte-heart'
let like = false
const likeEvent = () => { //this is where you set up an ajax call.
	like = like ? false : true
}
</script>
<button on:click="{likeEvent}">
	Like
	<SvelteHeart bind:value="{like}"/>
</button>

Props

PropTypeDefaultDescription
valuebooleanfalseThe component listens to the change of value. When it changes to true, the animation triggers.
colorLikedstring"#da3a09"The color when value is set to true
colorUnlikedstring"#222"The color when value is set to false
symbol"heart" ⎮ "star" ⎮ "thumb""heart"Accepts one out of three icon types. (heart, star, thumb)
sizenumber20This sets the size of the symbol as well as those in the animation.

Caution

There is no event dispatched from this component as its sole purpose is just an icon with an animation.

License

LIL License.

https://yongju.me

1.0.15

2 months ago

1.0.14

2 months ago

1.0.13

2 months ago

1.0.12

2 months ago

1.0.11

2 months ago

1.0.10

2 months ago

1.0.9

2 months ago

1.0.8

2 months ago

1.0.7

2 months ago

1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago