@appscode/design-system 1.0.43-alpha.19 → 1.0.43-alpha.190

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.
Files changed (124) hide show
  1. package/base/utilities/_all.scss +6 -0
  2. package/base/utilities/_default.scss +269 -4
  3. package/base/utilities/_derived-variables.scss +0 -1
  4. package/base/utilities/_initial-variables.scss +17 -13
  5. package/base/utilities/_mixin.scss +1 -17
  6. package/base/utilities/_typography.scss +14 -4
  7. package/base/utilities/dark-theme.scss +9 -146
  8. package/components/_ac-accordion.scss +8 -4
  9. package/components/_ac-alert-box.scss +15 -7
  10. package/components/_ac-card.scss +33 -6
  11. package/components/_ac-code-highlight.scss +5 -1
  12. package/components/_ac-content-layout.scss +2 -2
  13. package/components/_ac-input.scss +63 -23
  14. package/components/_ac-multi-select.scss +187 -5
  15. package/components/_ac-options.scss +24 -9
  16. package/components/_ac-select-box.scss +13 -3
  17. package/components/_ac-table.scss +7 -5
  18. package/components/_ac-tabs.scss +42 -5
  19. package/components/_ac-terminal.scss +270 -0
  20. package/components/_all.scss +35 -0
  21. package/components/_app-drawer.scss +2 -2
  22. package/components/_breadcumb.scss +2 -0
  23. package/components/_buttons.scss +45 -36
  24. package/components/_card-body-wrapper.scss +2 -2
  25. package/components/_dashboard-header.scss +32 -0
  26. package/components/_direct-deploy.scss +69 -0
  27. package/components/_go-to-top.scss +1 -1
  28. package/components/_graph.scss +45 -0
  29. package/components/_image-upload.scss +5 -3
  30. package/components/_left-sidebar-menu.scss +193 -39
  31. package/components/_monaco-editor.scss +1 -1
  32. package/components/_navbar.scss +125 -8
  33. package/components/_overview-info.scss +4 -4
  34. package/components/_pagination.scss +8 -0
  35. package/components/_payment-card.scss +10 -1
  36. package/components/_preview-modal.scss +15 -4
  37. package/components/_pricing-table.scss +1 -1
  38. package/components/_progress-bar.scss +4 -4
  39. package/components/_subscription-card.scss +12 -5
  40. package/components/_table-of-content.scss +1 -1
  41. package/components/_tfa.scss +69 -0
  42. package/components/_transitions.scss +261 -0
  43. package/components/_wizard.scss +16 -3
  44. package/components/ac-toaster/_ac-toasted.scss +1 -1
  45. package/components/bbum/_card-team.scss +1 -1
  46. package/components/bbum/_information-center.scss +15 -1
  47. package/components/bbum/_sign-up-notification.scss +1 -1
  48. package/components/bbum/_single-post-preview.scss +1 -1
  49. package/components/bbum/_user-profile.scss +91 -90
  50. package/components/ui-builder/_ui-builder.scss +43 -3
  51. package/components/ui-builder/_vue-open-api.scss +104 -0
  52. package/layouts/_all.scss +2 -0
  53. package/layouts/_code-preview.scss +5 -2
  54. package/main.scss +4 -54
  55. package/package.json +2 -7
  56. package/plugins/theme.js +4 -0
  57. package/plugins/time-convert.js +49 -0
  58. package/plugins/vue-toaster.js +3 -0
  59. package/vue-components/v2/banner/Banner.vue +2 -2
  60. package/vue-components/v2/breadcrumbs/Breadcrumb.vue +97 -0
  61. package/vue-components/v2/button/Button.vue +5 -0
  62. package/vue-components/v2/button/DownloadBtn.vue +45 -0
  63. package/vue-components/v2/card/Card.vue +1 -0
  64. package/vue-components/v2/card/PaymentCards.vue +11 -2
  65. package/vue-components/v2/content/ContentTable.vue +12 -7
  66. package/vue-components/v2/editor/Editor.vue +38 -5
  67. package/vue-components/v2/editor/FilteredFileEditor.vue +189 -0
  68. package/vue-components/v2/editor/MonacoEditor.vue +125 -0
  69. package/vue-components/v2/editor/ResourceKeyValueEditor.vue +209 -0
  70. package/vue-components/v2/form-fields/Input.vue +1 -1
  71. package/vue-components/v2/loaders/ResourceLoader.vue +101 -0
  72. package/vue-components/v2/loaders/SidebarLoader.vue +43 -0
  73. package/vue-components/v2/modal/Modal.vue +35 -4
  74. package/vue-components/v2/modals/DeleteConfirmationModal.vue +79 -0
  75. package/vue-components/v2/modals/JsonShowModal.vue +12 -2
  76. package/vue-components/v2/navbar/Appdrawer.vue +10 -9
  77. package/vue-components/v2/navbar/ThemeMode.vue +50 -44
  78. package/vue-components/v2/navbar/User.vue +202 -19
  79. package/vue-components/v2/notification/Notification.vue +101 -0
  80. package/vue-components/v2/notification/NotificationItem.vue +44 -0
  81. package/vue-components/v2/preloader/Preloader.vue +5 -5
  82. package/vue-components/v2/sidebar/ClusterSwitcher.vue +126 -0
  83. package/vue-components/v2/sidebar/SidebarItem.vue +23 -1
  84. package/vue-components/v2/sidebar/SidebarItemWithDropDown.vue +19 -20
  85. package/vue-components/v2/tab/TabItem.vue +1 -1
  86. package/vue-components/v2/table/Table.vue +44 -8
  87. package/vue-components/v2/table/TableRow.vue +12 -2
  88. package/vue-components/v2/table/table-cell/CellValue.vue +33 -4
  89. package/vue-components/v2/table/table-cell/GenericCell.vue +56 -0
  90. package/vue-components/v2/table/table-cell/ObjectCell.vue +4 -1
  91. package/vue-components/v2/tabs/EditorTabs.vue +1 -1
  92. package/vue-components/v3/button/Button.vue +5 -0
  93. package/vue-components/v3/content/ContentTable.vue +5 -0
  94. package/vue-components/v3/editor/Editor.vue +50 -30
  95. package/vue-components/v3/editor/FilteredFileEditor.vue +184 -0
  96. package/vue-components/v3/editor/MonacoEditor.vue +131 -0
  97. package/vue-components/v3/editor/ResourceKeyValueEditor.vue +125 -0
  98. package/vue-components/v3/form/Form.vue +63 -0
  99. package/vue-components/v3/form-fields/Input.vue +10 -10
  100. package/vue-components/v3/header/HeaderItem.vue +5 -0
  101. package/vue-components/v3/header/HeaderItems.vue +5 -0
  102. package/vue-components/v3/loaders/ResourceLoader.vue +83 -0
  103. package/vue-components/v3/loaders/SidebarLoader.vue +34 -0
  104. package/vue-components/v3/long-running-tasks/LongRunningTaskItem.vue +92 -0
  105. package/vue-components/v3/modal/Modal.vue +40 -16
  106. package/vue-components/v3/modals/DeleteConfirmationModal.vue +83 -0
  107. package/vue-components/v3/modals/JsonShowModal.vue +25 -16
  108. package/vue-components/v3/modals/LongRunningTasksModal.vue +337 -0
  109. package/vue-components/v3/navbar/Appdrawer.vue +12 -7
  110. package/vue-components/v3/navbar/ThemeMode.vue +49 -47
  111. package/vue-components/v3/navbar/User.vue +190 -16
  112. package/vue-components/v3/notification/Notification.vue +98 -0
  113. package/vue-components/v3/notification/NotificationItem.vue +52 -0
  114. package/vue-components/v3/sidebar/ClusterSwitcher.vue +133 -0
  115. package/vue-components/v3/sidebar/SidebarItemWithDropDown.vue +120 -0
  116. package/vue-components/v3/table/MultiInfoTable.vue +143 -0
  117. package/vue-components/v3/table/Table.vue +35 -12
  118. package/vue-components/v3/table/TableContainer.vue +34 -0
  119. package/vue-components/v3/table/TableRow.vue +10 -2
  120. package/vue-components/v3/table/table-cell/CellValue.vue +26 -3
  121. package/vue-components/v3/table/table-cell/GenericCell.vue +62 -0
  122. package/vue-components/v3/table/table-cell/ObjectCell.vue +5 -1
  123. package/vue-components/v3/tabs/EditorTabs.vue +1 -1
  124. package/vue-components/v3/terminal/LongRunningTaskTerminal.vue +148 -0
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <div>
3
+ <content-loader
4
+ :width="100"
5
+ :height="40"
6
+ :speed="2"
7
+ :primaryColor="primaryLoaderColor"
8
+ :secondaryColor="secondaryLoaderColor"
9
+ >
10
+ <rect x="1" y="1" rx="1" ry="1" width="14" height="1" />
11
+ <rect x="17" y="1" rx="1" ry="1" width="13" height="1" />
12
+ <rect x="32" y="1" rx="1" ry="1" width="8" height="1" />
13
+
14
+ <rect x="7" y="3" rx="1" ry="1" width="14" height="1" />
15
+ <rect x="23" y="3" rx="1" ry="1" width="13" height="1" />
16
+ <rect x="38" y="3" rx="1" ry="1" width="8" height="1" />
17
+
18
+ <rect x="13" y="5" rx="1" ry="1" width="8" height="1" />
19
+ <rect x="23" y="5" rx="1" ry="1" width="15" height="1" />
20
+ <rect x="40" y="5" rx="1" ry="1" width="4" height="1" />
21
+
22
+ <rect x="13" y="7" rx="1" ry="1" width="10" height="1" />
23
+ <rect x="25" y="7" rx="1" ry="1" width="20" height="1" />
24
+
25
+ <rect x="7" y="10" rx="1" ry="1" width="14" height="1" />
26
+ <rect x="23" y="10" rx="1" ry="1" width="13" height="1" />
27
+ <rect x="38" y="10" rx="1" ry="1" width="8" height="1" />
28
+
29
+ <rect x="13" y="12" rx="1" ry="1" width="8" height="1" />
30
+ <rect x="23" y="12" rx="1" ry="1" width="15" height="1" />
31
+ <rect x="40" y="12" rx="1" ry="1" width="4" height="1" />
32
+
33
+ <rect x="13" y="14" rx="1" ry="1" width="10" height="1" />
34
+ <rect x="25" y="14" rx="1" ry="1" width="20" height="1" />
35
+
36
+ <rect x="7" y="17" rx="1" ry="1" width="14" height="1" />
37
+ <rect x="23" y="17" rx="1" ry="1" width="13" height="1" />
38
+ <rect x="38" y="17" rx="1" ry="1" width="8" height="1" />
39
+
40
+ <rect x="13" y="19" rx="1" ry="1" width="8" height="1" />
41
+ <rect x="23" y="19" rx="1" ry="1" width="15" height="1" />
42
+ <rect x="40" y="19" rx="1" ry="1" width="4" height="1" />
43
+
44
+ <rect x="7" y="22" rx="1" ry="1" width="14" height="1" />
45
+ <rect x="23" y="22" rx="1" ry="1" width="13" height="1" />
46
+ <rect x="38" y="22" rx="1" ry="1" width="8" height="1" />
47
+
48
+ <rect x="13" y="24" rx="1" ry="1" width="8" height="1" />
49
+ <rect x="23" y="24" rx="1" ry="1" width="15" height="1" />
50
+ <rect x="40" y="24" rx="1" ry="1" width="4" height="1" />
51
+
52
+ <rect x="1" y="26" rx="1" ry="1" width="14" height="1" />
53
+ <rect x="17" y="26" rx="1" ry="1" width="13" height="1" />
54
+ <rect x="32" y="26" rx="1" ry="1" width="8" height="1" />
55
+
56
+ <rect x="7" y="29" rx="1" ry="1" width="14" height="1" />
57
+ <rect x="23" y="29" rx="1" ry="1" width="13" height="1" />
58
+ <rect x="38" y="29" rx="1" ry="1" width="8" height="1" />
59
+
60
+ <rect x="13" y="31" rx="1" ry="1" width="8" height="1" />
61
+ <rect x="23" y="31" rx="1" ry="1" width="15" height="1" />
62
+ <rect x="40" y="31" rx="1" ry="1" width="4" height="1" />
63
+
64
+ <rect x="7" y="33" rx="1" ry="1" width="14" height="1" />
65
+ <rect x="23" y="33" rx="1" ry="1" width="13" height="1" />
66
+ <rect x="38" y="33" rx="1" ry="1" width="8" height="1" />
67
+
68
+ <rect x="13" y="35" rx="1" ry="1" width="8" height="1" />
69
+ <rect x="23" y="35" rx="1" ry="1" width="15" height="1" />
70
+ <rect x="40" y="35" rx="1" ry="1" width="4" height="1" />
71
+
72
+ <rect x="13" y="37" rx="1" ry="1" width="8" height="1" />
73
+ <rect x="23" y="37" rx="1" ry="1" width="15" height="1" />
74
+ <rect x="40" y="37" rx="1" ry="1" width="4" height="1" />
75
+
76
+ <rect x="1" y="39" rx="1" ry="1" width="14" height="1" />
77
+ <rect x="17" y="39" rx="1" ry="1" width="13" height="1" />
78
+ <rect x="32" y="39" rx="1" ry="1" width="8" height="1" />
79
+ </content-loader>
80
+ </div>
81
+ </template>
82
+
83
+ <script>
84
+ import { ContentLoader } from "vue-content-loader";
85
+
86
+ export default {
87
+ components: {
88
+ ContentLoader
89
+ },
90
+ props: {
91
+ primaryLoaderColor: {
92
+ type: String,
93
+ default: "#f5f7f9"
94
+ },
95
+ secondaryLoaderColor: {
96
+ type: String,
97
+ default: "#ecebeb"
98
+ }
99
+ }
100
+ };
101
+ </script>
@@ -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>
@@ -6,7 +6,7 @@
6
6
  v-if="showModal"
