-
Notifications
You must be signed in to change notification settings - Fork 0
/
standalone.html
75 lines (61 loc) · 1.61 KB
/
standalone.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>color picker demo</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/yet-another-color-picker@latest/dist/ColorPicker.css">
</head>
<body>
<form method="POST" enctype="multipart/form-data">
<fieldset>
<legend>Color</legend>
<div>
<label>
Name
<input name="name" type="text" required>
</label>
</div>
<div>
<label>
Description (optional)
<input name="description" type="text">
</label>
</div>
<div>
<label>
Value (native input)
<input name="value-native" type="color" value="#ff6600">
</label>
</div>
<div>
<label>
Value (custom element)
<color-picker name="value" value="#f60a" format="hex"></color-picker>
</label>
</div>
</fieldset>
<button type="reset">Reset</button>
<button>Submit</button>
</form>
<script type="importmap">
{
"imports": {
"lit-html": "https://cdn.jsdelivr.net/npm/lit-html@^3.0.0"
}
}
</script>
<script type="module">
import 'https://cdn.jsdelivr.net/npm/yet-another-color-picker@latest/dist/ColorPicker.js'
const colorPicker = document.querySelector('color-picker')
colorPicker.addEventListener('color-change', function (event) {
console.log(event.detail)
})
document.forms[0].addEventListener('submit', function (event) {
const formData = new FormData(event.target)
console.info('submit', JSON.stringify(Array.from(formData.entries()), null, 2))
event.preventDefault()
})
</script>
</body>
</html>