-
Notifications
You must be signed in to change notification settings - Fork 2
/
Container.svelte
160 lines (140 loc) 路 3.12 KB
/
Container.svelte
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<script>
import { fly } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
import BtnFold from '../Btn_Fold/Btn_Fold.svelte';
import Icon_Settings from '../icons/Settings.svelte';
import Container_Items_Settings from '../Container_Items_Settings/Container_Items_Settings.svelte';
export let fold_direction;
export let is_show_settings = false;
export let settings_options = undefined;
export let settings_binds = undefined;
let is_folded = false;
let show_is_folded_btn = false;
let is_settings_open = false;
function get_transition_values() {
switch (fold_direction) {
case 'right':
return { x: 400, duration: 200, easing: quintOut };
break;
case 'down':
return { y: 200, duration: 200, easing: quintOut };
break;
case 'left_top':
return { x: -200, duration: 200, easing: quintOut };
break;
default:
break;
}
}
</script>
<div
class="container {is_folded ? `${fold_direction}_animate_out` : `${fold_direction}_animate_in`}"
>
{#if is_show_settings}
<button
class="icon_settings"
on:click={() => {
is_settings_open = !is_settings_open;
}}
>
<Icon_Settings width={21} height={21} fill={'#eee'} fill_opacity={0.8} />
</button>
{/if}
<slot />
</div>
{#if is_settings_open}
<Container_Items_Settings options={settings_options} binds={settings_binds} />
{/if}
<div
class="btn_fold {fold_direction} {is_folded
? `${fold_direction}_animate_out`
: `${fold_direction}_animate_in`}"
on:animationend={() => {
if (is_folded) {
show_is_folded_btn = true;
}
}}
>
<BtnFold
{fold_direction}
{is_folded}
on:click={(e) => {
is_folded = !is_folded;
}}
/>
</div>
{#if show_is_folded_btn}
<div
class="btn_fold {fold_direction}"
in:fly|local={get_transition_values()}
out:fly|local={get_transition_values()}
on:outroend={() => {
is_folded = false;
}}
>
<BtnFold
{fold_direction}
{is_folded}
on:click={(e) => {
show_is_folded_btn = false;
}}
/>
</div>
{/if}
<style>
.container {
display: flex;
flex-direction: column;
position: relative;
padding: 2rem;
background-color: var(--container-bg-color);
border-radius: var(--border-radius-primary);
backdrop-filter: blur(10px);
filter: drop-shadow(0px 4px 20px rgba(0, 0, 0, 0.74));
z-index: 100;
}
.btn_fold {
position: absolute;
z-index: 2;
}
.right {
right: 0rem;
bottom: -2rem;
}
.right_animate_in {
animation: slide_in_right var(--animation-slide-in-values);
}
.right_animate_out {
animation: slide_out_right var(--animation-slide-in-values);
}
.down_animate_in {
animation: slide_in_down var(--animation-slide-in-values);
}
.down_animate_out {
animation: slide_out_down var(--animation-slide-in-values);
}
.left_top_animate_in {
animation: slide_in_left var(--animation-slide-in-values);
}
.left_top_animate_out {
animation: slide_out_left var(--animation-slide-in-values);
}
.left {
right: 0rem;
bottom: -2rem;
}
.down {
right: -2rem;
bottom: 0;
}
.left_top {
left: 0px;
top: -2rem;
}
.icon_settings {
background-color: transparent;
border: none;
align-self: flex-end;
cursor: pointer;
}
</style>