7
7
  class="ac-modal is-middle-alignment"
8
8
  :class="modifierClasses"
9
- @click.self="destroyModal"
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
- :icon-image="require('@/assets/images/icons/close-icon.svg')"
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,7 @@
26
30
  <!-- modal header end -->
27
31
 
28
32
  <!-- modal body start -->
29
- <div class="ac-modal-body">
33
+ <div class="ac-modal-body ac-vscrollbar">
30
34
  <div class="ac-modal-content">
31
35
  <!-- freedom content start -->
32
36
  <slot />
@@ -36,7 +40,17 @@
36
40
  <!-- modal body end -->
37
41
 
38
42
  <!-- modal footer start -->
39
- <div class="ac-modal-footer action-footer">
43
+ <div
44
+ v-if="!hideActionFooter"
45
+ class="
46
+ ac-modal-footer
47
+ action-footer
48
+ is-flex is-align-items-center is-justify-content-space-between
49
+ "
50
+ >
51
+ <div>
52
+ <slot name="modal-footer-left" />
53
+ </div>
40
54
  <buttons class="has-text-right is-block">
41
55
  <slot name="modal-footer-controls" />
42
56
  </buttons>
@@ -62,6 +76,18 @@ export default {
62
76
  type: String,
63
77
  default: "",
64
78
  },
