-
Notifications
You must be signed in to change notification settings - Fork 17
/
Scale.vue
130 lines (122 loc) · 3.05 KB
/
Scale.vue
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template>
<div>
<Flipper :flip-key="focused">
<div class="flex items-center h-screen justify-center" v-if="focused === null">
<div v-for="color in colors" :key="color">
<Flipped :flip-id="color" translate scale>
<div
class="mx-3"
@click="setFocused(color)"
role="button"
:style="{backgroundColor: color}"
>
<Flipped :inverse-flip-id="color">
<div class="square font-mono text-xs flex items-center justify-center text-white">
<Flipped :flip-id="`hex-${color}`">
<span>{{ color }}</span>
</Flipped>
</div>
</Flipped>
</div>
</Flipped>
</div>
</div>
<Flipped :flip-id="focused" v-else @on-start="handleStart">
<div
@click="setFocused(focused)"
class="full-screen-square flex flex-col"
:style="{backgroundColor: focused}"
>
<Flipped :inverse-flip-id="focused">
<div class="flex-auto">
<div class="font-mono text-xs text-white p-4 text-center font-bold">
<Flipped :flip-id="`hex-${focused}`">
<span>{{ focused }}</span>
</Flipped>
</div>
<div class="opacity-grid flex-auto h-full">
<div
:style="{backgroundColor: `rgba(0, 0, 0, ${index/40})`}"
class="opacity-grid-square p-4"
v-for="(num, index) in Array(16)"
:key="num"
></div>
</div>
</div>
</Flipped>
</div>
</Flipped>
</Flipper>
</div>
</template>
<script>
import Flipper from "../src/Flipper";
import Flipped from "../src/Flipped";
import anime from "animejs";
export default {
name: "scale",
components: {
Flipper,
Flipped
},
data() {
return {
focused: null,
colors: ["#ff4f66", "#7971ea", "#5900d8"]
};
},
methods: {
setFocused(index) {
if (index === this.focused) {
this.focused = null;
} else {
this.focused = index;
}
},
handleStart({ el, id }) {
const squares = el.querySelectorAll(".opacity-grid-square");
anime({
targets: squares,
opacity: [0, 1],
delay: anime.stagger(40, { easing: "easeInQuad" })
});
}
}
};
</script>
<style lang="css" scoped>
.square {
height: 100px;
width: 100px;
}
.wrap {
transition: background 0.2s ease-out;
}
.wrap.open {
background: rgba(0, 0, 0, 1);
}
.full-screen-square {
width: 600px;
height: 600px;
position: fixed;
margin: auto;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 10;
}
.opacity-grid {
height: 555px;
border-top: 1px solid rgba(0, 0, 0, 0.05);
overflow: hidden;
display: grid;
grid-gap: 0;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(4, calc(555px / 4));
grid-auto-flow: row;
}
.opacity-grid-square {
opacity: 0;
}
</style>