@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,515 @@
|
|
|
1
|
+
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, Fragment, createTextVNode, toDisplayString, createCommentVNode, renderSlot, ref, readonly, onMounted, createElementVNode, resolveComponent, createVNode, withCtx, renderList, pushScopeId, popScopeId } from "vue";
|
|
2
|
+
var _export_sfc = (sfc, props) => {
|
|
3
|
+
const target = sfc.__vccOpts || sfc;
|
|
4
|
+
for (const [key, val] of props) {
|
|
5
|
+
target[key] = val;
|
|
6
|
+
}
|
|
7
|
+
return target;
|
|
8
|
+
};
|
|
9
|
+
const _sfc_main$2 = defineComponent({
|
|
10
|
+
props: {
|
|
11
|
+
bgLight: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: "bg-primary-50"
|
|
14
|
+
},
|
|
15
|
+
bgDark: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: "bg-primary-900"
|
|
18
|
+
},
|
|
19
|
+
textOnLight: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "text-primary-900"
|
|
22
|
+
},
|
|
23
|
+
textOnDark: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "text-primary-50"
|
|
26
|
+
},
|
|
27
|
+
width: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "w-fit"
|
|
30
|
+
},
|
|
31
|
+
height: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "h-fit"
|
|
34
|
+
},
|
|
35
|
+
ring: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "ring-[1px] ring-primary-500/30"
|
|
38
|
+
},
|
|
39
|
+
rounded: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: "rounded-token"
|
|
42
|
+
},
|
|
43
|
+
msg: {
|
|
44
|
+
type: String
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
setup(props, { attrs }) {
|
|
48
|
+
const { currentMode: currentMode2, MODE: MODE2 } = useDarkMode();
|
|
49
|
+
const cTransition = `transition-all duration-[200ms]`;
|
|
50
|
+
const background = computed(() => {
|
|
51
|
+
return currentMode2.value === MODE2.LIGHT ? props.bgLight : props.bgDark;
|
|
52
|
+
});
|
|
53
|
+
const text = computed(() => {
|
|
54
|
+
return currentMode2.value === MODE2.LIGHT ? props.textOnLight : props.textOnDark;
|
|
55
|
+
});
|
|
56
|
+
const classes = computed(() => {
|
|
57
|
+
var _a;
|
|
58
|
+
return `${cTransition}
|
|
59
|
+
${background.value}
|
|
60
|
+
${text.value}
|
|
61
|
+
${props.width}
|
|
62
|
+
${props.height}
|
|
63
|
+
${props.ring}
|
|
64
|
+
${props.rounded}
|
|
65
|
+
${(_a = attrs.class) != null ? _a : ""}`;
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
classes
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
73
|
+
return openBlock(), createElementBlock("button", {
|
|
74
|
+
class: normalizeClass(`cc-button btn ${_ctx.classes}`)
|
|
75
|
+
}, [
|
|
76
|
+
_ctx.msg ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
77
|
+
createTextVNode(toDisplayString(_ctx.msg), 1)
|
|
78
|
+
], 64)) : createCommentVNode("", true),
|
|
79
|
+
renderSlot(_ctx.$slots, "default")
|
|
80
|
+
], 2);
|
|
81
|
+
}
|
|
82
|
+
var VButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
83
|
+
var components = /* @__PURE__ */ Object.freeze({
|
|
84
|
+
__proto__: null,
|
|
85
|
+
[Symbol.toStringTag]: "Module",
|
|
86
|
+
VButton
|
|
87
|
+
});
|
|
88
|
+
var main = "";
|
|
89
|
+
var tailwind = "";
|
|
90
|
+
var themeVuetiful = "";
|
|
91
|
+
const MAGIC_NUM = 100;
|
|
92
|
+
var MyConstants = /* @__PURE__ */ Object.freeze({
|
|
93
|
+
__proto__: null,
|
|
94
|
+
[Symbol.toStringTag]: "Module",
|
|
95
|
+
MAGIC_NUM
|
|
96
|
+
});
|
|
97
|
+
const usePlatform = () => {
|
|
98
|
+
const isBrowser2 = typeof window !== "undefined";
|
|
99
|
+
return {
|
|
100
|
+
isBrowser: isBrowser2
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const { isBrowser: isBrowser$1 } = usePlatform();
|
|
104
|
+
const MODE = {
|
|
105
|
+
LIGHT: true,
|
|
106
|
+
DARK: false
|
|
107
|
+
};
|
|
108
|
+
const modeOsPrefers = ref(MODE.DARK);
|
|
109
|
+
const currentMode = ref(MODE.DARK);
|
|
110
|
+
const modeUserPrefers = ref(void 0);
|
|
111
|
+
const useDarkMode = () => {
|
|
112
|
+
const getModeOsPrefers = () => {
|
|
113
|
+
const prefersLightMode = window.matchMedia("(prefers-color-scheme: light)").matches;
|
|
114
|
+
setModeOsPrefers(prefersLightMode);
|
|
115
|
+
return prefersLightMode;
|
|
116
|
+
};
|
|
117
|
+
const getModeUserPrefers = () => {
|
|
118
|
+
if (isBrowser$1) {
|
|
119
|
+
const mode = localStorage.getItem("modeUserPrefers");
|
|
120
|
+
if (mode !== null)
|
|
121
|
+
modeUserPrefers.value = mode === "true";
|
|
122
|
+
}
|
|
123
|
+
return modeUserPrefers.value;
|
|
124
|
+
};
|
|
125
|
+
const getModeAutoPrefers = () => {
|
|
126
|
+
const os = getModeOsPrefers();
|
|
127
|
+
const user = getModeUserPrefers();
|
|
128
|
+
const modeValue = user !== void 0 ? user : os;
|
|
129
|
+
return modeValue;
|
|
130
|
+
};
|
|
131
|
+
const setModeOsPrefers = (value) => {
|
|
132
|
+
modeOsPrefers.value = value;
|
|
133
|
+
if (isBrowser$1) {
|
|
134
|
+
localStorage.setItem("modeOsPrefers", value.toString());
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const setModeUserPrefers = (value) => {
|
|
138
|
+
modeUserPrefers.value = value;
|
|
139
|
+
if (isBrowser$1) {
|
|
140
|
+
localStorage.setItem("modeUserPrefers", value.toString());
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const setModeCurrent = (value) => {
|
|
144
|
+
const elemHtmlClasses = document.documentElement.classList;
|
|
145
|
+
const classDark = "dark";
|
|
146
|
+
value === MODE.LIGHT ? elemHtmlClasses.remove(classDark) : elemHtmlClasses.add(classDark);
|
|
147
|
+
currentMode.value = value;
|
|
148
|
+
};
|
|
149
|
+
const initializeMode = () => {
|
|
150
|
+
const mode = getModeAutoPrefers();
|
|
151
|
+
setModeCurrent(mode);
|
|
152
|
+
};
|
|
153
|
+
const autoModeWatcher = () => {
|
|
154
|
+
const mql = window.matchMedia("(prefers-color-scheme: light)");
|
|
155
|
+
const setMode = (value) => {
|
|
156
|
+
const elemHtmlClasses = document.documentElement.classList;
|
|
157
|
+
const classDark = `dark`;
|
|
158
|
+
value === MODE.LIGHT ? elemHtmlClasses.remove(classDark) : elemHtmlClasses.add(classDark);
|
|
159
|
+
};
|
|
160
|
+
setMode(mql.matches);
|
|
161
|
+
mql.onchange = () => {
|
|
162
|
+
setMode(mql.matches);
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
modeOsPrefers: readonly(modeOsPrefers),
|
|
167
|
+
modeUserPrefers: readonly(modeUserPrefers),
|
|
168
|
+
currentMode: readonly(currentMode),
|
|
169
|
+
getModeOsPrefers,
|
|
170
|
+
getModeUserPrefers,
|
|
171
|
+
getModeAutoPrefers,
|
|
172
|
+
setModeUserPrefers,
|
|
173
|
+
setModeCurrent,
|
|
174
|
+
autoModeWatcher,
|
|
175
|
+
initializeMode,
|
|
176
|
+
MODE
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
const _sfc_main$1 = defineComponent({
|
|
180
|
+
props: {
|
|
181
|
+
bgLight: {
|
|
182
|
+
type: String,
|
|
183
|
+
default: "bg-surface-50"
|
|
184
|
+
},
|
|
185
|
+
bgDark: {
|
|
186
|
+
type: String,
|
|
187
|
+
default: "bg-surface-900"
|
|
188
|
+
},
|
|
189
|
+
textLight: {
|
|
190
|
+
type: String,
|
|
191
|
+
default: "text-surface-50"
|
|
192
|
+
},
|
|
193
|
+
textDark: {
|
|
194
|
+
type: String,
|
|
195
|
+
default: "text-surface-900"
|
|
196
|
+
},
|
|
197
|
+
width: {
|
|
198
|
+
type: String,
|
|
199
|
+
default: "w-12"
|
|
200
|
+
},
|
|
201
|
+
height: {
|
|
202
|
+
type: String,
|
|
203
|
+
default: "h-6"
|
|
204
|
+
},
|
|
205
|
+
ring: {
|
|
206
|
+
type: String,
|
|
207
|
+
default: "ring-[1px] ring-surface-500/30"
|
|
208
|
+
},
|
|
209
|
+
rounded: {
|
|
210
|
+
type: String,
|
|
211
|
+
default: "rounded-token"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
setup(props, { attrs }) {
|
|
215
|
+
const { initializeMode, setModeCurrent, setModeUserPrefers, currentMode: currentMode2, MODE: MODE2 } = useDarkMode();
|
|
216
|
+
onMounted(() => {
|
|
217
|
+
initializeMode();
|
|
218
|
+
});
|
|
219
|
+
const cTransition = `transition-all duration-[200ms]`;
|
|
220
|
+
const cTrack = "cursor-pointer";
|
|
221
|
+
const cThumb = "aspect-square scale-[0.8] flex justify-center items-center";
|
|
222
|
+
const cIcon = "w-[70%] aspect-square";
|
|
223
|
+
const svgPath = {
|
|
224
|
+
sun: "M361.5 1.2c5 2.1 8.6 6.6 9.6 11.9L391 121l107.9 19.8c5.3 1 9.8 4.6 11.9 9.6s1.5 10.7-1.6 15.2L446.9 256l62.3 90.3c3.1 4.5 3.7 10.2 1.6 15.2s-6.6 8.6-11.9 9.6L391 391 371.1 498.9c-1 5.3-4.6 9.8-9.6 11.9s-10.7 1.5-15.2-1.6L256 446.9l-90.3 62.3c-4.5 3.1-10.2 3.7-15.2 1.6s-8.6-6.6-9.6-11.9L121 391 13.1 371.1c-5.3-1-9.8-4.6-11.9-9.6s-1.5-10.7 1.6-15.2L65.1 256 2.8 165.7c-3.1-4.5-3.7-10.2-1.6-15.2s6.6-8.6 11.9-9.6L121 121 140.9 13.1c1-5.3 4.6-9.8 9.6-11.9s10.7-1.5 15.2 1.6L256 65.1 346.3 2.8c4.5-3.1 10.2-3.7 15.2-1.6zM352 256c0 53-43 96-96 96s-96-43-96-96s43-96 96-96s96 43 96 96zm32 0c0-70.7-57.3-128-128-128s-128 57.3-128 128s57.3 128 128 128s128-57.3 128-128z",
|
|
225
|
+
moon: "M223.5 32C100 32 0 132.3 0 256S100 480 223.5 480c60.6 0 115.5-24.2 155.8-63.4c5-4.9 6.3-12.5 3.1-18.7s-10.1-9.7-17-8.5c-9.8 1.7-19.8 2.6-30.1 2.6c-96.9 0-175.5-78.8-175.5-176c0-65.8 36-123.1 89.3-153.3c6.1-3.5 9.2-10.5 7.7-17.3s-7.3-11.9-14.3-12.5c-6.3-.5-12.6-.8-19-.8z"
|
|
226
|
+
};
|
|
227
|
+
const onToggleHandler = () => {
|
|
228
|
+
const toggle = !currentMode2.value;
|
|
229
|
+
setModeUserPrefers(toggle);
|
|
230
|
+
setModeCurrent(toggle);
|
|
231
|
+
};
|
|
232
|
+
const onKeyDown = (event) => {
|
|
233
|
+
if (["Enter", "Space"].includes(event.code)) {
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
event.currentTarget.click();
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const trackBg = computed(
|
|
239
|
+
() => currentMode2.value === MODE2.LIGHT ? props.bgLight : props.bgDark
|
|
240
|
+
);
|
|
241
|
+
const thumbBg = computed(
|
|
242
|
+
() => currentMode2.value === MODE2.LIGHT ? props.bgDark : props.bgLight
|
|
243
|
+
);
|
|
244
|
+
const thumbPosition = computed(
|
|
245
|
+
() => currentMode2.value === MODE2.LIGHT ? "translate-x-[100%]" : ""
|
|
246
|
+
);
|
|
247
|
+
const iconFill = computed(() => {
|
|
248
|
+
return currentMode2.value === MODE2.LIGHT ? props.textLight : props.textDark;
|
|
249
|
+
});
|
|
250
|
+
const classesTrack = computed(() => {
|
|
251
|
+
var _a;
|
|
252
|
+
return `${cTrack} ${cTransition} ${props.width} ${props.height} ${props.ring} ${props.rounded} ${trackBg.value} ${(_a = attrs.class) != null ? _a : ""}`;
|
|
253
|
+
});
|
|
254
|
+
const classesThumb = computed(
|
|
255
|
+
() => `${cThumb} ${cTransition} ${props.height} ${props.rounded} ${thumbBg.value} ${thumbPosition.value}`
|
|
256
|
+
);
|
|
257
|
+
const classesIcon = computed(() => `${cIcon}`);
|
|
258
|
+
return {
|
|
259
|
+
classesTrack,
|
|
260
|
+
classesThumb,
|
|
261
|
+
classesIcon,
|
|
262
|
+
svgPath,
|
|
263
|
+
onToggleHandler,
|
|
264
|
+
onKeyDown,
|
|
265
|
+
currentMode: currentMode2,
|
|
266
|
+
iconFill
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
const _hoisted_1$1 = ["aria-checked", "title"];
|
|
271
|
+
const _hoisted_2$1 = ["d"];
|
|
272
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
273
|
+
return openBlock(), createElementBlock("div", {
|
|
274
|
+
class: normalizeClass(`lightswitch-track ${_ctx.classesTrack}`),
|
|
275
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onToggleHandler && _ctx.onToggleHandler(...args)),
|
|
276
|
+
onKeydown: _cache[1] || (_cache[1] = (...args) => _ctx.onKeyDown && _ctx.onKeyDown(...args)),
|
|
277
|
+
"on:keyup": "",
|
|
278
|
+
"on:keypress": "",
|
|
279
|
+
role: "switch",
|
|
280
|
+
"aria-label": "Light Switch",
|
|
281
|
+
"aria-checked": _ctx.currentMode,
|
|
282
|
+
title: `Toggle ${_ctx.currentMode === false ? "Dark" : "Light"} Mode`,
|
|
283
|
+
tabindex: "0"
|
|
284
|
+
}, [
|
|
285
|
+
createElementVNode("div", {
|
|
286
|
+
class: normalizeClass(`lightswitch-thumb ${_ctx.classesThumb}`)
|
|
287
|
+
}, [
|
|
288
|
+
(openBlock(), createElementBlock("svg", {
|
|
289
|
+
class: normalizeClass(`lightswitch-icon ${_ctx.classesIcon} ${_ctx.iconFill}`),
|
|
290
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
291
|
+
viewBox: "0 0 512 512"
|
|
292
|
+
}, [
|
|
293
|
+
createElementVNode("path", {
|
|
294
|
+
fill: "currentColor",
|
|
295
|
+
d: _ctx.currentMode ? _ctx.svgPath.sun : _ctx.svgPath.moon
|
|
296
|
+
}, null, 8, _hoisted_2$1)
|
|
297
|
+
], 2))
|
|
298
|
+
], 2)
|
|
299
|
+
], 42, _hoisted_1$1);
|
|
300
|
+
}
|
|
301
|
+
var DarkModeSwitch = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
302
|
+
function add(a, b) {
|
|
303
|
+
return a + b;
|
|
304
|
+
}
|
|
305
|
+
var MyUtil = {
|
|
306
|
+
add
|
|
307
|
+
};
|
|
308
|
+
const { isBrowser } = usePlatform();
|
|
309
|
+
const chosenTheme = ref("vuetiful");
|
|
310
|
+
const useTheme = () => {
|
|
311
|
+
const themes = ["vuetiful", "modern", "rocket", "sahara", "seafoam", "seasonal", "vintage"];
|
|
312
|
+
const theme = ref("vuetiful");
|
|
313
|
+
const setTheme = (name) => {
|
|
314
|
+
theme.value = name;
|
|
315
|
+
if (isBrowser) {
|
|
316
|
+
localStorage.setItem("vuetiful-theme", name);
|
|
317
|
+
applyTheme(name);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const applyTheme = (name) => {
|
|
321
|
+
document.body.setAttribute("data-theme", name);
|
|
322
|
+
};
|
|
323
|
+
const initializeTheme = (callback) => {
|
|
324
|
+
var _a;
|
|
325
|
+
if (isBrowser) {
|
|
326
|
+
const themeName = (_a = localStorage.getItem("vuetiful-theme")) != null ? _a : "vuetiful";
|
|
327
|
+
if (themeName)
|
|
328
|
+
loadTheme(themeName, callback);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
const loadTheme = (theme2, callback) => {
|
|
332
|
+
chosenTheme.value = theme2;
|
|
333
|
+
const existingStyle = document.getElementById("theme");
|
|
334
|
+
const themeUrl = `https://code-coaching.dev/vuetiful-themes/theme-${theme2}.css`;
|
|
335
|
+
const link = document.createElement("link");
|
|
336
|
+
link.id = "theme";
|
|
337
|
+
link.href = themeUrl;
|
|
338
|
+
link.type = "text/css";
|
|
339
|
+
link.rel = "stylesheet";
|
|
340
|
+
link.onload = () => {
|
|
341
|
+
if (existingStyle)
|
|
342
|
+
existingStyle.remove();
|
|
343
|
+
setTheme(theme2);
|
|
344
|
+
if (callback) {
|
|
345
|
+
callback();
|
|
346
|
+
console.log("callback");
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
const head = document.querySelector("head");
|
|
350
|
+
if (head)
|
|
351
|
+
head.appendChild(link);
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
theme: readonly(theme),
|
|
355
|
+
themes: readonly(themes),
|
|
356
|
+
chosenTheme: readonly(chosenTheme),
|
|
357
|
+
setTheme,
|
|
358
|
+
initializeTheme,
|
|
359
|
+
loadTheme
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
var themeSwitcher_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
363
|
+
const _sfc_main = defineComponent({
|
|
364
|
+
components: {
|
|
365
|
+
DarkModeSwitch,
|
|
366
|
+
VButton
|
|
367
|
+
},
|
|
368
|
+
props: {
|
|
369
|
+
bgLight: {
|
|
370
|
+
type: String,
|
|
371
|
+
default: "bg-surface-50"
|
|
372
|
+
},
|
|
373
|
+
bgDark: {
|
|
374
|
+
type: String,
|
|
375
|
+
default: "bg-surface-900"
|
|
376
|
+
},
|
|
377
|
+
textOnLight: {
|
|
378
|
+
type: String,
|
|
379
|
+
default: "text-surface-900"
|
|
380
|
+
},
|
|
381
|
+
textOnDark: {
|
|
382
|
+
type: String,
|
|
383
|
+
default: "text-surface-50"
|
|
384
|
+
},
|
|
385
|
+
width: {
|
|
386
|
+
type: String,
|
|
387
|
+
default: "w-60"
|
|
388
|
+
},
|
|
389
|
+
height: {
|
|
390
|
+
type: String,
|
|
391
|
+
default: "max-h-64 lg:max-h-[500px]"
|
|
392
|
+
},
|
|
393
|
+
ring: {
|
|
394
|
+
type: String,
|
|
395
|
+
default: "ring-[1px] ring-surface-500/30"
|
|
396
|
+
},
|
|
397
|
+
rounded: {
|
|
398
|
+
type: String,
|
|
399
|
+
default: "rounded-token"
|
|
400
|
+
},
|
|
401
|
+
roundedContainer: {
|
|
402
|
+
type: String,
|
|
403
|
+
default: "rounded-container-token"
|
|
404
|
+
},
|
|
405
|
+
buttonClasses: {
|
|
406
|
+
type: String,
|
|
407
|
+
default: "w-24"
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
setup(props, { attrs }) {
|
|
411
|
+
const { initializeTheme, loadTheme, themes, chosenTheme: chosenTheme2 } = useTheme();
|
|
412
|
+
const { currentMode: currentMode2, MODE: MODE2 } = useDarkMode();
|
|
413
|
+
const showPopup = ref(false);
|
|
414
|
+
onMounted(() => {
|
|
415
|
+
initializeTheme();
|
|
416
|
+
});
|
|
417
|
+
const cTransition = `transition-all duration-[200ms]`;
|
|
418
|
+
function onKeyDown(event) {
|
|
419
|
+
if (["Enter", "Space"].includes(event.code)) {
|
|
420
|
+
event.preventDefault();
|
|
421
|
+
event.currentTarget.click();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
const background = computed(() => {
|
|
425
|
+
return currentMode2.value === MODE2.LIGHT ? props.bgLight : props.bgDark;
|
|
426
|
+
});
|
|
427
|
+
const text = computed(() => {
|
|
428
|
+
return currentMode2.value === MODE2.LIGHT ? props.textOnLight : props.textOnDark;
|
|
429
|
+
});
|
|
430
|
+
const classes = computed(() => {
|
|
431
|
+
var _a;
|
|
432
|
+
return `${cTransition}
|
|
433
|
+
${background.value}
|
|
434
|
+
${text.value}
|
|
435
|
+
${props.width}
|
|
436
|
+
${props.ring}
|
|
437
|
+
${props.roundedContainer}
|
|
438
|
+
${(_a = attrs.class) != null ? _a : ""}`;
|
|
439
|
+
});
|
|
440
|
+
const listClasses = computed(() => {
|
|
441
|
+
return `${cTransition}
|
|
442
|
+
${props.height}`;
|
|
443
|
+
});
|
|
444
|
+
const listItemClasses = computed(() => {
|
|
445
|
+
return `${cTransition}
|
|
446
|
+
${props.ring}
|
|
447
|
+
${props.rounded}`;
|
|
448
|
+
});
|
|
449
|
+
return {
|
|
450
|
+
onKeyDown,
|
|
451
|
+
loadTheme,
|
|
452
|
+
currentMode: currentMode2,
|
|
453
|
+
classes,
|
|
454
|
+
chosenTheme: chosenTheme2,
|
|
455
|
+
themes,
|
|
456
|
+
showPopup,
|
|
457
|
+
listClasses,
|
|
458
|
+
listItemClasses
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
const _withScopeId = (n) => (pushScopeId("data-v-74718370"), n = n(), popScopeId(), n);
|
|
463
|
+
const _hoisted_1 = { class: "cc-theme-switcher" };
|
|
464
|
+
const _hoisted_2 = { class: "space-y-4" };
|
|
465
|
+
const _hoisted_3 = { class: "flex items-center justify-between" };
|
|
466
|
+
const _hoisted_4 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("h6", null, "Mode", -1));
|
|
467
|
+
const _hoisted_5 = { class: "flex flex-col gap-4" };
|
|
468
|
+
const _hoisted_6 = ["onClick"];
|
|
469
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
470
|
+
const _component_VButton = resolveComponent("VButton");
|
|
471
|
+
const _component_DarkModeSwitch = resolveComponent("DarkModeSwitch");
|
|
472
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
473
|
+
createVNode(_component_VButton, {
|
|
474
|
+
class: normalizeClass(`cc-theme-switcher__button ${_ctx.buttonClasses}`),
|
|
475
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.showPopup = !_ctx.showPopup)
|
|
476
|
+
}, {
|
|
477
|
+
default: withCtx(() => [
|
|
478
|
+
createTextVNode(" Theme ")
|
|
479
|
+
]),
|
|
480
|
+
_: 1
|
|
481
|
+
}, 8, ["class"]),
|
|
482
|
+
_ctx.showPopup ? (openBlock(), createElementBlock("div", {
|
|
483
|
+
key: 0,
|
|
484
|
+
class: normalizeClass(["cc-theme-switcher__popup p-4 shadow-xl", _ctx.classes])
|
|
485
|
+
}, [
|
|
486
|
+
createElementVNode("div", _hoisted_2, [
|
|
487
|
+
createElementVNode("section", _hoisted_3, [
|
|
488
|
+
_hoisted_4,
|
|
489
|
+
createVNode(_component_DarkModeSwitch)
|
|
490
|
+
]),
|
|
491
|
+
createElementVNode("nav", {
|
|
492
|
+
class: normalizeClass(["list-nav -m-4 overflow-y-auto p-4", _ctx.listClasses])
|
|
493
|
+
}, [
|
|
494
|
+
createElementVNode("ul", _hoisted_5, [
|
|
495
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.themes, (theme, index2) => {
|
|
496
|
+
return openBlock(), createElementBlock("li", {
|
|
497
|
+
class: normalizeClass(["h-full w-full p-2 text-center capitalize hover:cursor-pointer hover:bg-primary-100 hover:text-primary-900", `${_ctx.listItemClasses} ${_ctx.chosenTheme === theme ? "bg-primary-50 text-primary-900" : "bg-surface-200 text-surface-900"}`]),
|
|
498
|
+
key: index2,
|
|
499
|
+
onClick: ($event) => _ctx.loadTheme(theme)
|
|
500
|
+
}, toDisplayString(theme), 11, _hoisted_6);
|
|
501
|
+
}), 128))
|
|
502
|
+
])
|
|
503
|
+
], 2)
|
|
504
|
+
])
|
|
505
|
+
], 2)) : createCommentVNode("", true)
|
|
506
|
+
]);
|
|
507
|
+
}
|
|
508
|
+
var themeSwitcher = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-74718370"]]);
|
|
509
|
+
function install(app) {
|
|
510
|
+
for (const key in components) {
|
|
511
|
+
app.component(key, components[key]);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
var index = { install };
|
|
515
|
+
export { DarkModeSwitch, MyConstants, MyUtil, themeSwitcher as ThemeSwitcher, VButton, index as default, useDarkMode, useTheme };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
(function(d,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(d=typeof globalThis!="undefined"?globalThis:d||self,e(d["@code-coaching/vuetiful"]={},d.Vue))})(this,function(d,e){"use strict";var S=(t,s)=>{const c=t.__vccOpts||t;for(const[u,m]of s)c[u]=m;return c};const O=e.defineComponent({props:{bgLight:{type:String,default:"bg-primary-50"},bgDark:{type:String,default:"bg-primary-900"},textOnLight:{type:String,default:"text-primary-900"},textOnDark:{type:String,default:"text-primary-50"},width:{type:String,default:"w-fit"},height:{type:String,default:"h-fit"},ring:{type:String,default:"ring-[1px] ring-primary-500/30"},rounded:{type:String,default:"rounded-token"},msg:{type:String}},setup(t,{attrs:s}){const{currentMode:c,MODE:u}=$(),m="transition-all duration-[200ms]",r=e.computed(()=>c.value===u.LIGHT?t.bgLight:t.bgDark),o=e.computed(()=>c.value===u.LIGHT?t.textOnLight:t.textOnDark);return{classes:e.computed(()=>{var n;return`${m}
|
|
2
|
+
${r.value}
|
|
3
|
+
${o.value}
|
|
4
|
+
${t.width}
|
|
5
|
+
${t.height}
|
|
6
|
+
${t.ring}
|
|
7
|
+
${t.rounded}
|
|
8
|
+
${(n=s.class)!=null?n:""}`})}}});function z(t,s,c,u,m,r){return e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(`cc-button btn ${t.classes}`)},[t.msg?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(t.msg),1)],64)):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"default")],2)}var w=S(O,[["render",z]]),L=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",VButton:w}),ce="",ae="",le="";const x=100;var H=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",MAGIC_NUM:x});const _=()=>({isBrowser:typeof window!="undefined"}),{isBrowser:M}=_(),y={LIGHT:!0,DARK:!1},D=e.ref(y.DARK),B=e.ref(y.DARK),k=e.ref(void 0),$=()=>{const t=()=>{const n=window.matchMedia("(prefers-color-scheme: light)").matches;return u(n),n},s=()=>{if(M){const n=localStorage.getItem("modeUserPrefers");n!==null&&(k.value=n==="true")}return k.value},c=()=>{const n=t(),a=s();return a!==void 0?a:n},u=n=>{D.value=n,M&&localStorage.setItem("modeOsPrefers",n.toString())},m=n=>{k.value=n,M&&localStorage.setItem("modeUserPrefers",n.toString())},r=n=>{const a=document.documentElement.classList,l="dark";n===y.LIGHT?a.remove(l):a.add(l),B.value=n},o=()=>{const n=c();r(n)},i=()=>{const n=window.matchMedia("(prefers-color-scheme: light)"),a=l=>{const g=document.documentElement.classList,p="dark";l===y.LIGHT?g.remove(p):g.add(p)};a(n.matches),n.onchange=()=>{a(n.matches)}};return{modeOsPrefers:e.readonly(D),modeUserPrefers:e.readonly(k),currentMode:e.readonly(B),getModeOsPrefers:t,getModeUserPrefers:s,getModeAutoPrefers:c,setModeUserPrefers:m,setModeCurrent:r,autoModeWatcher:i,initializeMode:o,MODE:y}},N=e.defineComponent({props:{bgLight:{type:String,default:"bg-surface-50"},bgDark:{type:String,default:"bg-surface-900"},textLight:{type:String,default:"text-surface-50"},textDark:{type:String,default:"text-surface-900"},width:{type:String,default:"w-12"},height:{type:String,default:"h-6"},ring:{type:String,default:"ring-[1px] ring-surface-500/30"},rounded:{type:String,default:"rounded-token"}},setup(t,{attrs:s}){const{initializeMode:c,setModeCurrent:u,setModeUserPrefers:m,currentMode:r,MODE:o}=$();e.onMounted(()=>{c()});const i="transition-all duration-[200ms]",n="cursor-pointer",a="aspect-square scale-[0.8] flex justify-center items-center",l="w-[70%] aspect-square",g={sun:"M361.5 1.2c5 2.1 8.6 6.6 9.6 11.9L391 121l107.9 19.8c5.3 1 9.8 4.6 11.9 9.6s1.5 10.7-1.6 15.2L446.9 256l62.3 90.3c3.1 4.5 3.7 10.2 1.6 15.2s-6.6 8.6-11.9 9.6L391 391 371.1 498.9c-1 5.3-4.6 9.8-9.6 11.9s-10.7 1.5-15.2-1.6L256 446.9l-90.3 62.3c-4.5 3.1-10.2 3.7-15.2 1.6s-8.6-6.6-9.6-11.9L121 391 13.1 371.1c-5.3-1-9.8-4.6-11.9-9.6s-1.5-10.7 1.6-15.2L65.1 256 2.8 165.7c-3.1-4.5-3.7-10.2-1.6-15.2s6.6-8.6 11.9-9.6L121 121 140.9 13.1c1-5.3 4.6-9.8 9.6-11.9s10.7-1.5 15.2 1.6L256 65.1 346.3 2.8c4.5-3.1 10.2-3.7 15.2-1.6zM352 256c0 53-43 96-96 96s-96-43-96-96s43-96 96-96s96 43 96 96zm32 0c0-70.7-57.3-128-128-128s-128 57.3-128 128s57.3 128 128 128s128-57.3 128-128z",moon:"M223.5 32C100 32 0 132.3 0 256S100 480 223.5 480c60.6 0 115.5-24.2 155.8-63.4c5-4.9 6.3-12.5 3.1-18.7s-10.1-9.7-17-8.5c-9.8 1.7-19.8 2.6-30.1 2.6c-96.9 0-175.5-78.8-175.5-176c0-65.8 36-123.1 89.3-153.3c6.1-3.5 9.2-10.5 7.7-17.3s-7.3-11.9-14.3-12.5c-6.3-.5-12.6-.8-19-.8z"},p=()=>{const h=!r.value;m(h),u(h)},b=h=>{["Enter","Space"].includes(h.code)&&(h.preventDefault(),h.currentTarget.click())},T=e.computed(()=>r.value===o.LIGHT?t.bgLight:t.bgDark),C=e.computed(()=>r.value===o.LIGHT?t.bgDark:t.bgLight),f=e.computed(()=>r.value===o.LIGHT?"translate-x-[100%]":""),ne=e.computed(()=>r.value===o.LIGHT?t.textLight:t.textDark),oe=e.computed(()=>{var h;return`${n} ${i} ${t.width} ${t.height} ${t.ring} ${t.rounded} ${T.value} ${(h=s.class)!=null?h:""}`}),se=e.computed(()=>`${a} ${i} ${t.height} ${t.rounded} ${C.value} ${f.value}`),re=e.computed(()=>`${l}`);return{classesTrack:oe,classesThumb:se,classesIcon:re,svgPath:g,onToggleHandler:p,onKeyDown:b,currentMode:r,iconFill:ne}}}),G=["aria-checked","title"],U=["d"];function K(t,s,c,u,m,r){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(`lightswitch-track ${t.classesTrack}`),onClick:s[0]||(s[0]=(...o)=>t.onToggleHandler&&t.onToggleHandler(...o)),onKeydown:s[1]||(s[1]=(...o)=>t.onKeyDown&&t.onKeyDown(...o)),"on:keyup":"","on:keypress":"",role:"switch","aria-label":"Light Switch","aria-checked":t.currentMode,title:`Toggle ${t.currentMode===!1?"Dark":"Light"} Mode`,tabindex:"0"},[e.createElementVNode("div",{class:e.normalizeClass(`lightswitch-thumb ${t.classesThumb}`)},[(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(`lightswitch-icon ${t.classesIcon} ${t.iconFill}`),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},[e.createElementVNode("path",{fill:"currentColor",d:t.currentMode?t.svgPath.sun:t.svgPath.moon},null,8,U)],2))],2)],42,G)}var I=S(N,[["render",K]]);function A(t,s){return t+s}var j={add:A};const{isBrowser:E}=_(),P=e.ref("vuetiful"),V=()=>{const t=["vuetiful","modern","rocket","sahara","seafoam","seasonal","vintage"],s=e.ref("vuetiful"),c=o=>{s.value=o,E&&(localStorage.setItem("vuetiful-theme",o),u(o))},u=o=>{document.body.setAttribute("data-theme",o)},m=o=>{var i;if(E){const n=(i=localStorage.getItem("vuetiful-theme"))!=null?i:"vuetiful";n&&r(n,o)}},r=(o,i)=>{P.value=o;const n=document.getElementById("theme"),a=`https://code-coaching.dev/vuetiful-themes/theme-${o}.css`,l=document.createElement("link");l.id="theme",l.href=a,l.type="text/css",l.rel="stylesheet",l.onload=()=>{n&&n.remove(),c(o),i&&(i(),console.log("callback"))};const g=document.querySelector("head");g&&g.appendChild(l)};return{theme:e.readonly(s),themes:e.readonly(t),chosenTheme:e.readonly(P),setTheme:c,initializeTheme:m,loadTheme:r}};var ie="";const q=e.defineComponent({components:{DarkModeSwitch:I,VButton:w},props:{bgLight:{type:String,default:"bg-surface-50"},bgDark:{type:String,default:"bg-surface-900"},textOnLight:{type:String,default:"text-surface-900"},textOnDark:{type:String,default:"text-surface-50"},width:{type:String,default:"w-60"},height:{type:String,default:"max-h-64 lg:max-h-[500px]"},ring:{type:String,default:"ring-[1px] ring-surface-500/30"},rounded:{type:String,default:"rounded-token"},roundedContainer:{type:String,default:"rounded-container-token"},buttonClasses:{type:String,default:"w-24"}},setup(t,{attrs:s}){const{initializeTheme:c,loadTheme:u,themes:m,chosenTheme:r}=V(),{currentMode:o,MODE:i}=$(),n=e.ref(!1);e.onMounted(()=>{c()});const a="transition-all duration-[200ms]";function l(f){["Enter","Space"].includes(f.code)&&(f.preventDefault(),f.currentTarget.click())}const g=e.computed(()=>o.value===i.LIGHT?t.bgLight:t.bgDark),p=e.computed(()=>o.value===i.LIGHT?t.textOnLight:t.textOnDark),b=e.computed(()=>{var f;return`${a}
|
|
9
|
+
${g.value}
|
|
10
|
+
${p.value}
|
|
11
|
+
${t.width}
|
|
12
|
+
${t.ring}
|
|
13
|
+
${t.roundedContainer}
|
|
14
|
+
${(f=s.class)!=null?f:""}`}),T=e.computed(()=>`${a}
|
|
15
|
+
${t.height}`),C=e.computed(()=>`${a}
|
|
16
|
+
${t.ring}
|
|
17
|
+
${t.rounded}`);return{onKeyDown:l,loadTheme:u,currentMode:o,classes:b,chosenTheme:r,themes:m,showPopup:n,listClasses:T,listItemClasses:C}}}),F=t=>(e.pushScopeId("data-v-74718370"),t=t(),e.popScopeId(),t),R={class:"cc-theme-switcher"},W={class:"space-y-4"},J={class:"flex items-center justify-between"},Q=F(()=>e.createElementVNode("h6",null,"Mode",-1)),X={class:"flex flex-col gap-4"},Y=["onClick"];function Z(t,s,c,u,m,r){const o=e.resolveComponent("VButton"),i=e.resolveComponent("DarkModeSwitch");return e.openBlock(),e.createElementBlock("div",R,[e.createVNode(o,{class:e.normalizeClass(`cc-theme-switcher__button ${t.buttonClasses}`),onClick:s[0]||(s[0]=n=>t.showPopup=!t.showPopup)},{default:e.withCtx(()=>[e.createTextVNode(" Theme ")]),_:1},8,["class"]),t.showPopup?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["cc-theme-switcher__popup p-4 shadow-xl",t.classes])},[e.createElementVNode("div",W,[e.createElementVNode("section",J,[Q,e.createVNode(i)]),e.createElementVNode("nav",{class:e.normalizeClass(["list-nav -m-4 overflow-y-auto p-4",t.listClasses])},[e.createElementVNode("ul",X,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.themes,(n,a)=>(e.openBlock(),e.createElementBlock("li",{class:e.normalizeClass(["h-full w-full p-2 text-center capitalize hover:cursor-pointer hover:bg-primary-100 hover:text-primary-900",`${t.listItemClasses} ${t.chosenTheme===n?"bg-primary-50 text-primary-900":"bg-surface-200 text-surface-900"}`]),key:a,onClick:l=>t.loadTheme(n)},e.toDisplayString(n),11,Y))),128))])],2)])],2)):e.createCommentVNode("",!0)])}var v=S(q,[["render",Z],["__scopeId","data-v-74718370"]]);function ee(t){for(const s in L)t.component(s,L[s])}var te={install:ee};d.DarkModeSwitch=I,d.MyConstants=H,d.MyUtil=j,d.ThemeSwitcher=v,d.VButton=w,d.default=te,d.useDarkMode=$,d.useTheme=V,Object.defineProperty(d,"__esModule",{value:!0}),d[Symbol.toStringTag]="Module"});
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@code-coaching/vuetiful",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "onchange 'src/**/*.vue' 'src/**/*.ts' 'src/**/*.css' -- npm run build",
|
|
6
|
+
"prebuild": "node 'scripts/intellisense.js'",
|
|
7
|
+
"build": "rimraf dist && vue-tsc && vite build && npm run build:style",
|
|
8
|
+
"build:style": "npx tailwindcss -i ./src/styles/all.css -o ./dist/styles/all.css",
|
|
9
|
+
"docs:dev": "cd docs && npm run dev",
|
|
10
|
+
"docs:build": "cd docs && npm run build",
|
|
11
|
+
"docs:serve": "cd docs && npm run serve"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"vue": "^3.2.25"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^17.0.14",
|
|
18
|
+
"@vitejs/plugin-vue": "^2.0.0",
|
|
19
|
+
"autoprefixer": "^10.4.14",
|
|
20
|
+
"onchange": "^7.1.0",
|
|
21
|
+
"postcss": "^8.4.21",
|
|
22
|
+
"prettier": "^2.8.4",
|
|
23
|
+
"prettier-plugin-tailwindcss": "^0.2.4",
|
|
24
|
+
"rimraf": "^3.0.2",
|
|
25
|
+
"tailwindcss": "^3.2.7",
|
|
26
|
+
"typescript": "^4.4.4",
|
|
27
|
+
"vite": "^2.7.2",
|
|
28
|
+
"vue": "^3.2.25",
|
|
29
|
+
"vue-tsc": "^0.29.8"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"src",
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"types": "./dist/types/index.d.ts",
|
|
36
|
+
"module": "./dist/vuetiful.es.mjs",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"import": "./dist/vuetiful.es.mjs",
|
|
40
|
+
"require": "./dist/vuetiful.umd.js",
|
|
41
|
+
"types": "./dist/types/index.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./themes/*": "./src/themes/*",
|
|
44
|
+
"./styles/*": "./src/styles/*",
|
|
45
|
+
"./tailwind/*": "./src/tailwind/*"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: 'myfont';
|
|
3
|
+
src: url('fonts/myfont.woff');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[class^='icon-'],
|
|
7
|
+
[class*=' icon-'] {
|
|
8
|
+
font-family: 'myfont' !important;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.icon-heart:before {
|
|
12
|
+
content: '\e9da';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.global-example {
|
|
16
|
+
color: red;
|
|
17
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button :class="`cc-button btn ${classes}`">
|
|
3
|
+
<template v-if="msg">{{ msg }}</template>
|
|
4
|
+
<slot />
|
|
5
|
+
</button>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { CssClasses, useDarkMode } from "@/index";
|
|
10
|
+
import { computed, defineComponent } from "vue";
|
|
11
|
+
|
|
12
|
+
export default defineComponent({
|
|
13
|
+
props: {
|
|
14
|
+
bgLight: {
|
|
15
|
+
type: String as () => CssClasses,
|
|
16
|
+
default: "bg-primary-50",
|
|
17
|
+
},
|
|
18
|
+
bgDark: {
|
|
19
|
+
type: String as () => CssClasses,
|
|
20
|
+
default: "bg-primary-900",
|
|
21
|
+
},
|
|
22
|
+
textOnLight: {
|
|
23
|
+
type: String as () => CssClasses,
|
|
24
|
+
default: "text-primary-900",
|
|
25
|
+
},
|
|
26
|
+
textOnDark: {
|
|
27
|
+
type: String as () => CssClasses,
|
|
28
|
+
default: "text-primary-50",
|
|
29
|
+
},
|
|
30
|
+
width: {
|
|
31
|
+
type: String as () => CssClasses,
|
|
32
|
+
default: "w-fit",
|
|
33
|
+
},
|
|
34
|
+
height: {
|
|
35
|
+
type: String as () => CssClasses,
|
|
36
|
+
default: "h-fit",
|
|
37
|
+
},
|
|
38
|
+
ring: {
|
|
39
|
+
type: String as () => CssClasses,
|
|
40
|
+
default: "ring-[1px] ring-primary-500/30",
|
|
41
|
+
},
|
|
42
|
+
rounded: {
|
|
43
|
+
type: String as () => CssClasses,
|
|
44
|
+
default: "rounded-token",
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
msg: {
|
|
48
|
+
type: String,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
setup(props, { attrs }) {
|
|
52
|
+
const { currentMode, MODE } = useDarkMode();
|
|
53
|
+
const cTransition = `transition-all duration-[200ms]`;
|
|
54
|
+
|
|
55
|
+
const background = computed(() => {
|
|
56
|
+
return currentMode.value === MODE.LIGHT ? props.bgLight : props.bgDark;
|
|
57
|
+
});
|
|
58
|
+
const text = computed(() => {
|
|
59
|
+
return currentMode.value === MODE.LIGHT ? props.textOnLight : props.textOnDark;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const classes = computed(() => {
|
|
63
|
+
return `${cTransition}
|
|
64
|
+
${background.value}
|
|
65
|
+
${text.value}
|
|
66
|
+
${props.width}
|
|
67
|
+
${props.height}
|
|
68
|
+
${props.ring}
|
|
69
|
+
${props.rounded}
|
|
70
|
+
${attrs.class ?? ""}`;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
classes,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
</script>
|