@appscode/design-system 0.0.21-alpha.2 → 0.4.27
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/base/utilities/_all.scss +7 -0
- package/base/utilities/_customize-bulma.scss +191 -0
- package/base/utilities/_default.scss +319 -110
- package/base/utilities/_derived-variables.scss +8 -15
- package/base/utilities/_grid.scss +29 -0
- package/base/utilities/_initial-variables.scss +111 -72
- package/base/utilities/_mixin.scss +90 -10
- package/base/utilities/_typography.scss +29 -19
- package/base/utilities/dark-theme.scss +26 -0
- package/components/_ac-accordion.scss +15 -5
- package/components/_ac-alert-box.scss +109 -26
- package/components/_ac-card.scss +71 -24
- package/components/_ac-code-highlight.scss +7 -1
- package/components/_ac-content-layout.scss +5 -5
- package/components/_ac-drag.scss +8 -6
- package/components/_ac-input.scss +196 -38
- package/components/_ac-modal.scss +6 -5
- package/components/_ac-multi-select.scss +281 -23
- package/components/_ac-options.scss +31 -16
- package/components/_ac-report.scss +53 -0
- package/components/_ac-select-box.scss +15 -5
- package/components/_ac-table.scss +160 -39
- package/components/_ac-tabs.scss +86 -23
- package/components/_ac-tags.scss +87 -2
- package/components/_ac-terminal.scss +270 -0
- package/components/_all.scss +28 -0
- package/components/_app-drawer.scss +134 -0
- package/components/_breadcumb.scss +8 -3
- package/components/_buttons.scss +96 -62
- package/components/_card-body-wrapper.scss +3 -3
- package/components/_dashboard-header.scss +33 -1
- package/components/_direct-deploy.scss +69 -0
- package/components/_go-to-top.scss +1 -1
- package/components/_graph.scss +45 -0
- package/components/_image-upload.scss +6 -4
- package/components/_left-sidebar-menu.scss +212 -52
- package/components/_monaco-editor.scss +1 -1
- package/components/_navbar.scss +193 -31
- package/components/_overview-info.scss +4 -4
- package/components/_overview-page.scss +1 -2
- package/components/_pagination.scss +45 -7
- package/components/_payment-card.scss +28 -12
- package/components/_preloader.scss +1 -1
- package/components/_preview-modal.scss +22 -9
- package/components/_pricing-table.scss +1 -1
- package/components/_progress-bar.scss +5 -5
- package/components/_subscription-card.scss +15 -8
- package/components/_table-of-content.scss +1 -1
- package/components/_tfa.scss +69 -0
- package/components/_transitions.scss +261 -0
- package/components/_widget-menu.scss +9 -9
- package/components/_wizard.scss +33 -20
- package/components/ac-toaster/_ac-toasted.scss +40 -8
- package/components/bbum/_all.scss +9 -0
- package/components/bbum/_card-team.scss +18 -10
- package/components/bbum/_information-center.scss +19 -5
- package/components/bbum/_mobile-desktop.scss +6 -6
- package/components/bbum/_post.scss +5 -4
- package/components/bbum/_sign-up-notification.scss +6 -6
- package/components/bbum/_single-post-preview.scss +10 -10
- package/components/bbum/_user-profile.scss +97 -90
- package/components/ui-builder/_ui-builder.scss +98 -21
- package/components/ui-builder/_vue-open-api.scss +104 -0
- package/layouts/_404.scss +159 -0
- package/layouts/_all.scss +2 -0
- package/layouts/_code-preview.scss +19 -8
- package/main.scss +6 -53
- package/package.json +4 -7
- package/plugins/caching.ts +243 -0
- package/plugins/theme.js +142 -0
- package/plugins/time-convert.js +49 -0
- package/plugins/vue-toaster.js +10 -6
- package/vue-components/v2/banner/Banner.vue +2 -2
- package/vue-components/v2/breadcrumbs/Breadcrumb.vue +97 -0
- package/vue-components/v2/button/Button.vue +10 -1
- package/vue-components/v2/button/DownloadBtn.vue +45 -0
- package/vue-components/v2/card/Card.vue +1 -0
- package/vue-components/v2/card/CardContent.vue +5 -0
- package/vue-components/v2/card/CardHeader.vue +12 -0
- package/vue-components/v2/card/OverviewCard.vue +10 -0
- package/vue-components/v2/card/OverviewCards.vue +5 -0
- package/vue-components/v2/card/PaymentCard.vue +69 -0
- package/vue-components/v2/card/PaymentCardOptionButtons.vue +35 -0
- package/vue-components/v2/card/PaymentCards.vue +44 -0
- package/vue-components/v2/content/ContentHeader.vue +9 -5
- package/vue-components/v2/content/ContentTable.vue +12 -7
- package/vue-components/v2/editor/Editor.vue +38 -5
- package/vue-components/v2/editor/FilteredFileEditor.vue +189 -0
- package/vue-components/v2/editor/MonacoEditor.vue +125 -0
- package/vue-components/v2/editor/ResourceKeyValueEditor.vue +209 -0
- package/vue-components/v2/form/Form.vue +12 -7
- package/vue-components/v2/form-fields/Input.vue +1 -1
- package/vue-components/v2/header/Header.vue +0 -1
- package/vue-components/v2/loaders/ResourceLoader.vue +101 -0
- package/vue-components/v2/loaders/SidebarLoader.vue +43 -0
- package/vue-components/v2/modal/Modal.vue +40 -7
- package/vue-components/v2/modals/DeleteConfirmationModal.vue +79 -0
- package/vue-components/v2/modals/JsonShowModal.vue +12 -3
- package/vue-components/v2/navbar/Appdrawer.vue +10 -9
- package/vue-components/v2/navbar/ThemeMode.vue +120 -0
- package/vue-components/v2/navbar/User.vue +229 -17
- package/vue-components/v2/notification/Notification.vue +101 -0
- package/vue-components/v2/notification/NotificationItem.vue +44 -0
- package/vue-components/v2/pagination/Pagination.vue +24 -4
- package/vue-components/v2/preloader/Preloader.vue +5 -5
- package/vue-components/v2/sidebar/ClusterSwitcher.vue +126 -0
- package/vue-components/v2/sidebar/SidebarItem.vue +24 -2
- package/vue-components/v2/sidebar/SidebarItemWithDropDown.vue +19 -20
- package/vue-components/v2/tab/TabItem.vue +1 -1
- package/vue-components/v2/table/FakeTableCell.vue +36 -0
- package/vue-components/v2/table/InfoTable.vue +13 -3
- package/vue-components/v2/table/NarrowTable.vue +0 -2
- package/vue-components/v2/table/Table.vue +170 -10
- package/vue-components/v2/table/TableRow.vue +29 -2
- package/vue-components/v2/table/table-cell/CellValue.vue +33 -4
- package/vue-components/v2/table/table-cell/GenericCell.vue +56 -0
- package/vue-components/v2/table/table-cell/ObjectCell.vue +4 -1
- package/vue-components/v2/tabs/EditorTabs.vue +1 -1
- package/vue-components/v3/button/Button.vue +78 -0
- package/vue-components/v3/content/ContentHeader.vue +55 -0
- package/vue-components/v3/content/ContentTable.vue +83 -0
- package/vue-components/v3/dropdown/DropdownDivider.vue +3 -0
- package/vue-components/v3/dropdown/DropdownItem.vue +5 -0
- package/vue-components/v3/dropdown/DropdownMenu.vue +111 -0
- package/vue-components/v3/editor/Editor.vue +160 -0
- package/vue-components/v3/editor/FilteredFileEditor.vue +186 -0
- package/vue-components/v3/editor/MonacoEditor.vue +131 -0
- package/vue-components/v3/editor/ResourceKeyValueEditor.vue +125 -0
- package/vue-components/v3/form/Form.vue +63 -0
- package/vue-components/v3/form-fields/Input.vue +22 -0
- package/vue-components/v3/header/Header.vue +45 -0
- package/vue-components/v3/header/HeaderItem.vue +5 -0
- package/vue-components/v3/header/HeaderItems.vue +5 -0
- package/vue-components/v3/loaders/ResourceLoader.vue +83 -0
- package/vue-components/v3/loaders/SidebarLoader.vue +34 -0
- package/vue-components/v3/long-running-tasks/LongRunningTaskItem.vue +92 -0
- package/vue-components/v3/modal/Modal.vue +158 -0
- package/vue-components/v3/modals/DeleteConfirmationModal.vue +85 -0
- package/vue-components/v3/modals/JsonShowModal.vue +96 -0
- package/vue-components/v3/modals/LongRunningTasksModal.vue +373 -0
- package/vue-components/v3/navbar/Appdrawer.vue +63 -0
- package/vue-components/v3/navbar/ThemeMode.vue +120 -0
- package/vue-components/v3/navbar/User.vue +288 -0
- package/vue-components/v3/notification/Notification.vue +98 -0
- package/vue-components/v3/notification/NotificationItem.vue +52 -0
- package/vue-components/v3/pagination/Pagination.vue +172 -0
- package/vue-components/v3/searchbars/SearchBar.vue +47 -0
- package/vue-components/v3/sidebar/ClusterSwitcher.vue +133 -0
- package/vue-components/v3/sidebar/SidebarItemWithDropDown.vue +120 -0
- package/vue-components/v3/tab/TabItem.vue +17 -0
- package/vue-components/v3/table/FakeTableCell.vue +39 -0
- package/vue-components/v3/table/InfoTable.vue +105 -0
- package/vue-components/v3/table/MultiInfoTable.vue +143 -0
- package/vue-components/v3/table/Table.vue +272 -0
- package/vue-components/v3/table/TableCell.vue +28 -0
- package/vue-components/v3/table/TableContainer.vue +34 -0
- package/vue-components/v3/table/TableRow.vue +147 -0
- package/vue-components/v3/table/table-cell/ArrayCell.vue +111 -0
- package/vue-components/v3/table/table-cell/CellValue.vue +133 -0
- package/vue-components/v3/table/table-cell/GenericCell.vue +75 -0
- package/vue-components/v3/table/table-cell/ObjectCell.vue +110 -0
- package/vue-components/v3/table/table-cell/ValueWithModal.vue +43 -0
- package/vue-components/v3/tabs/EditorTabs.vue +36 -0
- package/vue-components/v3/tag/Tag.vue +17 -0
- package/vue-components/v3/terminal/LongRunningTaskTerminal.vue +148 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<content-loader
|
|
4
|
+
:width="100"
|
|
5
|
+
:height="175"
|
|
6
|
+
:speed="2"
|
|
7
|
+
:primaryColor="primaryLoaderColor"
|
|
8
|
+
:secondaryColor="secondaryLoaderColor"
|
|
9
|
+
>
|
|
10
|
+
<rect x="2" y="1" rx="3" ry="3" width="96" height="20" />
|
|
11
|
+
<rect x="15" y="23" rx="3" ry="3" width="83" height="15" />
|
|
12
|
+
<rect x="15" y="40" rx="3" ry="3" width="83" height="15" />
|
|
13
|
+
<rect x="15" y="57" rx="3" ry="3" width="83" height="15" />
|
|
14
|
+
|
|
15
|
+
<rect x="2" y="78" rx="3" ry="3" width="96" height="20" />
|
|
16
|
+
<rect x="15" y="100" rx="3" ry="3" width="83" height="15" />
|
|
17
|
+
<rect x="15" y="117" rx="3" ry="3" width="83" height="15" />
|
|
18
|
+
<rect x="15" y="134" rx="3" ry="3" width="83" height="15" />
|
|
19
|
+
|
|
20
|
+
<rect x="2" y="155" rx="3" ry="3" width="96" height="20" />
|
|
21
|
+
</content-loader>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
import { ContentLoader } from "vue-content-loader";
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
components: {
|
|
30
|
+
ContentLoader
|
|
31
|
+
},
|
|
32
|
+
props: {
|
|
33
|
+
primaryLoaderColor: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "#f5f7f9"
|
|
36
|
+
},
|
|
37
|
+
secondaryLoaderColor: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "#ecebeb"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
</script>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- for transition https://github.com/adamwathan/vue-tailwind-examples/blob/master/src/components/Modal.vue -->
|
|
3
|
-
<!-- modal start -->
|
|
4
2
|
<portal to="modal">
|
|
3
|
+
<!-- for transition https://github.com/adamwathan/vue-tailwind-examples/blob/master/src/components/Modal.vue -->
|
|
4
|
+
<!-- modal start -->
|
|
5
5
|
<div
|
|
6
6
|
v-if="showModal"
|
|
7
7
|
class="ac-modal is-middle-alignment"
|
|
8
8
|
:class="modifierClasses"
|
|
9
|
-
@click.self="
|
|
9
|
+
@click.self="onModalOutsideClick"
|
|
10
10
|
>
|
|
11
11
|
<div class="ac-modal-inner">
|
|
12
12
|
<!-- modal header start -->
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
<header-item>
|
|
18
18
|
<ac-button
|
|
19
19
|
modifier-classes="is-square is-transparent"
|
|
20
|
-
:
|
|
20
|
+
:disabled="isCloseOptionDisabled"
|
|
21
|
+
:icon-image="
|
|
22
|
+
require('@appscode/design-system-images/icons/close-icon.svg')
|
|
23
|
+
"
|
|
24
|
+
data-testid="delete-confirmation-modal-close-icon"
|
|
21
25
|
@click.stop="destroyModal"
|
|
22
26
|
/>
|
|
23
27
|
</header-item>
|
|
@@ -26,7 +30,10 @@
|
|
|
26
30
|
<!-- modal header end -->
|
|
27
31
|
|
|
28
32
|
<!-- modal body start -->
|
|
29
|
-
<div
|
|
33
|
+
<div
|
|
34
|
+
class="ac-modal-body ac-vscrollbar"
|
|
35
|
+
data-testid="ac-modal-content-with-scroll"
|
|
36
|
+
>
|
|
30
37
|
<div class="ac-modal-content">
|
|
31
38
|
<!-- freedom content start -->
|
|
32
39
|
<slot />
|
|
@@ -36,7 +43,17 @@
|
|
|
36
43
|
<!-- modal body end -->
|
|
37
44
|
|
|
38
45
|
<!-- modal footer start -->
|
|
39
|
-
<div
|
|
46
|
+
<div
|
|
47
|
+
v-if="!hideActionFooter"
|
|
48
|
+
class="
|
|
49
|
+
ac-modal-footer
|
|
50
|
+
action-footer
|
|
51
|
+
is-flex is-align-items-center is-justify-content-space-between
|
|
52
|
+
"
|
|
53
|
+
>
|
|
54
|
+
<div>
|
|
55
|
+
<slot name="modal-footer-left" />
|
|
56
|
+
</div>
|
|
40
57
|
<buttons class="has-text-right is-block">
|
|
41
58
|
<slot name="modal-footer-controls" />
|
|
42
59
|
</buttons>
|
|
@@ -45,7 +62,6 @@
|
|
|
45
62
|
</div>
|
|
46
63
|
</div>
|
|
47
64
|
</portal>
|
|
48
|
-
<!-- modal end -->
|
|
49
65
|
</template>
|
|
50
66
|
|
|
51
67
|
<script>
|
|
@@ -63,6 +79,18 @@ export default {
|
|
|
63
79
|
type: String,
|
|
64
80
|
default: "",
|
|
65
81
|
},
|
|
82
|
+
isCloseOptionDisabled: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false,
|
|
85
|
+
},
|
|
86
|
+
ignoreOutsideClick: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
},
|
|
90
|
+
hideActionFooter: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: false,
|
|
93
|
+
},
|
|
66
94
|
},
|
|
67
95
|
|
|
68
96
|
components: {
|
|
@@ -98,11 +126,16 @@ export default {
|
|
|
98
126
|
this.destroyModal();
|
|
99
127
|
}
|
|
100
128
|
},
|
|
129
|
+
onModalOutsideClick() {
|
|
130
|
+
if (this.ignoreOutsideClick) return;
|
|
131
|
+
this.destroyModal();
|
|
132
|
+
},
|
|
101
133
|
initializeModal() {
|
|
102
134
|
this.showModal = true;
|
|
103
135
|
document.addEventListener("keydown", this.onKeyDown);
|
|
104
136
|
},
|
|
105
137
|
destroyModal() {
|
|
138
|
+
if (this.isCloseOptionDisabled) return;
|
|
106
139
|
this.showModal = false;
|
|
107
140
|
document.removeEventListener("keydown", this.onKeyDown);
|
|
108
141
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- modal start -->
|
|
3
|
+
<modal
|
|
4
|
+
:title="title"
|
|
5
|
+
modifier-classes="is-normal"
|
|
6
|
+
:open="open"
|
|
7
|
+
@closemodal="closeModal"
|
|
8
|
+
>
|
|
9
|
+
<!-- freedom content start -->
|
|
10
|
+
<div class="action-message pt-35 pb-35 has-text-centered">
|
|
11
|
+
<h5 class="is-message">{{ message }} {{ itemName ? "" : "?" }}</h5>
|
|
12
|
+
<p class="is-description">{{ itemName }} {{ itemName ? "?" : "" }}</p>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<!-- freedom content end -->
|
|
16
|
+
|
|
17
|
+
<!-- modal footer start -->
|
|
18
|
+
<template #modal-footer-controls>
|
|
19
|
+
<ac-button
|
|
20
|
+
@click.stop="closeModal"
|
|
21
|
+
title="Cancel"
|
|
22
|
+
modifier-classes="is-outlined"
|
|
23
|
+
data-testid="delete-confirmation-modal-close-button"
|
|
24
|
+
/>
|
|
25
|
+
<ac-button
|
|
26
|
+
modifier-classes="is-danger"
|
|
27
|
+
:is-loader-active="isDeleteActive"
|
|
28
|
+
title="Yes"
|
|
29
|
+
data-testid="delete-confirmation-modal-confirm-button"
|
|
30
|
+
@click.stop="confirm(true)"
|
|
31
|
+
/>
|
|
32
|
+
</template>
|
|
33
|
+
</modal>
|
|
34
|
+
<!-- modal end -->
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script>
|
|
38
|
+
export default {
|
|
39
|
+
components: {
|
|
40
|
+
Modal: () => import("./../modal/Modal.vue"),
|
|
41
|
+
AcButton: () => import("./../button/Button.vue"),
|
|
42
|
+
},
|
|
43
|
+
props: {
|
|
44
|
+
open: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
title: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: "",
|
|
51
|
+
},
|
|
52
|
+
message: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "",
|
|
55
|
+
},
|
|
56
|
+
itemName: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "",
|
|
59
|
+
},
|
|
60
|
+
isLoading: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
isDeleteActive: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
methods: {
|
|
70
|
+
confirm(response) {
|
|
71
|
+
this.$emit("delete-confirmation-modal$confirm", response);
|
|
72
|
+
},
|
|
73
|
+
closeModal() {
|
|
74
|
+
this.confirm(false);
|
|
75
|
+
this.$emit("closemodal", true);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
</script>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- modal start -->
|
|
3
2
|
<modal
|
|
4
3
|
:title="editorTitle"
|
|
5
4
|
:open="open"
|
|
@@ -11,7 +10,9 @@
|
|
|
11
10
|
<ac-button
|
|
12
11
|
modifier-classes="is-square is-primary"
|
|
13
12
|
icon-class="copy"
|
|
14
|
-
v-clipboard:copy="
|
|
13
|
+
v-clipboard:copy="
|
|
14
|
+
`${editorTitle}: ${JSON.stringify(parsedContent, null, 4)}`
|
|
15
|
+
"
|
|
15
16
|
v-clipboard:success="onCopy"
|
|
16
17
|
v-clipboard:error="onError"
|
|
17
18
|
/>
|
|
@@ -27,6 +28,8 @@
|
|
|
27
28
|
</template>
|
|
28
29
|
|
|
29
30
|
<script>
|
|
31
|
+
import Preloader from "../preloader/Preloader.vue";
|
|
32
|
+
import Banner from "../banner/Banner.vue";
|
|
30
33
|
export default {
|
|
31
34
|
props: {
|
|
32
35
|
open: {
|
|
@@ -44,7 +47,13 @@ export default {
|
|
|
44
47
|
},
|
|
45
48
|
components: {
|
|
46
49
|
Modal: () => import("../modal/Modal.vue"),
|
|
47
|
-
Editor: () =>
|
|
50
|
+
Editor: () => ({
|
|
51
|
+
component: import("../editor/Editor.vue"),
|
|
52
|
+
loading: Preloader,
|
|
53
|
+
delay: 200,
|
|
54
|
+
error: Banner,
|
|
55
|
+
timeout: 100000,
|
|
56
|
+
}),
|
|
48
57
|
AcButton: () => import("../button/Button.vue"),
|
|
49
58
|
HeaderItem: () => import("../header/HeaderItem.vue"),
|
|
50
59
|
},
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="app-drawer-wrapper
|
|
3
|
-
<div
|
|
2
|
+
<div class="app-drawer-wrapper is-flex">
|
|
3
|
+
<div
|
|
4
|
+
class="drawer-icon is-flex is-justify-content-center is-align-items-center"
|
|
5
|
+
>
|
|
4
6
|
<svg
|
|
5
7
|
class="gb_We"
|
|
6
8
|
focusable="false"
|
|
7
9
|
viewBox="0 0 24 24"
|
|
10
|
+
style="width: 22px;margin-top: 2px;"
|
|
8
11
|
:style="{ fill: 'white' }"
|
|
9
12
|
>
|
|
10
13
|
<path
|
|
@@ -20,16 +23,14 @@
|
|
|
20
23
|
<article class="media">
|
|
21
24
|
<figure class="media-left">
|
|
22
25
|
<p class="image">
|
|
23
|
-
<img
|
|
24
|
-
:src="app.icon_url"
|
|
25
|
-
/>
|
|
26
|
+
<img :src="app.icon_url" />
|
|
26
27
|
</p>
|
|
27
28
|
</figure>
|
|
28
29
|
<div class="media-content">
|
|
29
30
|
<div class="content">
|
|
30
31
|
<p>
|
|
31
|
-
<strong>{{app.title}}</strong>
|
|
32
|
-
<span>{{app.sub_title}}</span>
|
|
32
|
+
<strong>{{ app.title }}</strong>
|
|
33
|
+
<span>{{ app.sub_title }}</span>
|
|
33
34
|
</p>
|
|
34
35
|
</div>
|
|
35
36
|
</div>
|
|
@@ -50,7 +51,7 @@ export default {
|
|
|
50
51
|
}
|
|
51
52
|
},
|
|
52
53
|
components: {
|
|
53
|
-
NavbarItemContent: () => import("./NavbarItemContent.vue")
|
|
54
|
-
}
|
|
54
|
+
NavbarItemContent: () => import("./NavbarItemContent.vue")
|
|
55
|
+
}
|
|
55
56
|
};
|
|
56
57
|
</script>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<button
|
|
4
|
+
v-if="themeMode"
|
|
5
|
+
class="button ac-nav-button"
|
|
6
|
+
style="color: #ffffff; font-size: 15px;"
|
|
7
|
+
@click="toggleTheme"
|
|
8
|
+
:title="themeModes[themeMode].displayName"
|
|
9
|
+
>
|
|
10
|
+
<i :class="`fa ${themeModes[themeMode].iconClass}`" />
|
|
11
|
+
</button>
|
|
12
|
+
<div class="ac-menu-content theme-choice">
|
|
13
|
+
<ul class="is-flex is-flex-direction-row is-justify-content-space-around">
|
|
14
|
+
<li
|
|
15
|
+
v-for="theme of Object.keys(themeModes)"
|
|
16
|
+
:title="themeModes[theme].displayName"
|
|
17
|
+
@click="themeMode = theme"
|
|
18
|
+
:class="{'is-active': themeMode === theme}"
|
|
19
|
+
:key="theme"
|
|
20
|
+
>
|
|
21
|
+
<i :class="['fa', themeModes[theme].iconClass]" />
|
|
22
|
+
</li>
|
|
23
|
+
</ul>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
<script>
|
|
28
|
+
export default {
|
|
29
|
+
data() {
|
|
30
|
+
return {
|
|
31
|
+
themeMode: "",
|
|
32
|
+
themeModes: {
|
|
33
|
+
system: {
|
|
34
|
+
displayName: "System Theme",
|
|
35
|
+
iconClass: "fa-desktop",
|
|
36
|
+
},
|
|
37
|
+
light: {
|
|
38
|
+
displayName: "Light Theme",
|
|
39
|
+
iconClass: "fa-sun-o",
|
|
40
|
+
},
|
|
41
|
+
dark: {
|
|
42
|
+
displayName: "Dark Theme",
|
|
43
|
+
iconClass: "fa-moon-o",
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
mounted() {
|
|
50
|
+
// get theme mode from localStorage or set default one
|
|
51
|
+
this.themeMode = localStorage.getItem("themeMode") || "light";
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
destroyed() {
|
|
55
|
+
this.removeColorSchemeEventListener();
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
watch: {
|
|
59
|
+
themeMode: {
|
|
60
|
+
handler(n) {
|
|
61
|
+
this.onThemeModeChange(n);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
methods: {
|
|
67
|
+
// handle theme mode button click
|
|
68
|
+
toggleTheme() {
|
|
69
|
+
if (this.themeMode === "light") this.themeMode = "dark";
|
|
70
|
+
else if (this.themeMode === "dark") this.themeMode = "system";
|
|
71
|
+
else if (this.themeMode === "system") this.themeMode = "light";
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// triggered when theme mode is updated
|
|
75
|
+
onThemeModeChange(n) {
|
|
76
|
+
localStorage.setItem("themeMode", n);
|
|
77
|
+
|
|
78
|
+
let theme = n;
|
|
79
|
+
if (n === "system") {
|
|
80
|
+
const isDarkMode =
|
|
81
|
+
window.matchMedia &&
|
|
82
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
83
|
+
this.addColorSchemeEventListener();
|
|
84
|
+
theme = isDarkMode ? "dark" : "light";
|
|
85
|
+
} else {
|
|
86
|
+
this.removeColorSchemeEventListener();
|
|
87
|
+
}
|
|
88
|
+
this.$emit("set:theme", theme);
|
|
89
|
+
this.handleDarkThemeClass(theme);
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
// add proper css class to update the ui theme
|
|
93
|
+
handleDarkThemeClass(currentTheme) {
|
|
94
|
+
if (currentTheme === "light") {
|
|
95
|
+
document.documentElement.classList.remove("is-dark-theme");
|
|
96
|
+
} else {
|
|
97
|
+
document.documentElement.classList.add("is-dark-theme");
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
// add system theme listener event
|
|
102
|
+
addColorSchemeEventListener() {
|
|
103
|
+
window
|
|
104
|
+
.matchMedia("(prefers-color-scheme: dark)")
|
|
105
|
+
.addEventListener("change", this.handleSystemThemeChange);
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// remove system theme listener event
|
|
109
|
+
removeColorSchemeEventListener() {
|
|
110
|
+
window
|
|
111
|
+
.matchMedia("(prefers-color-scheme: dark)")
|
|
112
|
+
.removeEventListener("change", this.handleSystemThemeChange);
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
handleSystemThemeChange() {
|
|
116
|
+
this.onThemeModeChange(this.themeMode);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
</script>
|