mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-02-05 14:48:03 +01:00
docs(date-picker): improve examples responsive
This commit is contained in:
@@ -27,8 +27,8 @@ function selectRange (duration: Duration) {
|
|||||||
</UButton>
|
</UButton>
|
||||||
|
|
||||||
<template #panel="{ close }">
|
<template #panel="{ close }">
|
||||||
<div class="flex items-center divide-x divide-gray-200 dark:divide-gray-800">
|
<div class="flex items-center sm:divide-x divide-gray-200 dark:divide-gray-800">
|
||||||
<div class="flex flex-col py-4">
|
<div class="hidden sm:flex flex-col py-4">
|
||||||
<UButton
|
<UButton
|
||||||
v-for="(range, index) in ranges"
|
v-for="(range, index) in ranges"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -37,6 +37,7 @@ function selectRange (duration: Duration) {
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
class="rounded-none px-6"
|
class="rounded-none px-6"
|
||||||
:class="[isRangeSelected(range.duration) ? 'bg-gray-100 dark:bg-gray-800' : 'hover:bg-gray-50 dark:hover:bg-gray-800/50']"
|
:class="[isRangeSelected(range.duration) ? 'bg-gray-100 dark:bg-gray-800' : 'hover:bg-gray-50 dark:hover:bg-gray-800/50']"
|
||||||
|
truncate
|
||||||
@click="selectRange(range.duration)"
|
@click="selectRange(range.duration)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { useBreakpoints, breakpointsTailwind } from '@vueuse/core'
|
||||||
import { DatePicker as VCalendarDatePicker } from 'v-calendar'
|
import { DatePicker as VCalendarDatePicker } from 'v-calendar'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import type { DatePickerDate, DatePickerRangeObject } from 'v-calendar/dist/types/src/use/datePicker'
|
import type { DatePickerDate, DatePickerRangeObject } from 'v-calendar/dist/types/src/use/datePicker'
|
||||||
@@ -25,6 +26,10 @@ const date = computed({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const breakpoints = useBreakpoints(breakpointsTailwind)
|
||||||
|
|
||||||
|
const smallerThanSm = breakpoints.smaller('sm')
|
||||||
|
|
||||||
const attrs = {
|
const attrs = {
|
||||||
transparent: true,
|
transparent: true,
|
||||||
borderless: true,
|
borderless: true,
|
||||||
@@ -35,7 +40,7 @@ const attrs = {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VCalendarDatePicker v-if="date && (date as DatePickerRangeObject)?.start && (date as DatePickerRangeObject)?.end" v-model.range="date" :columns="2" v-bind="{ ...attrs, ...$attrs }" />
|
<VCalendarDatePicker v-if="date && (date as DatePickerRangeObject)?.start && (date as DatePickerRangeObject)?.end" v-model.range="date" :columns="smallerThanSm ? 1 : 2" :rows="smallerThanSm ? 2 : 1" v-bind="{ ...attrs, ...$attrs }" />
|
||||||
<VCalendarDatePicker v-else v-model="date" v-bind="{ ...attrs, ...$attrs }" />
|
<VCalendarDatePicker v-else v-model="date" v-bind="{ ...attrs, ...$attrs }" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user