@code-coaching/vuetiful 0.23.0 → 0.23.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-coaching/vuetiful",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "onchange 'src/**/*.vue' 'src/**/*.ts' 'src/**/*.css' -- npm run build",
@@ -1,150 +1,80 @@
1
1
  <template>
2
- <div class="cc-theme-switcher">
3
- <VButton :class="`cc-theme-switcher__button ${buttonClasses}`" @click="showPopup = !showPopup">
2
+ <div class="vuetiful-theme-switcher">
3
+ <v-button
4
+ :class="`vuetiful-theme-switcher__button ${classButton}`"
5
+ @click="showPopup = !showPopup"
6
+ >
4
7
  Theme
5
- </VButton>
8
+ </v-button>
6
9
 
7
10
  <div
8
11
  v-if="showPopup"
9
- class="cc-theme-switcher__popup absolute z-10 mt-1 p-4 shadow-xl"
10
- :class="classes"
12
+ class="vuetiful-theme-switcher__popup absolute z-10 mt-1 space-y-4 p-4 shadow-xl rounded-container-token"
13
+ :class="`${background} ${text} ${widthPopup} ${classList}`"
11
14
  >
12
- <div class="space-y-4">
13
- <section class="flex items-center justify-between">
14
- <h6>Mode</h6>
15
- <v-light-switch />
16
- </section>
17
- <nav class="list-nav -m-4 overflow-y-auto p-4" :class="listClasses">
18
- <ul class="flex flex-col gap-4">
19
- <li
20
- class="h-full w-full p-2 text-center capitalize hover:cursor-pointer hover:bg-primary-100 hover:text-primary-900"
21
- :class="`${listItemClasses} ${
22
- chosenTheme === theme.name
23
- ? 'bg-primary-50 text-primary-900'
24
- : 'bg-surface-200 text-surface-900'
25
- }`"
26
- v-for="(theme, index) in themes"
27
- :key="index"
28
- @click="loadTheme(theme.name)"
29
- >
30
- {{ theme.name }}
31
- </li>
32
- </ul>
33
- </nav>
34
- </div>
15
+ <section class="flex items-center justify-between">
16
+ <div class="text-lg">Mode</div>
17
+ <v-light-switch />
18
+ </section>
19
+ <nav
20
+ class="vuetiful-theme-switcher__popup-list -m-4 flex flex-col gap-4 overflow-y-auto p-4"
21
+ :class="`${heightList} ${classList}`"
22
+ >
23
+ <v-button
24
+ class="vuetiful-theme-switcher__popup-list-item h-full w-full p-2 text-center capitalize hover:cursor-pointer"
25
+ v-for="(theme, index) in themes"
26
+ :class="`${classListItem} ${chosenTheme === theme.name ? 'variant-filled-surface' : ''}`"
27
+ :key="index"
28
+ @click="loadTheme(theme.name)"
29
+ >
30
+ {{ theme.name }}
31
+ </v-button>
32
+ </nav>
35
33
  </div>
36
34
  </div>
37
35
  </template>
38
36
 
39
- <script lang="ts">
40
- import { CssClasses, useDarkMode, useTheme, VButton, VLightSwitch } from "@/index";
41
- import { computed, defineComponent, onMounted, ref } from "vue";
37
+ <script setup lang="ts">
38
+ import { CssClasses, useTheme, VButton, VLightSwitch } from "@/index";
39
+ import { onMounted, ref } from "vue";
42
40
 
43
- export default defineComponent({
44
- components: {
45
- VLightSwitch,
46
- VButton,
41
+ defineProps({
42
+ background: {
43
+ type: String as () => CssClasses,
44
+ default: "bg-surface-50-900-token",
47
45
  },
48
- props: {
49
- bgLight: {
50
- type: String as () => CssClasses,
51
- default: "bg-surface-50",
52
- },
53
- bgDark: {
54
- type: String as () => CssClasses,
55
- default: "bg-surface-900",
56
- },
57
- textOnLight: {
58
- type: String as () => CssClasses,
59
- default: "text-surface-900",
60
- },
61
- textOnDark: {
62
- type: String as () => CssClasses,
63
- default: "text-surface-50",
64
- },
65
- width: {
66
- type: String as () => CssClasses,
67
- default: "w-60",
68
- },
69
- height: {
70
- type: String as () => CssClasses,
71
- default: "max-h-64 lg:max-h-[500px]",
72
- },
73
- ring: {
74
- type: String as () => CssClasses,
75
- default: "ring-[1px] ring-surface-500/30",
76
- },
77
- rounded: {
78
- type: String as () => CssClasses,
79
- default: "rounded-token",
80
- },
81
- roundedContainer: {
82
- type: String as () => CssClasses,
83
- default: "rounded-container-token",
84
- },
85
- buttonClasses: {
86
- type: String as () => CssClasses,
87
- default: "w-24",
88
- },
46
+ text: {
47
+ type: String as () => CssClasses,
48
+ default: "text-surface-900-50-token",
89
49
  },
90
- setup(props) {
91
- const { initializeTheme, loadTheme, themes, chosenTheme } = useTheme();
92
- const { currentMode, MODE } = useDarkMode();
93
-
94
- const showPopup = ref(false);
95
- onMounted(() => {
96
- initializeTheme();
97
- });
98
-
99
- const cTransition = `transition-all duration-[200ms]`;
100
-
101
- type OnKeyDownEvent = KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement };
102
- function onKeyDown(event: KeyboardEvent): void {
103
- if (["Enter", "Space"].includes(event.code)) {
104
- event.preventDefault();
105
- (event as OnKeyDownEvent).currentTarget.click();
106
- }
107
- }
108
50
 
109
- const background = computed(() => {
110
- return currentMode.value === MODE.LIGHT ? props.bgLight : props.bgDark;
111
- });
112
-
113
- const text = computed(() => {
114
- return currentMode.value === MODE.LIGHT ? props.textOnLight : props.textOnDark;
115
- });
116
-
117
- const classes = computed(() => {
118
- return `${cTransition}
119
- ${background.value}
120
- ${text.value}
121
- ${props.width}
122
- ${props.ring}
123
- ${props.roundedContainer}`;
124
- });
51
+ widthPopup: {
52
+ type: String as () => CssClasses,
53
+ default: "w-60",
54
+ },
55
+ heightList: {
56
+ type: String as () => CssClasses,
57
+ default: "max-h-64 lg:max-h-[500px]",
58
+ },
125
59
 
126
- const listClasses = computed(() => {
127
- return `${cTransition}
128
- ${props.height}`;
129
- });
60
+ classButton: {
61
+ type: String as () => CssClasses,
62
+ default: "",
63
+ },
64
+ classList: {
65
+ type: String as () => CssClasses,
66
+ default: "",
67
+ },
68
+ classListItem: {
69
+ type: String as () => CssClasses,
70
+ default: "",
71
+ },
72
+ });
130
73
 
131
- const listItemClasses = computed(() => {
132
- return `${cTransition}
133
- ${props.ring}
134
- ${props.rounded}`;
135
- });
74
+ const { initializeTheme, loadTheme, themes, chosenTheme } = useTheme();
136
75
 
137
- return {
138
- onKeyDown,
139
- loadTheme,
140
- currentMode,
141
- classes,
142
- chosenTheme,
143
- themes,
144
- showPopup,
145
- listClasses,
146
- listItemClasses,
147
- };
148
- },
76
+ const showPopup = ref(false);
77
+ onMounted(() => {
78
+ initializeTheme();
149
79
  });
150
80
  </script>