mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(ui): add the Vue component kit with UiRail, UiTooltip and UiIcon
This commit is contained in:
1 parent
c13c487dcf
commit
7307c11c74
13 files changed
+340
-3
No files matched your search
@@ -0,0 +1,50 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, ref } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
text: { type: String, required: true },
|
||||
/** Which side of the trigger the tip opens on. */
|
||||
side: { type: String, default: 'right' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
/** Milliseconds the pointer rests before the tip shows. */
|
||||
delay: { type: Number, default: 0 },
|
||||
});
|
||||
|
||||
const open = ref(false);
|
||||
let timer = null;
|
||||
|
||||
function show() {
|
||||
if (props.disabled) return;
|
||||
clearTimeout(timer);
|
||||
if (props.delay > 0)
|
||||
timer = setTimeout(() => (open.value = true), props.delay);
|
||||
else open.value = true;
|
||||
}
|
||||
|
||||
function hide() {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
open.value = false;
|
||||
}
|
||||
|
||||
onBeforeUnmount(hide);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
class="ui-tooltip"
|
||||
@pointerenter="show"
|
||||
@pointerleave="hide"
|
||||
@focusin="show"
|
||||
@focusout="hide"
|
||||
>
|
||||
<slot />
|
||||
<span
|
||||
v-if="open && !disabled"
|
||||
class="ui-tooltip__tip"
|
||||
:class="`ui-tooltip__tip--${side}`"
|
||||
role="tooltip"
|
||||
>{{ text }}</span
|
||||
>
|
||||
</span>
|
||||
</template>
|
||||
Reference in new issue
Block a user