FMHYedit/.vitepress/theme/components/Feedback2.vue

158 lines
4.0 KiB
Vue
Raw Normal View History

2023-11-14 15:10:49 +00:00
<script setup lang="ts">
2024-01-25 16:32:45 +00:00
import { ref } from 'vue'
2023-11-14 15:10:49 +00:00
import {
TransitionRoot,
TransitionChild,
Dialog,
DialogPanel,
DialogTitle,
2024-01-25 16:32:45 +00:00
DialogDescription
} from '@headlessui/vue'
2023-11-14 15:10:49 +00:00
2024-01-25 16:32:45 +00:00
const isOpen = ref(true)
2023-11-14 15:10:49 +00:00
const feedbackOptions = [
{
2024-01-25 16:32:45 +00:00
label: '💡 Suggestion',
value: 'suggestion'
2023-11-14 15:10:49 +00:00
},
{
2024-01-25 16:32:45 +00:00
label: '❤️ Appreciation',
value: 'appreciate'
2023-11-14 15:10:49 +00:00
},
2024-01-25 16:32:45 +00:00
{ label: '🐞 Bug', value: 'bug' },
{ label: '📂 Other', value: 'other' }
]
2023-11-14 15:10:49 +00:00
function closeModal() {
2024-01-25 16:32:45 +00:00
isOpen.value = false
2023-11-14 15:10:49 +00:00
}
function openModal() {
2024-01-25 16:32:45 +00:00
isOpen.value = true
2023-11-14 15:10:49 +00:00
}
</script>
<template>
2023-11-14 17:18:52 +00:00
<button
type="button"
class="p-[4px 8px] text-xl i-carbon:user-favorite-alt-filled"
2024-01-25 16:32:45 +00:00
@click="openModal"
/>
2023-11-14 15:10:49 +00:00
<TransitionRoot appear :show="isOpen" as="template">
2023-11-14 17:18:52 +00:00
<Dialog as="div" class="relative z-10" @close="closeModal">
<TransitionChild
as="template"
enter="duration-300 ease-out"
enter-from="opacity-0"
enter-to="opacity-100"
leave="duration-200 ease-in"
leave-from="opacity-100"
2024-01-25 16:32:45 +00:00
leave-to="opacity-0"
>
2023-11-14 15:10:49 +00:00
<div class="fixed inset-0 bg-black/25" />
</TransitionChild>
<div class="fixed inset-0 overflow-y-auto">
2024-01-25 16:32:45 +00:00
<div
class="flex min-h-full items-center justify-center p-4 text-center"
>
2023-11-14 17:18:52 +00:00
<TransitionChild
as="template"
enter="duration-300 ease-out"
enter-from="opacity-0 scale-95"
enter-to="opacity-100 scale-100"
leave="duration-200 ease-in"
leave-from="opacity-100 scale-100"
2024-01-25 16:32:45 +00:00
leave-to="opacity-0 scale-95"
>
2023-11-14 15:10:49 +00:00
<DialogPanel
2024-01-25 16:32:45 +00:00
class="w-full max-w-md transform overflow-hidden rounded-2xl bg-bg p-6 text-left align-middle shadow-xl transition-all"
>
<DialogTitle
as="h3"
class="text-lg font-medium leading-6 text-text"
>
2023-11-14 15:10:49 +00:00
Feedback
</DialogTitle>
<div class="mt-2">
<div class="grid gap-[0.5rem]">
2023-11-14 17:18:52 +00:00
<button
v-for="item in feedbackOptions"
:key="item.value"
2024-01-25 16:32:45 +00:00
class="inline-flex justify-center rounded-md border border-transparent bg-bg-alt px-4 py-2 text-sm font-medium text-text hover:border-primary focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2"
>
2023-11-14 15:10:49 +00:00
<span>{{ item.label }}</span>
</button>
</div>
</div>
2023-11-14 17:18:52 +00:00
<div class="mt-2">
<div>
2023-11-19 08:57:14 +00:00
<label class="field-label">Feedback*</label>
2023-11-14 15:10:49 +00:00
2023-11-19 08:57:14 +00:00
<textarea placeholder="meow" rows="5" />
2023-11-14 17:18:52 +00:00
</div>
2023-11-14 15:10:49 +00:00
</div>
<div class="mt-4">
2023-11-14 17:18:52 +00:00
<button
type="button"
2023-11-14 15:10:49 +00:00
class="inline-flex justify-center rounded-md border border-transparent bg-blue-100 px-4 py-2 text-sm font-medium text-blue-900 hover:bg-blue-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"
2024-01-25 16:32:45 +00:00
@click="closeModal"
>
2023-11-14 15:10:49 +00:00
Close
</button>
</div>
</DialogPanel>
</TransitionChild>
</div>
</div>
</Dialog>
</TransitionRoot>
</template>
<style scoped>
textarea,
input {
font-family: var(--vp-font-family-base);
background: var(--vp-c-bg-soft);
font-size: 14px;
border-radius: 4px;
padding: 16px;
width: 100%;
&::placeholder {
color: var(--vp-c-text-2) !important;
opacity: 1;
}
}
.btn {
border: 1px solid var(--vp-c-divider);
background-color: var(--vp-c-bg);
border-radius: 8px;
transition:
border-color 0.25s,
background-color 0.25s;
display: inline-block;
font-size: 14px;
font-weight: 500;
line-height: 1.5;
margin: 0;
padding: 0.375rem 0.75rem;
text-align: center;
vertical-align: middle;
white-space: nowrap;
}
.btn:disabled {
opacity: 0.5;
}
.btn:hover {
border-color: var(--vp-c-brand);
}
</style>