Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Svelte Color Picker currently has one type of colorpicker.
| ------ | ------ | ------ |
| on:colorChange | function | Given function gets called every time color changes |
| startColor | string | Initializes color picker with the value (hexadecimal without alpha). |
| width | number | Changes the color picker's width `default: 240` |
| height | number | Changes the color picker's height `default: 265` |

License
----
Expand Down
18 changes: 11 additions & 7 deletions src/HsvPicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import {onMount,createEventDispatcher} from 'svelte';

export let startColor ="#FF0000";
export let width = 240;
export let height = 265;

onMount(() => {
document.addEventListener("mouseup", mouseUp);
Expand Down Expand Up @@ -393,8 +395,6 @@ function rgbToHSV(r, g, b, update) {

<style>
.main-container {
width: 240px;
height: 265px;
background: #f2f2f2;
border-radius: 1px;
-webkit-box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.51);
Expand All @@ -408,17 +408,21 @@ function rgbToHSV(r, g, b, update) {
user-select: none;
}

.colorsquare {
height: 60%;
}

.saturation-gradient {
background: linear-gradient(to right, rgb(255, 255, 255), rgba(255, 255, 255, 0));
width: 240px;
height: 160px;
width: 100%;
height: 100%;
}

.value-gradient {
background: linear-gradient(to top, rgb(0, 0, 0), rgba(0, 0, 0, 0));
overflow: hidden;
width: 240px;
height: 160px;
width: 100%;
height: 100%;
}

.hue-selector {
Expand Down Expand Up @@ -600,7 +604,7 @@ function rgbToHSV(r, g, b, update) {
}
</style>

<div class="main-container">
<div class="main-container" style={`width: ${width}px; height: ${height}px`}>

<div class="colorsquare size">
<div class="saturation-gradient">
Expand Down