79
+ isCloseOptionDisabled: {
80
+ type: Boolean,
81
+ default: false,
82
+ },
83
+ ignoreOutsideClick: {
84
+ type: Boolean,
85
+ default: false,
86
+ },
87
+ hideActionFooter: {
88
+ type: Boolean,
89
+ default: false,
90
+ },
65
91
  },
66
92
 
67
93
  components: {
@@ -97,11 +123,16 @@ export default {
97
123
  this.destroyModal();
98
124
  }
99
125
  },
126
+ onModalOutsideClick() {
127
+ if (this.ignoreOutsideClick) return;
128
+ this.destroyModal();
129
+ },
100
130
  initializeModal() {
101
131
  this.showModal = true;
102
132
  document.addEventListener("keydown", this.onKeyDown);
103
133
  },
104
134
  destroyModal() {
135
+ if (this.isCloseOptionDisabled) return;
105
136
  this.showModal = false;
106
137
  document.removeEventListener("keydown", this.onKeyDown);
107
138
 
@@ -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>
@@ -10,7 +10,9 @@
10
10
  <ac-button
11
11
  modifier-classes="is-square is-primary"
12
12
  icon-class="copy"
13
- v-clipboard:copy="`${editorTitle}: &quot;${editorContent}&quot;`"
13
+ v-clipboard:copy="
14
+ `${editorTitle}: ${JSON.stringify(parsedContent, null, 4)}`
15
+ "
14
16
  v-clipboard:success="onCopy"
15
17
  v-clipboard:error="onError"
16
18
  />
@@ -26,6 +28,8 @@
26
28
  </template>
27
29
 
28
30
  <script>
31
+ import Preloader from "../preloader/Preloader.vue";
32
+ import Banner from "../banner/Banner.vue";
29
33
  export default {
30
34
  props: {
31
35
  open: {
@@ -43,7 +47,13 @@ export default {
43
47
  },
44
48
  components: {
45
49
  Modal: () => import("../modal/Modal.vue"),
46
- Editor: () => import("../editor/Editor.vue"),
50
+ Editor: () => ({
51
+ component: import("../editor/Editor.vue"),
52
+ loading: Preloader,
53
+ delay: 200,
54
+ error: Banner,
55
+ timeout: 100000,
56
+ }),
47
57
  AcButton: () => import("../button/Button.vue"),
48
58
  HeaderItem: () => import("../header/HeaderItem.vue"),
49
59
  },
@@ -1,10 +1,13 @@
1
1
  <template>
2
- <div class="app-drawer-wrapper d-table-cell">
3
- <div class="drawer-icon">
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>
@@ -1,38 +1,49 @@
1
1
  <template>
2
- <button v-if="themeMode" class="button ac-nav-button" @click="toggleTheme" :title="themeModeIconTooltip" >
3
- <i :class="`fa ${themeModeIconClass} width-15`" />
4
- </button>
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>
5
26
  </template>
6
27
  <script>
7
28
  export default {
8
29
  data() {
9
30
  return {
10
31
  themeMode: "",
11
- };
12
- },
13
-
14
- computed: {
15
- // to set icon class for theme mode
16
- themeModeIconClass() {
17
- if(this.themeMode === "system") {
18
- return "fa-desktop";
19
- } else if(this.themeMode === "light") {
20
- return "fa-sun-o";
21
- } else if(this.themeMode === "dark") {
22
- return "fa-moon-o";
23
- }
24
- },
25
-
26
- // to set icon tooltip for theme mode
27
- themeModeIconTooltip() {
28
- if(this.themeMode === "system") {
29
- return "System theme";
30
- } else if(this.themeMode === "light") {
31
- return "Light theme";
32
- } else if(this.themeMode === "dark") {
33
- return "Dark theme";
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
+ }
34
45
  }
35
- }
46
+ };
36
47
  },
37
48
 
38
49
  mounted() {
@@ -55,12 +66,9 @@ export default {
55
66
  methods: {
56
67
  // handle theme mode button click
57
68
  toggleTheme() {
58
- if(this.themeMode === "light")
59
- this.themeMode = "dark";
60
- else if(this.themeMode === "dark")
61
- this.themeMode = "system";
62
- else if(this.themeMode === "system")
63
- this.themeMode = "light";
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";
64
72
  },
65
73
 
66
74
  // triggered when theme mode is updated
@@ -68,8 +76,10 @@ export default {
68
76
  localStorage.setItem("themeMode", n);
69
77
 
70
78
  let theme = n;
71
- if(n === "system") {
72
- const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
79
+ if (n === "system") {
80
+ const isDarkMode =
81
+ window.matchMedia &&
82
+ window.matchMedia("(prefers-color-scheme: dark)").matches;
73
83
  this.addColorSchemeEventListener();
74
84
  theme = isDarkMode ? "dark" : "light";
75
85
  } else {
@@ -81,7 +91,7 @@ export default {
81
91
 
82
92
  // add proper css class to update the ui theme
83
93
  handleDarkThemeClass(currentTheme) {
84
- if(currentTheme === "light") {
94
+ if (currentTheme === "light") {
85
95
  document.documentElement.classList.remove("is-dark-theme");
86
96
  } else {
87
97
  document.documentElement.classList.add("is-dark-theme");
@@ -92,23 +102,19 @@ export default {
92
102
  addColorSchemeEventListener() {
93
103
  window
94
104
  .matchMedia("(prefers-color-scheme: dark)")
95
- .addEventListener(
96
- "change", this.handleSystemThemeChange
97
- );
105
+ .addEventListener("change", this.handleSystemThemeChange);
98
106
  },
99
107
 
100
108
  // remove system theme listener event
101
109
  removeColorSchemeEventListener() {
102
110
  window
103
111
  .matchMedia("(prefers-color-scheme: dark)")
104
- .removeEventListener(
105
- "change", this.handleSystemThemeChange
106
- );
112
+ .removeEventListener("change", this.handleSystemThemeChange);
107
113
  },
108
114
 
109
115
  handleSystemThemeChange() {
110
116
  this.onThemeModeChange(this.themeMode);
111
- },
117
+ }
112
118
  }
113
- }
119
+ };
114
120
  </script>