@code-coaching/vuetiful 0.9.0 → 0.11.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/dist/style.css +1 -1
- package/dist/styles/all.css +0 -10
- package/dist/types/components/atoms/VBadge.vue.d.ts +1 -1
- package/dist/types/components/atoms/VChip.vue.d.ts +1 -1
- package/dist/types/components/molecules/VShell.vue.d.ts +8 -0
- package/dist/types/utils/code-block/{code-block.vue.d.ts → VCodeBlock.vue.d.ts} +13 -55
- package/dist/types/utils/dark-mode/dark-mode.vue.d.ts +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/theme/theme-switcher.vue.d.ts +1 -1
- package/dist/vuetiful.es.mjs +100 -155
- package/dist/vuetiful.umd.js +10 -10
- package/package.json +1 -1
- package/src/components/atoms/VBadge.vue +1 -6
- package/src/components/atoms/VButton.vue +1 -6
- package/src/components/atoms/VChip.vue +1 -6
- package/src/components/molecules/VDrawer.vue +2 -6
- package/src/components/molecules/VRail.vue +2 -9
- package/src/components/molecules/VRailTile.vue +19 -18
- package/src/components/molecules/VShell.vue +1 -3
- package/src/styles/core.css +1 -0
- package/src/utils/code-block/VCodeBlock.vue +81 -0
- package/src/utils/index.ts +2 -2
- package/src/utils/code-block/code-block.vue +0 -106
package/package.json
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useAttrs } from "vue";
|
|
3
|
-
|
|
4
2
|
defineProps({
|
|
5
3
|
icon: {
|
|
6
4
|
type: Boolean as () => boolean,
|
|
@@ -11,7 +9,6 @@ defineProps({
|
|
|
11
9
|
default: "button",
|
|
12
10
|
},
|
|
13
11
|
});
|
|
14
|
-
const attrs = useAttrs();
|
|
15
12
|
const emit = defineEmits<{ (event: "click"): void }>();
|
|
16
13
|
|
|
17
14
|
const activate = () => {
|
|
@@ -41,9 +38,7 @@ const keyupHandler = (event: KeyboardEvent) => {
|
|
|
41
38
|
tabindex="0"
|
|
42
39
|
role="button"
|
|
43
40
|
:is="tag"
|
|
44
|
-
:class="`vuetiful-button ${icon ? 'btn-icon' : 'btn'} border-token hover:cursor-pointer
|
|
45
|
-
attrs.class ?? ''
|
|
46
|
-
}`"
|
|
41
|
+
:class="`vuetiful-button ${icon ? 'btn-icon' : 'btn'} border-token hover:cursor-pointer`"
|
|
47
42
|
@click="clickHandler"
|
|
48
43
|
@keydown="keydownHandler"
|
|
49
44
|
@keyup="keyupHandler"
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { CssClasses } from "@/index";
|
|
3
3
|
import { useDrawer } from "@/services";
|
|
4
|
-
import { Ref, computed, onMounted, ref, toRefs
|
|
4
|
+
import { Ref, computed, onMounted, ref, toRefs } from "vue";
|
|
5
5
|
|
|
6
6
|
const { drawer, close } = useDrawer();
|
|
7
|
-
const attrs = useAttrs();
|
|
8
7
|
|
|
9
8
|
// #region Props
|
|
10
9
|
const props = defineProps({
|
|
@@ -29,7 +28,6 @@ const props = defineProps({
|
|
|
29
28
|
},
|
|
30
29
|
});
|
|
31
30
|
|
|
32
|
-
// prettier-ignore
|
|
33
31
|
const { regionBackdrop, regionDrawer, labelledby, describedby } = toRefs(props);
|
|
34
32
|
// prettier-ignore
|
|
35
33
|
const presets = {
|
|
@@ -81,9 +79,7 @@ onMounted(() => {
|
|
|
81
79
|
<div
|
|
82
80
|
v-if="drawer.open"
|
|
83
81
|
ref="elemBackdrop"
|
|
84
|
-
:class="`drawer-backdrop backdrop-blur-xs fixed bottom-0 left-0 right-0 top-0 flex bg-surface-backdrop-token
|
|
85
|
-
attrs.class ?? ''
|
|
86
|
-
}`"
|
|
82
|
+
:class="`drawer-backdrop backdrop-blur-xs fixed bottom-0 left-0 right-0 top-0 flex bg-surface-backdrop-token z-40 ${regionBackdrop}`"
|
|
87
83
|
@mousedown="onBackdropInteraction"
|
|
88
84
|
@touchstart="onBackdropInteraction"
|
|
89
85
|
></div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { CssClasses } from "@/index";
|
|
3
|
-
import { defineProps, provide
|
|
3
|
+
import { defineProps, provide } from "vue";
|
|
4
4
|
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
active: {
|
|
@@ -26,19 +26,12 @@ const props = defineProps({
|
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
const attrs = useAttrs();
|
|
30
|
-
|
|
31
29
|
provide("active", props.active);
|
|
32
30
|
provide("hover", props.hover);
|
|
33
31
|
</script>
|
|
34
32
|
|
|
35
33
|
<template>
|
|
36
|
-
<div
|
|
37
|
-
class="v-rail"
|
|
38
|
-
:class="`grid h-full w-[70px] grid-rows-[auto_1fr_auto] gap-0 overflow-y-auto sm:w-20 ${
|
|
39
|
-
attrs.class || ''
|
|
40
|
-
}`"
|
|
41
|
-
>
|
|
34
|
+
<div class="v-rail grid h-full w-[70px] grid-rows-[auto_1fr_auto] gap-0 overflow-y-auto sm:w-20">
|
|
42
35
|
<div class="v-bar-lead" :class="regionLead"><slot name="lead" /></div>
|
|
43
36
|
<div class="v-bar-default" :class="regionDefault"><slot /></div>
|
|
44
37
|
<div class="v-bar-trail" :class="regionTrail"><slot name="trail" /></div>
|
|
@@ -61,22 +61,23 @@ const keyupHandler = (event: KeyboardEvent) => {
|
|
|
61
61
|
</script>
|
|
62
62
|
|
|
63
63
|
<template>
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
64
|
+
<component
|
|
65
|
+
@click="clickHandler"
|
|
66
|
+
@keydown="keydownHandler"
|
|
67
|
+
@keyup="keyupHandler"
|
|
68
|
+
:is="tag"
|
|
69
|
+
v-bind="attrs"
|
|
70
|
+
:class="`app-rail-tile unstyled grid aspect-square w-full cursor-pointer place-content-center place-items-center space-y-1.5 ${hover} ${
|
|
71
|
+
selectedRailTile === value ? `${active}` : ''
|
|
72
|
+
}`"
|
|
73
|
+
>
|
|
74
|
+
<template v-if="$slots.default">
|
|
75
|
+
<div :class="`app-rail-tile-icon ${regionIcon}`"><slot /></div>
|
|
76
|
+
</template>
|
|
77
|
+
<template v-if="label">
|
|
78
|
+
<div :class="`app-rail-tile-label text-center text-xs font-bold ${regionLabel}`">
|
|
79
|
+
{{ label }}
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
</component>
|
|
82
83
|
</template>
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* @slot pageFooter - Insert content that resides below your page content. Recommended for most layouts.
|
|
8
8
|
* @slot fixedFooter - Insert fixed footer content. Not recommended for most layouts.
|
|
9
9
|
*/
|
|
10
|
-
import { useAttrs } from "vue";
|
|
11
10
|
export type CssClasses = string;
|
|
12
11
|
defineProps({
|
|
13
12
|
regionPage: { type: String as () => CssClasses, default: "" },
|
|
@@ -19,11 +18,10 @@ defineProps({
|
|
|
19
18
|
slotPageFooter: { type: String as () => CssClasses, default: "" },
|
|
20
19
|
slotFixedFooter: { type: String as () => CssClasses, default: "" },
|
|
21
20
|
});
|
|
22
|
-
const attrs = useAttrs();
|
|
23
21
|
</script>
|
|
24
22
|
|
|
25
23
|
<template>
|
|
26
|
-
<div
|
|
24
|
+
<div class="vuetiful-shell flex h-full w-full flex-col overflow-hidden">
|
|
27
25
|
<header v-if="$slots.fixedHeader" :class="`vuetiful-fixed-header ${slotFixedHeader}`">
|
|
28
26
|
<slot name="fixedHeader" />
|
|
29
27
|
</header>
|
package/src/styles/core.css
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { CssClasses, vClipboard } from "@/index";
|
|
3
|
+
import "highlight.js/styles/github-dark.css";
|
|
4
|
+
import { ref } from "vue";
|
|
5
|
+
import { useHighlight } from "./highlight.service";
|
|
6
|
+
|
|
7
|
+
const { highlight } = useHighlight();
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
language: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: "plaintext",
|
|
13
|
+
},
|
|
14
|
+
code: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "",
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
headerClass: {
|
|
20
|
+
type: String as () => CssClasses,
|
|
21
|
+
},
|
|
22
|
+
preClass: {
|
|
23
|
+
type: String as () => CssClasses,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
buttonClass: {
|
|
27
|
+
type: String as () => CssClasses,
|
|
28
|
+
default: "btn btn-sm variant-soft !text-white",
|
|
29
|
+
},
|
|
30
|
+
buttonText: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "Copy",
|
|
33
|
+
},
|
|
34
|
+
buttonCopiedText: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: "👍",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits<{
|
|
41
|
+
(event: "copy"): void;
|
|
42
|
+
}>();
|
|
43
|
+
|
|
44
|
+
const copyState = ref(false);
|
|
45
|
+
|
|
46
|
+
// Allow shorthand alias, but show full text in UI
|
|
47
|
+
function languageFormatter(lang: string): string {
|
|
48
|
+
if (lang === "js") return "javascript";
|
|
49
|
+
if (lang === "ts") return "typescript";
|
|
50
|
+
if (["sh", "bash", "zsh", "shell"].includes(lang)) return "console";
|
|
51
|
+
return lang;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function onCopyClick() {
|
|
55
|
+
copyState.value = true;
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
copyState.value = false;
|
|
58
|
+
}, 2000);
|
|
59
|
+
emit("copy");
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template v-if="language && code">
|
|
64
|
+
<div class="code-block bg-neutral-900/90 text-sm text-white shadow rounded-container-token">
|
|
65
|
+
<header
|
|
66
|
+
:class="`code-block-header flex items-center justify-between p-2 pb-0 pl-4 text-xs uppercase text-white/50 ${headerClass}`"
|
|
67
|
+
>
|
|
68
|
+
<span :class="`code-block-language`">{{ languageFormatter(language) }}</span>
|
|
69
|
+
<button
|
|
70
|
+
:class="`code-block-btn ${buttonClass}`"
|
|
71
|
+
@click="onCopyClick()"
|
|
72
|
+
v-clipboard="props.code"
|
|
73
|
+
>
|
|
74
|
+
{{ !copyState ? buttonText : buttonCopiedText }}
|
|
75
|
+
</button>
|
|
76
|
+
</header>
|
|
77
|
+
<pre
|
|
78
|
+
:class="`code-block-pre whitespace-pre-wrap break-all p-4 pt-1 ${preClass}`"
|
|
79
|
+
><code :class="`code-block-code language-${language}`" v-html="highlight(props.code, props.language)"></code></pre>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
package/src/utils/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import VCodeBlock from "./code-block/VCodeBlock.vue";
|
|
2
2
|
import { useDarkMode } from "./dark-mode/dark-mode.service";
|
|
3
3
|
import DarkModeSwitch from "./dark-mode/dark-mode.vue";
|
|
4
4
|
import ThemeSwitcher from "./theme/theme-switcher.vue";
|
|
5
5
|
import { useTheme } from "./theme/theme.service";
|
|
6
6
|
|
|
7
|
-
export { DarkModeSwitch, ThemeSwitcher, useDarkMode, useTheme,
|
|
7
|
+
export { DarkModeSwitch, ThemeSwitcher, useDarkMode, useTheme, VCodeBlock };
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { CssClasses, vClipboard } from "@/index";
|
|
3
|
-
import "highlight.js/styles/github-dark.css";
|
|
4
|
-
import { computed, ref, useAttrs } from "vue";
|
|
5
|
-
import { useHighlight } from "./highlight.service";
|
|
6
|
-
|
|
7
|
-
const { highlight } = useHighlight();
|
|
8
|
-
|
|
9
|
-
const props = defineProps({
|
|
10
|
-
language: {
|
|
11
|
-
type: String,
|
|
12
|
-
default: "plaintext",
|
|
13
|
-
},
|
|
14
|
-
code: {
|
|
15
|
-
type: String,
|
|
16
|
-
default: "",
|
|
17
|
-
},
|
|
18
|
-
background: {
|
|
19
|
-
type: String as () => CssClasses,
|
|
20
|
-
default: "bg-neutral-900/90",
|
|
21
|
-
},
|
|
22
|
-
blur: {
|
|
23
|
-
type: String as () => CssClasses,
|
|
24
|
-
default: "",
|
|
25
|
-
},
|
|
26
|
-
text: {
|
|
27
|
-
type: String as () => CssClasses,
|
|
28
|
-
default: "text-sm",
|
|
29
|
-
},
|
|
30
|
-
color: {
|
|
31
|
-
type: String as () => CssClasses,
|
|
32
|
-
default: "text-white",
|
|
33
|
-
},
|
|
34
|
-
rounded: {
|
|
35
|
-
type: String as () => CssClasses,
|
|
36
|
-
default: "rounded-container-token",
|
|
37
|
-
},
|
|
38
|
-
shadow: {
|
|
39
|
-
type: String as () => CssClasses,
|
|
40
|
-
default: "shadow",
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
button: {
|
|
44
|
-
type: String as () => CssClasses,
|
|
45
|
-
default: "btn btn-sm variant-soft !text-white",
|
|
46
|
-
},
|
|
47
|
-
buttonLabel: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: "Copy",
|
|
50
|
-
},
|
|
51
|
-
buttonCopied: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: "👍",
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const attrs = useAttrs();
|
|
58
|
-
const emit = defineEmits<{
|
|
59
|
-
(event: "copy"): void;
|
|
60
|
-
}>();
|
|
61
|
-
|
|
62
|
-
const cBase = "overflow-hidden shadow";
|
|
63
|
-
const cHeader = "text-xs text-white/50 uppercase flex justify-between items-center p-2 pl-4 pb-0";
|
|
64
|
-
const cPre = "whitespace-pre-wrap break-all p-4 pt-1";
|
|
65
|
-
|
|
66
|
-
const copyState = ref(false);
|
|
67
|
-
|
|
68
|
-
// Allow shorthand alias, but show full text in UI
|
|
69
|
-
function languageFormatter(lang: string): string {
|
|
70
|
-
if (lang === "js") return "javascript";
|
|
71
|
-
if (lang === "ts") return "typescript";
|
|
72
|
-
if (["sh", "bash", "zsh", "shell"].includes(lang)) return "console";
|
|
73
|
-
return lang;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function onCopyClick() {
|
|
77
|
-
copyState.value = true;
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
copyState.value = false;
|
|
80
|
-
}, 2000);
|
|
81
|
-
emit("copy");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Reactive
|
|
85
|
-
const classesBase = computed(
|
|
86
|
-
() =>
|
|
87
|
-
`${cBase} ${props.background} ${props.blur} ${props.text} ${props.color} ${props.rounded} ${
|
|
88
|
-
props.shadow
|
|
89
|
-
} ${attrs.class ?? ""}`
|
|
90
|
-
);
|
|
91
|
-
</script>
|
|
92
|
-
|
|
93
|
-
<!-- prettier-ignore -->
|
|
94
|
-
<template>
|
|
95
|
-
<div v-if="language && code">
|
|
96
|
-
<div :class="`code-block ${classesBase}`" data-testid="code-block">
|
|
97
|
-
<header :class="`code-block-header ${cHeader}`">
|
|
98
|
-
<span :class="`code-block-language`">{{languageFormatter(language)}}</span>
|
|
99
|
-
<button :class="`code-block-btn ${button}`" @click="onCopyClick()" v-clipboard="props.code">
|
|
100
|
-
{{!copyState ? buttonLabel : buttonCopied}}
|
|
101
|
-
</button>
|
|
102
|
-
</header>
|
|
103
|
-
<pre :class="`code-block-pre ${cPre}`"><code :class="`code-block-code language-${language}`" v-html="highlight(props.code, props.language)"></code></pre>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
</template>
|