mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00
refactor(search): command palette design (#463)
This commit is contained in:
parent
732da08157
commit
bcb98b359c
18 changed files with 576 additions and 386 deletions
15
src/ui/c-modal/c-modal.demo.vue
Normal file
15
src/ui/c-modal/c-modal.demo.vue
Normal file
|
@ -0,0 +1,15 @@
|
|||
<script lang="ts" setup>
|
||||
const modal1 = ref();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-button @click="() => modal1?.open()">
|
||||
Open Modal
|
||||
</c-button>
|
||||
|
||||
<c-modal ref="modal1">
|
||||
Content
|
||||
</c-modal>
|
||||
</div>
|
||||
</template>
|
11
src/ui/c-modal/c-modal.theme.ts
Normal file
11
src/ui/c-modal/c-modal.theme.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { defineThemes } from '../theme/theme.models';
|
||||
import { appThemes } from '../theme/themes';
|
||||
|
||||
export const { useTheme } = defineThemes({
|
||||
dark: {
|
||||
background: appThemes.dark.background,
|
||||
},
|
||||
light: {
|
||||
background: appThemes.light.background,
|
||||
},
|
||||
});
|
74
src/ui/c-modal/c-modal.vue
Normal file
74
src/ui/c-modal/c-modal.vue
Normal file
|
@ -0,0 +1,74 @@
|
|||
<script setup lang="ts">
|
||||
import { useTheme } from './c-modal.theme';
|
||||
|
||||
const props = withDefaults(defineProps<{ open?: boolean; centered?: boolean }>(), {
|
||||
open: false,
|
||||
centered: true,
|
||||
});
|
||||
const emit = defineEmits(['update:open']);
|
||||
const isOpen = useVModel(props, 'open', emit, { passive: true });
|
||||
|
||||
const { centered } = toRefs(props);
|
||||
|
||||
function close() {
|
||||
isOpen.value = false;
|
||||
}
|
||||
|
||||
function open() {
|
||||
isOpen.value = true;
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
isOpen.value = !isOpen.value;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
close,
|
||||
open,
|
||||
toggle,
|
||||
isOpen,
|
||||
});
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
const theme = useTheme();
|
||||
const modal = ref();
|
||||
|
||||
onClickOutside(modal, () => {
|
||||
if (isOpen.value) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<transition>
|
||||
<div v-if="isOpen" class="c-modal--overlay" fixed left-0 top-0 z-10 h-full w-full flex justify-center px-2 :class="{ 'items-center': centered }">
|
||||
<div ref="modal" class="c-modal--container" v-bind="$attrs" max-w-xl w-full flex-grow rounded-md pa-24px>
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
.c-modal--overlay {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.c-modal--container {
|
||||
background-color: v-bind('theme.background');
|
||||
}
|
||||
|
||||
.v-enter-active,
|
||||
.v-leave-active {
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.v-enter-from,
|
||||
.v-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue