-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathcolor-palette.riot
65 lines (58 loc) · 1.24 KB
/
color-palette.riot
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
<color-palette>
<div
each={ color in state.colors }
style="background: { color }"
class={ color === props.value ? 'selected' : '' }
onclick={ () => onClick(color) }/>
<script>
export default {
state: {
colors: [
'#edc951',
'#eb6841',
'#cc2a36',
'#4f372d',
'#00a0b0'
],
},
onBeforeMount(props) {
this.root.value = props.value
},
onClick(color) {
this.root.value = color
this.root.dispatchEvent(new Event('change'))
}
}
</script>
<style>
:host {
display: inline-block;
padding: .5em;
line-height: 0;
background: white;
transition: box-shadow .2s;
}
:host:hover {
box-shadow: 0 1px 5px rgba(0,0,0,.5);
}
div {
display: inline-block;
width: 2em;
height: 2em;
position: relative;
cursor: pointer;
z-index: 1;
box-sizing: border-box;
-moz-box-sizing: border-box;
transition: box-shadow .2s;
}
div:hover {
z-index: 2;
box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
div:hover,
div.selected {
border: 3px solid rgba(255,255,255,.7);
}
</style>
</color-palette>