@code-coaching/vuetiful 0.0.0
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/README.md +143 -0
- package/dist/style.css +1 -0
- package/dist/styles/all.css +4645 -0
- package/dist/types/components/atoms/VButton.vue.d.ts +86 -0
- package/dist/types/components/atoms/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/constants/MyConstants.d.ts +1 -0
- package/dist/types/constants/index.d.ts +2 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/tailwind.d.ts +4 -0
- package/dist/types/utils/MyUtil.d.ts +5 -0
- package/dist/types/utils/dark-mode/dark-mode.d.ts +18 -0
- package/dist/types/utils/dark-mode/dark-mode.vue.d.ts +91 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/dist/types/utils/platform/platform.d.ts +4 -0
- package/dist/types/utils/theme/theme-switcher.vue.d.ts +106 -0
- package/dist/types/utils/theme/theme.d.ts +9 -0
- package/dist/vuetiful.es.mjs +515 -0
- package/dist/vuetiful.umd.js +17 -0
- package/package.json +47 -0
- package/src/assets/fonts/myfont.woff +0 -0
- package/src/assets/main.css +17 -0
- package/src/components/atoms/VButton.vue +78 -0
- package/src/components/atoms/index.ts +3 -0
- package/src/components/index.ts +3 -0
- package/src/constants/MyConstants.ts +1 -0
- package/src/constants/index.ts +5 -0
- package/src/env.d.ts +8 -0
- package/src/index.ts +29 -0
- package/src/styles/all.css +21 -0
- package/src/styles/core.css +65 -0
- package/src/styles/elements/alerts.css +17 -0
- package/src/styles/elements/badges.css +31 -0
- package/src/styles/elements/breadcrumbs.css +26 -0
- package/src/styles/elements/buttons.css +103 -0
- package/src/styles/elements/cards.css +32 -0
- package/src/styles/elements/chips.css +22 -0
- package/src/styles/elements/forms.css +268 -0
- package/src/styles/elements/lists.css +48 -0
- package/src/styles/elements/logo-clouds.css +29 -0
- package/src/styles/elements/modals.css +15 -0
- package/src/styles/elements/placeholders.css +17 -0
- package/src/styles/elements/popups.css +16 -0
- package/src/styles/elements/tables.css +102 -0
- package/src/styles/elements.css +19 -0
- package/src/styles/highlight-js.css +116 -0
- package/src/styles/tailwind.css +16 -0
- package/src/styles/typography.css +101 -0
- package/src/styles/variants.css +156 -0
- package/src/tailwind/core.cjs +37 -0
- package/src/tailwind/generated/intellisense-classes.cjs +558 -0
- package/src/tailwind/intellisense.cjs +21 -0
- package/src/tailwind/settings.cjs +20 -0
- package/src/tailwind/theme/colors.cjs +20 -0
- package/src/tailwind/tokens/backgrounds.cjs +48 -0
- package/src/tailwind/tokens/border-radius.cjs +21 -0
- package/src/tailwind/tokens/borders.cjs +24 -0
- package/src/tailwind/tokens/fills.cjs +20 -0
- package/src/tailwind/tokens/rings.cjs +50 -0
- package/src/tailwind/tokens/text.cjs +35 -0
- package/src/tailwind/vuetiful.cjs +19 -0
- package/src/themes/theme-modern.css +127 -0
- package/src/themes/theme-rocket.css +119 -0
- package/src/themes/theme-sahara.css +128 -0
- package/src/themes/theme-seafoam.css +121 -0
- package/src/themes/theme-seasonal.css +115 -0
- package/src/themes/theme-vintage.css +125 -0
- package/src/themes/theme-vuetiful.css +118 -0
- package/src/types/index.ts +1 -0
- package/src/types/tailwind.ts +7 -0
- package/src/utils/MyUtil.ts +7 -0
- package/src/utils/dark-mode/dark-mode.ts +90 -0
- package/src/utils/dark-mode/dark-mode.vue +133 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/platform/platform.ts +10 -0
- package/src/utils/theme/theme-switcher.vue +155 -0
- package/src/utils/theme/theme.ts +65 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="cc-theme-switcher">
|
|
3
|
+
<VButton :class="`cc-theme-switcher__button ${buttonClasses}`" @click="showPopup = !showPopup">
|
|
4
|
+
Theme
|
|
5
|
+
</VButton>
|
|
6
|
+
|
|
7
|
+
<div v-if="showPopup" class="cc-theme-switcher__popup p-4 shadow-xl" :class="classes">
|
|
8
|
+
<div class="space-y-4">
|
|
9
|
+
<section class="flex items-center justify-between">
|
|
10
|
+
<h6>Mode</h6>
|
|
11
|
+
<DarkModeSwitch />
|
|
12
|
+
</section>
|
|
13
|
+
<nav class="list-nav -m-4 overflow-y-auto p-4" :class="listClasses">
|
|
14
|
+
<ul class="flex flex-col gap-4">
|
|
15
|
+
<li
|
|
16
|
+
class="h-full w-full p-2 text-center capitalize hover:cursor-pointer hover:bg-primary-100 hover:text-primary-900"
|
|
17
|
+
:class="`${listItemClasses} ${
|
|
18
|
+
chosenTheme === theme
|
|
19
|
+
? 'bg-primary-50 text-primary-900'
|
|
20
|
+
: 'bg-surface-200 text-surface-900'
|
|
21
|
+
}`"
|
|
22
|
+
v-for="(theme, index) in themes"
|
|
23
|
+
:key="index"
|
|
24
|
+
@click="loadTheme(theme)"
|
|
25
|
+
>
|
|
26
|
+
{{ theme }}
|
|
27
|
+
</li>
|
|
28
|
+
</ul>
|
|
29
|
+
</nav>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script lang="ts">
|
|
36
|
+
import { CssClasses, DarkModeSwitch, useDarkMode, useTheme, VButton } from "@/index";
|
|
37
|
+
import { computed, defineComponent, onMounted, ref } from "vue";
|
|
38
|
+
|
|
39
|
+
export default defineComponent({
|
|
40
|
+
components: {
|
|
41
|
+
DarkModeSwitch,
|
|
42
|
+
VButton,
|
|
43
|
+
},
|
|
44
|
+
props: {
|
|
45
|
+
bgLight: {
|
|
46
|
+
type: String as () => CssClasses,
|
|
47
|
+
default: "bg-surface-50",
|
|
48
|
+
},
|
|
49
|
+
bgDark: {
|
|
50
|
+
type: String as () => CssClasses,
|
|
51
|
+
default: "bg-surface-900",
|
|
52
|
+
},
|
|
53
|
+
textOnLight: {
|
|
54
|
+
type: String as () => CssClasses,
|
|
55
|
+
default: "text-surface-900",
|
|
56
|
+
},
|
|
57
|
+
textOnDark: {
|
|
58
|
+
type: String as () => CssClasses,
|
|
59
|
+
default: "text-surface-50",
|
|
60
|
+
},
|
|
61
|
+
width: {
|
|
62
|
+
type: String as () => CssClasses,
|
|
63
|
+
default: "w-60",
|
|
64
|
+
},
|
|
65
|
+
height: {
|
|
66
|
+
type: String as () => CssClasses,
|
|
67
|
+
default: "max-h-64 lg:max-h-[500px]",
|
|
68
|
+
},
|
|
69
|
+
ring: {
|
|
70
|
+
type: String as () => CssClasses,
|
|
71
|
+
default: "ring-[1px] ring-surface-500/30",
|
|
72
|
+
},
|
|
73
|
+
rounded: {
|
|
74
|
+
type: String as () => CssClasses,
|
|
75
|
+
default: "rounded-token",
|
|
76
|
+
},
|
|
77
|
+
roundedContainer: {
|
|
78
|
+
type: String as () => CssClasses,
|
|
79
|
+
default: "rounded-container-token",
|
|
80
|
+
},
|
|
81
|
+
buttonClasses: {
|
|
82
|
+
type: String as () => CssClasses,
|
|
83
|
+
default: "w-24",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
setup(props, { attrs }) {
|
|
87
|
+
const { initializeTheme, loadTheme, themes, chosenTheme } = useTheme();
|
|
88
|
+
const { currentMode, MODE } = useDarkMode();
|
|
89
|
+
|
|
90
|
+
const showPopup = ref(false);
|
|
91
|
+
onMounted(() => {
|
|
92
|
+
initializeTheme();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const cTransition = `transition-all duration-[200ms]`;
|
|
96
|
+
|
|
97
|
+
type OnKeyDownEvent = KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement };
|
|
98
|
+
function onKeyDown(event: KeyboardEvent): void {
|
|
99
|
+
if (["Enter", "Space"].includes(event.code)) {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
(event as OnKeyDownEvent).currentTarget.click();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const background = computed(() => {
|
|
106
|
+
return currentMode.value === MODE.LIGHT ? props.bgLight : props.bgDark;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const text = computed(() => {
|
|
110
|
+
return currentMode.value === MODE.LIGHT ? props.textOnLight : props.textOnDark;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const classes = computed(() => {
|
|
114
|
+
return `${cTransition}
|
|
115
|
+
${background.value}
|
|
116
|
+
${text.value}
|
|
117
|
+
${props.width}
|
|
118
|
+
${props.ring}
|
|
119
|
+
${props.roundedContainer}
|
|
120
|
+
${attrs.class ?? ""}`;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const listClasses = computed(() => {
|
|
124
|
+
return `${cTransition}
|
|
125
|
+
${props.height}`;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const listItemClasses = computed(() => {
|
|
129
|
+
return `${cTransition}
|
|
130
|
+
${props.ring}
|
|
131
|
+
${props.rounded}`;
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
onKeyDown,
|
|
136
|
+
loadTheme,
|
|
137
|
+
currentMode,
|
|
138
|
+
classes,
|
|
139
|
+
chosenTheme,
|
|
140
|
+
themes,
|
|
141
|
+
showPopup,
|
|
142
|
+
listClasses,
|
|
143
|
+
listItemClasses,
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
</script>
|
|
148
|
+
|
|
149
|
+
<style scoped>
|
|
150
|
+
.cc-theme-switcher__popup {
|
|
151
|
+
position: absolute;
|
|
152
|
+
z-index: 1;
|
|
153
|
+
margin-top: 0.25rem;
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readonly, ref } from "vue";
|
|
2
|
+
import { usePlatform } from "../platform/platform";
|
|
3
|
+
|
|
4
|
+
const { isBrowser } = usePlatform();
|
|
5
|
+
const chosenTheme = ref("vuetiful");
|
|
6
|
+
|
|
7
|
+
const useTheme = () => {
|
|
8
|
+
const themes = ["vuetiful", "modern", "rocket", "sahara", "seafoam", "seasonal", "vintage"];
|
|
9
|
+
const theme = ref("vuetiful");
|
|
10
|
+
|
|
11
|
+
const setTheme = (name: string): void => {
|
|
12
|
+
theme.value = name;
|
|
13
|
+
if (isBrowser) {
|
|
14
|
+
localStorage.setItem("vuetiful-theme", name);
|
|
15
|
+
applyTheme(name);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const applyTheme = (name: string): void => {
|
|
20
|
+
document.body.setAttribute("data-theme", name);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const initializeTheme = (callback?: Function): void => {
|
|
24
|
+
if (isBrowser) {
|
|
25
|
+
const themeName = localStorage.getItem("vuetiful-theme") ?? "vuetiful";
|
|
26
|
+
if (themeName) loadTheme(themeName, callback);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const loadTheme = (theme: string, callback?: Function) => {
|
|
31
|
+
chosenTheme.value = theme;
|
|
32
|
+
const existingStyle = document.getElementById("theme");
|
|
33
|
+
|
|
34
|
+
const themeUrl = `https://code-coaching.dev/vuetiful-themes/theme-${theme}.css`;
|
|
35
|
+
|
|
36
|
+
const link = document.createElement("link");
|
|
37
|
+
link.id = "theme";
|
|
38
|
+
link.href = themeUrl;
|
|
39
|
+
link.type = "text/css";
|
|
40
|
+
link.rel = "stylesheet";
|
|
41
|
+
link.onload = () => {
|
|
42
|
+
if (existingStyle) existingStyle.remove();
|
|
43
|
+
setTheme(theme);
|
|
44
|
+
if (callback) {
|
|
45
|
+
callback();
|
|
46
|
+
console.log("callback")
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const head = document.querySelector("head");
|
|
51
|
+
if (head) head.appendChild(link);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
theme: readonly(theme),
|
|
56
|
+
themes: readonly(themes),
|
|
57
|
+
chosenTheme: readonly(chosenTheme),
|
|
58
|
+
|
|
59
|
+
setTheme,
|
|
60
|
+
initializeTheme,
|
|
61
|
+
loadTheme,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { useTheme };
|