@appscode/design-system 2.6.22-alpha-0.0.17 → 2.6.22-alpha-0.0.18
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.
package/package.json
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, watch } from "vue";
|
|
3
|
+
import HeroiconsChevronDown20Solid from "~icons/heroicons/chevron-down-20-solid";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
title: string;
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
11
|
+
isOpen: false,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const dropDownStatus = ref<"close" | "open">("close");
|
|
15
|
+
|
|
16
|
+
const toggleDropDownStatus = () => {
|
|
17
|
+
if (dropDownStatus.value === "open") dropDownStatus.value = "close";
|
|
18
|
+
else dropDownStatus.value = "open";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
watch(
|
|
22
|
+
() => props.isOpen,
|
|
23
|
+
(n) => {
|
|
24
|
+
if (n) {
|
|
25
|
+
dropDownStatus.value = "open";
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{ immediate: true },
|
|
29
|
+
);
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<div
|
|
34
|
+
class="label p-16 b-b-1 is-flex is-align-items-center is-justify-content-space-between is-fullwidth is-clickable"
|
|
35
|
+
@click="toggleDropDownStatus"
|
|
36
|
+
>
|
|
37
|
+
<div class="is-flex gap-8">
|
|
38
|
+
<span class="icon"><slot name="drop-down-icon" /></span>{{ title }}
|
|
39
|
+
</div>
|
|
40
|
+
<HeroiconsChevronDown20Solid
|
|
41
|
+
:style="{ transform: dropDownStatus === 'open' ? 'rotate(180deg)' : 'none', transition: '0.2s' }"
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
<slot v-if="dropDownStatus === 'open'" name="drop-down-items" />
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
title: string;
|
|
4
|
+
id: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
isActive?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
withDefaults(defineProps<Props>(), {
|
|
10
|
+
isActive: false,
|
|
11
|
+
url: "",
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<router-link :to="url" class="sidebar-item" :class="{ 'is-active': isActive }">
|
|
17
|
+
<span class="icon">
|
|
18
|
+
<slot name="item-icon" />
|
|
19
|
+
</span>
|
|
20
|
+
<span>{{ title }}</span>
|
|
21
|
+
</router-link>
|
|
22
|
+
</template>
|
|
@@ -1,93 +1,10 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { nextTick, watch, ref, computed } from "vue";
|
|
3
|
-
import { useRoute } from "vue-router";
|
|
4
|
-
import CogIcon from "../../icons/CogIcon.vue";
|
|
5
|
-
|
|
6
|
-
interface SidebarEntry {
|
|
7
|
-
id: string;
|
|
8
|
-
name: string;
|
|
9
|
-
icon?: any;
|
|
10
|
-
url: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface SidebarSection {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
icon?: any;
|
|
17
|
-
entries: SidebarEntry[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface Props {
|
|
21
|
-
items: SidebarSection[];
|
|
22
|
-
isActive: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Props
|
|
26
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
27
|
-
items: () => [],
|
|
28
|
-
isActive: false
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const sidebarItem = ref<HTMLElement | null>(null);
|
|
32
|
-
|
|
33
|
-
const route = useRoute();
|
|
34
|
-
|
|
35
|
-
const updatedItems = computed(() => {
|
|
36
|
-
return props.items.map((section) => {
|
|
37
|
-
const updatedEntries = section.entries.map((entry) => ({
|
|
38
|
-
...entry,
|
|
39
|
-
isActive: route.path === entry.url,
|
|
40
|
-
}));
|
|
41
|
-
return { ...section, entries: updatedEntries };
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Scroll active item into view
|
|
46
|
-
watch(
|
|
47
|
-
() => props.isActive,
|
|
48
|
-
(n) => {
|
|
49
|
-
if (n) {
|
|
50
|
-
nextTick(() => {
|
|
51
|
-
setTimeout(() => {
|
|
52
|
-
const top = (sidebarItem.value && sidebarItem.value.getBoundingClientRect().top) || 0;
|
|
53
|
-
if (top > window.innerHeight - 200) {
|
|
54
|
-
sidebarItem.value?.scrollIntoView({
|
|
55
|
-
behavior: "smooth",
|
|
56
|
-
block: "center",
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}, 300);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
{ immediate: true },
|
|
64
|
-
);
|
|
65
|
-
</script>
|
|
1
|
+
<script setup lang="ts"></script>
|
|
66
2
|
|
|
67
3
|
<template>
|
|
68
4
|
<div class="sidebar-style-2">
|
|
69
5
|
<div class="left-sidebar">
|
|
70
|
-
<div class="sidebar-items"
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
<slot
|
|
74
|
-
name="sidebar-item"
|
|
75
|
-
v-for="(entry, iIdx) in section.entries"
|
|
76
|
-
:key="entry.id"
|
|
77
|
-
:item="entry"
|
|
78
|
-
>
|
|
79
|
-
<router-link
|
|
80
|
-
:to="entry.url"
|
|
81
|
-
class="sidebar-item"
|
|
82
|
-
:class="{ 'is-active': entry.isActive }"
|
|
83
|
-
:ref="entry.isActive ? sidebarItem : null"
|
|
84
|
-
>
|
|
85
|
-
<span class="icon">
|
|
86
|
-
<img :src="entry.icon || CogIcon" alt="icon" />
|
|
87
|
-
</span>
|
|
88
|
-
<span>{{ entry.name }}</span>
|
|
89
|
-
</router-link>
|
|
90
|
-
</slot>
|
|
6
|
+
<div class="sidebar-items">
|
|
7
|
+
<slot name="items-with-drop-down" />
|
|
91
8
|
</div>
|
|
92
9
|
</div>
|
|
93
10
|
</div>
|