@hyvor/design 0.0.49 → 0.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,16 @@
1
- <script>export let color = "#000000";
1
+ <script>import ColorPicker from "svelte-awesome-color-picker";
2
+ import { clickOutside } from "../index.js";
3
+ import { createEventDispatcher } from "svelte";
4
+ export let color = "#000000";
2
5
  export let size = 30;
3
- let inputEl;
4
- function handleClick() {
5
- inputEl.click();
6
+ let show = false;
7
+ const dispatch = createEventDispatcher();
8
+ function handleInput() {
9
+ dispatch("input", color);
10
+ }
11
+ function handleClose() {
12
+ dispatch("change", color);
13
+ show = false;
6
14
  }
7
15
  </script>
8
16
 
@@ -11,9 +19,29 @@ function handleClick() {
11
19
  style:width="{size}px"
12
20
  style:height="{size}px"
13
21
  style:background-color={color}
14
- on:click={handleClick}
22
+ on:click={() => show = true}
15
23
  ></button>
16
24
 
25
+ {#if show}
26
+ <div
27
+ use:clickOutside={{
28
+ callback: () => handleClose(),
29
+ }}
30
+ >
31
+ <ColorPicker
32
+ bind:hex={color}
33
+ --input-size={size + 'px'}
34
+ isDialog={false}
35
+ isAlpha={false}
36
+ on:input={handleInput}
37
+ />
38
+ </div>
39
+ {/if}
40
+ </span>
41
+
42
+ <!-- <span>
43
+
44
+
17
45
  <input
18
46
  type="color"
19
47
  bind:value={color}
@@ -22,7 +50,7 @@ function handleClick() {
22
50
  on:change
23
51
  on:input
24
52
  />
25
- </span>
53
+ </span> -->
26
54
 
27
55
  <style>
28
56
  span {
@@ -31,12 +59,10 @@ function handleClick() {
31
59
  button {
32
60
  border-radius: 50%;
33
61
  }
34
- input {
62
+ div {
35
63
  position: absolute;
36
- left: 100%;
37
- bottom: 50%;
38
- transform: translate(0, 50%);
64
+ left: 0;
65
+ top: 100%;
39
66
  width: 0;
40
- opacity: 0;
41
67
  }
42
68
  </style>
@@ -5,8 +5,8 @@ declare const __propDef: {
5
5
  size?: number | undefined;
6
6
  };
7
7
  events: {
8
- change: Event;
9
- input: Event;
8
+ input: CustomEvent<string>;
9
+ change: CustomEvent<string>;
10
10
  } & {
11
11
  [evt: string]: CustomEvent<any>;
12
12
  };
@@ -8,6 +8,7 @@ let open = false;
8
8
  </script>
9
9
 
10
10
  <div class="wrap">
11
+ <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
11
12
  <img
12
13
  {src}
13
14
  {alt}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyvor/design",
3
- "version": "0.0.49",
3
+ "version": "0.0.50",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "scripts": {
@@ -38,6 +38,7 @@
38
38
  "@sveltejs/vite-plugin-svelte": "^3.0.0",
39
39
  "publint": "^0.1.9",
40
40
  "svelte": "^4.0.5",
41
+ "svelte-awesome-color-picker": "^3.0.4",
41
42
  "svelte-check": "^3.4.3",
42
43
  "tslib": "^2.4.1",
43
44
  "typescript": "^5.0.0",