cja-phoenix 0.6.2 → 0.6.3

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.
@@ -0,0 +1,193 @@
1
+ <template>
2
+ <Teleport to="body">
3
+ <Transition name="fade">
4
+ <div
5
+ class="drawer-backdrop"
6
+ v-if="backdrop && active"
7
+ @click="closeDrawer"
8
+ ></div>
9
+ </Transition>
10
+ <Transition name="slide">
11
+ <div
12
+ class="drawer-container"
13
+ :class="[`drawer-${type}`, { active: active }]"
14
+ :style="{ height, ...cssVars }"
15
+ >
16
+ <slot></slot>
17
+ </div>
18
+ </Transition>
19
+ </Teleport>
20
+ </template>
21
+
22
+ <script lang="ts" setup>
23
+ import { ref } from "vue";
24
+ import { computed } from "vue";
25
+
26
+ const props = withDefaults(
27
+ defineProps<{
28
+ defaultActive?: boolean;
29
+ type?:
30
+ | "vertical-top"
31
+ | "vertical-bottom"
32
+ | "horizontal-left"
33
+ | "horizontal-right";
34
+ maxWidth?: {
35
+ md?: string;
36
+ lg?: string;
37
+ xl?: string;
38
+ };
39
+ height?: string;
40
+ backdrop?: boolean;
41
+ }>(),
42
+ {
43
+ defaultActive: false,
44
+ type: "vertical-bottom",
45
+ backdrop: false,
46
+ close: true,
47
+ maxWidth: () => ({
48
+ md: "min(calc(100% - 48px), 768px)",
49
+ lg: "min(calc(100% - 48px), 1024px)",
50
+ xl: "1024px",
51
+ }),
52
+ }
53
+ );
54
+
55
+ const cssVars = computed(() => ({
56
+ "--md-max-width": props.maxWidth.md,
57
+ "--lg-max-width": props.maxWidth.lg,
58
+ "--xl-max-width": props.maxWidth.xl,
59
+ }));
60
+
61
+ const active = ref(props.defaultActive);
62
+
63
+ const emit = defineEmits(["close", "open"]);
64
+
65
+ const openDrawer = () => {
66
+ active.value = true;
67
+ emit("open");
68
+ };
69
+
70
+ const closeDrawer = () => {
71
+ active.value = false;
72
+ emit("close");
73
+ };
74
+
75
+ const toggleDrawer = () => {
76
+ active.value = !active.value;
77
+
78
+ emit(active.value ? "open" : "close");
79
+ };
80
+
81
+ defineExpose({ active, openDrawer, closeDrawer, toggleDrawer });
82
+ </script>
83
+
84
+ <style lang="scss" scoped>
85
+ @import "../../assets/breakpoints.scss";
86
+ @import "../../assets/backdrop.scss";
87
+
88
+ .drawer-backdrop {
89
+ @include backdrop;
90
+
91
+ &.fade-enter-from,
92
+ &.fade-leave-to {
93
+ opacity: 0;
94
+ }
95
+
96
+ &.fade-enter-to,
97
+ &.fade-leave-from {
98
+ opacity: 1;
99
+ }
100
+ }
101
+
102
+ .drawer-container {
103
+ position: fixed;
104
+ z-index: 1000;
105
+ width: 100%;
106
+ transition: all 0.3s ease-in-out;
107
+
108
+ @media screen and (min-width: $break-md-min) {
109
+ max-width: var(--md-max-width);
110
+ }
111
+
112
+ @media screen and (min-width: $break-lg-min) {
113
+ max-width: var(--lg-max-width);
114
+ }
115
+
116
+ @media screen and (min-width: $break-xl-min) {
117
+ max-width: var(--xl-max-width);
118
+ }
119
+
120
+ &.drawer-vertical-top {
121
+ top: 0;
122
+
123
+ &.active {
124
+ transform: translateY(0);
125
+ }
126
+
127
+ &.slide-enter-from,
128
+ &.slide-leave-to {
129
+ transform: translateY(-100%);
130
+ }
131
+
132
+ &.slide-enter-to,
133
+ &.slide-leave-from {
134
+ transform: translateY(0);
135
+ }
136
+ }
137
+
138
+ &.drawer-vertical-bottom {
139
+ bottom: 0;
140
+ transform: translateY(100%);
141
+
142
+ &.active {
143
+ transform: translateY(0);
144
+ }
145
+
146
+ &.slide-enter-from,
147
+ &.slide-leave-to {
148
+ transform: translateY(100%);
149
+ }
150
+
151
+ &.slide-enter-to,
152
+ &.slide-leave-from {
153
+ transform: translateY(0);
154
+ }
155
+ }
156
+
157
+ &.drawer-horizontal-left {
158
+ left: 0;
159
+
160
+ &.active {
161
+ transform: translateX(0);
162
+ }
163
+
164
+ &.slide-enter-from,
165
+ &.slide-leave-to {
166
+ transform: translateX(-100%);
167
+ }
168
+
169
+ &.slide-enter-to,
170
+ &.slide-leave-from {
171
+ transform: translateX(0);
172
+ }
173
+ }
174
+
175
+ &.drawer-horizontal-right {
176
+ right: 0;
177
+
178
+ &.active {
179
+ transform: translateX(0);
180
+ }
181
+
182
+ &.slide-enter-from,
183
+ &.slide-leave-to {
184
+ transform: translateX(100%);
185
+ }
186
+
187
+ &.slide-enter-to,
188
+ &.slide-leave-from {
189
+ transform: translateX(0);
190
+ }
191
+ }
192
+ }
193
+ </style>