vanilla-vue-ui 0.0.24 → 0.0.26
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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Replace vue3 with vue if you are using Storybook for Vue 2
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
3
|
+
import GameDialog from './GameDialog.vue';
|
|
4
|
+
|
|
5
|
+
type GameDialogProps = InstanceType<typeof GameDialog>['$props']
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof GameDialog> = {
|
|
8
|
+
component: GameDialog,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof GameDialog>;
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
|
|
16
|
+
* See https://storybook.js.org/docs/api/csf
|
|
17
|
+
* to learn how to use render functions.
|
|
18
|
+
*/
|
|
19
|
+
export const Primary: Story = {
|
|
20
|
+
render: (args: GameDialogProps) => ({
|
|
21
|
+
setup() {
|
|
22
|
+
return { args }
|
|
23
|
+
},
|
|
24
|
+
components: { GameDialog },
|
|
25
|
+
template: '<GameDialog v-bind="args" />',
|
|
26
|
+
}),
|
|
27
|
+
args: {
|
|
28
|
+
text: 'こんにちは',
|
|
29
|
+
link: '/ja/blog/tag/半年チャレンジ/',
|
|
30
|
+
linkLabel: 'こちら',
|
|
31
|
+
speed: 200,
|
|
32
|
+
autoStart: true,
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="
|
|
4
|
+
relative max-w-sm text-white select-none
|
|
5
|
+
bg-black
|
|
6
|
+
transition-all duration-150 ease-out
|
|
7
|
+
origin-bottom
|
|
8
|
+
animate-[dialogPop_0.2s_ease-out]
|
|
9
|
+
"
|
|
10
|
+
@click="skip"
|
|
11
|
+
>
|
|
12
|
+
<span>{{ displayText }}</span>
|
|
13
|
+
|
|
14
|
+
<a
|
|
15
|
+
v-if="isFinished && link"
|
|
16
|
+
:href="link"
|
|
17
|
+
class="
|
|
18
|
+
ml-2 inline-block text-yellow-400
|
|
19
|
+
animate-[dialogBlink_1.2s_steps(2)_infinite]
|
|
20
|
+
hover:underline
|
|
21
|
+
"
|
|
22
|
+
>
|
|
23
|
+
▶ {{ linkLabel }}
|
|
24
|
+
</a>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import { ref, onMounted, watch } from 'vue'
|
|
30
|
+
|
|
31
|
+
const props = withDefaults(defineProps<{
|
|
32
|
+
text: string
|
|
33
|
+
speed?: number
|
|
34
|
+
link?: string
|
|
35
|
+
linkLabel?: string
|
|
36
|
+
autoStart?: boolean
|
|
37
|
+
}>(), {
|
|
38
|
+
speed: 60,
|
|
39
|
+
link: '',
|
|
40
|
+
linkLabel: 'つづく',
|
|
41
|
+
autoStart: true,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const displayText = ref('')
|
|
45
|
+
const isFinished = ref(false)
|
|
46
|
+
|
|
47
|
+
let index = 0
|
|
48
|
+
let timer: number | null = null
|
|
49
|
+
|
|
50
|
+
const start = () => {
|
|
51
|
+
clear()
|
|
52
|
+
displayText.value = ''
|
|
53
|
+
isFinished.value = false
|
|
54
|
+
index = 0
|
|
55
|
+
|
|
56
|
+
timer = window.setInterval(() => {
|
|
57
|
+
displayText.value += props.text[index]
|
|
58
|
+
index++
|
|
59
|
+
|
|
60
|
+
if (index >= props.text.length) finish()
|
|
61
|
+
}, props.speed)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const finish = () => {
|
|
65
|
+
clear()
|
|
66
|
+
isFinished.value = true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const clear = () => {
|
|
70
|
+
if (timer !== null) {
|
|
71
|
+
clearInterval(timer)
|
|
72
|
+
timer = null
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const skip = () => {
|
|
77
|
+
if (!isFinished.value) {
|
|
78
|
+
displayText.value = props.text
|
|
79
|
+
finish()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
if (props.autoStart) start()
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
watch(() => props.text, () => {
|
|
88
|
+
if (props.autoStart) start()
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
defineExpose({ start, finish })
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<style scoped>
|
|
95
|
+
@keyframes dialogPop {
|
|
96
|
+
from {
|
|
97
|
+
transform: scale(0.95);
|
|
98
|
+
opacity: 0;
|
|
99
|
+
}
|
|
100
|
+
to {
|
|
101
|
+
transform: scale(1);
|
|
102
|
+
opacity: 1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@keyframes dialogBlink {
|
|
107
|
+
50% { opacity: 0.3 }
|
|
108
|
+
}
|
|
109
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
|
|
3
|
+
import WTagLink from './WTagLink.vue';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof WTagLink> = {
|
|
6
|
+
component: WTagLink,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof WTagLink>;
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
|
|
14
|
+
* See https://storybook.js.org/docs/api/csf
|
|
15
|
+
* to learn how to use render functions.
|
|
16
|
+
*/
|
|
17
|
+
export const Primary: Story = {
|
|
18
|
+
render: () => ({
|
|
19
|
+
components: { WTagLink },
|
|
20
|
+
template: '<WTagLink to="/to">content</WTagLink>',
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a
|
|
3
|
+
:href="to"
|
|
4
|
+
class="
|
|
5
|
+
inline-flex items-center
|
|
6
|
+
h-8 pr-2 p-0
|
|
7
|
+
gap-2
|
|
8
|
+
rounded-full
|
|
9
|
+
bg-white
|
|
10
|
+
box-border border-2 border-black
|
|
11
|
+
shadow-sm
|
|
12
|
+
hover:shadow-md
|
|
13
|
+
hover:-translate-y-0.5
|
|
14
|
+
transition-all duration-150
|
|
15
|
+
relative
|
|
16
|
+
"
|
|
17
|
+
>
|
|
18
|
+
<span
|
|
19
|
+
class="
|
|
20
|
+
flex items-center justify-center
|
|
21
|
+
h-8 w-8
|
|
22
|
+
rounded-full
|
|
23
|
+
bg-orange-400
|
|
24
|
+
text-white
|
|
25
|
+
text-2xl
|
|
26
|
+
shrink-0
|
|
27
|
+
absolute -top-0.5 -left-1
|
|
28
|
+
border-2 border-black
|
|
29
|
+
"
|
|
30
|
+
>
|
|
31
|
+
#
|
|
32
|
+
</span>
|
|
33
|
+
|
|
34
|
+
<span
|
|
35
|
+
class="
|
|
36
|
+
text-gray-800
|
|
37
|
+
text-sm
|
|
38
|
+
font-medium
|
|
39
|
+
truncate
|
|
40
|
+
pl-8
|
|
41
|
+
"
|
|
42
|
+
>
|
|
43
|
+
<slot />
|
|
44
|
+
</span>
|
|
45
|
+
</a>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script setup lang="ts">
|
|
49
|
+
defineProps<{
|
|
50
|
+
to: string
|
|
51
|
+
}>()
|
|
52
|
+
</script>
|