Coder Social home page Coder Social logo

arthurjamain / svelte-picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ramiroaisen/svelte-picker

0.0 1.0 0.0 3.76 MB

Svelte color picker (enhaced fork of svelte-color-picker)

License: MIT License

CSS 3.22% HTML 4.03% JavaScript 11.92% Svelte 80.83%

svelte-picker's Introduction

enhanced fork of svelte-color-picker

Svelte Picker [Demo Page]

svelte-v3

Installation

With npm

$ npm i svelte-picker

Usage

In your component :

<script>
import Picker from 'svelte-picker';
// To bind (not necessary)
let picker;

function handleChange(event){
	const {r, g, b, a, hex}  = event.detail;
	// Note that when you call setColor this will be called too
	// (should we change that?)
}

// You can change the color programatically too
onSomeEvent(() => {
	picker.setColor("#000"); // or
	picker.setColor("#000000"); // or
	picker.setColor({r:0, g:255, b:123});
})
</script>

<Picker
	bind:this={picker}
	class=""
	alpha={true}
	on:colorchange={handleChange}
	startColor={"#ff0000"}
/>
Props Value Type Use
class string="" class(es) to be added to the root element
alpha boolean=true wheather to show or not alpha picker
startColor string="#ff0000" Initial color (hexadecimal without alpha)
setColor function set the color of the picker from outside (whitout alpha for now)
on:colorchange callback Given callback gets called every time color changes

License

MIT

Contribute

git clone https://github.com/ramiroaisen/svelte-picker.git
npm i -D
npm run dev

opens a dev server

svelte-picker's People

Contributors

arthurjamain avatar ramiroaisen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.