Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add style to work with v-calendar time picker (#243) #265

Merged
merged 4 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/www/__registry__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ export const Index = {
component: () => import('../src/lib/registry/default/example/DatePickerWithRange.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/DatePickerWithRange.vue'],
},
DateTimePickerDemo: {
name: 'DateTimePickerDemo',
type: 'components:example',
registryDependencies: ['utils', 'button', 'calendar', 'popover'],
component: () => import('../src/lib/registry/default/example/DateTimePickerDemo.vue').then(m => m.default),
files: ['../src/lib/registry/default/example/DateTimePickerDemo.vue'],
},
DialogCustomCloseButton: {
name: 'DialogCustomCloseButton',
type: 'components:example',
Expand Down Expand Up @@ -1194,6 +1201,13 @@ export const Index = {
component: () => import('../src/lib/registry/new-york/example/DatePickerWithRange.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/DatePickerWithRange.vue'],
},
DateTimePickerDemo: {
name: 'DateTimePickerDemo',
type: 'components:example',
registryDependencies: ['utils', 'button', 'calendar', 'popover'],
component: () => import('../src/lib/registry/new-york/example/DateTimePickerDemo.vue').then(m => m.default),
files: ['../src/lib/registry/new-york/example/DateTimePickerDemo.vue'],
},
DialogCustomCloseButton: {
name: 'DialogCustomCloseButton',
type: 'components:example',
Expand Down
4 changes: 4 additions & 0 deletions apps/www/src/content/docs/components/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const date = ref<Date>()

<ComponentPreview name="DatePickerWithRange" />

### Date Time Picker

<ComponentPreview name="DateTimePickerDemo" />

### With Presets

<ComponentPreview name="DatePickerWithPresets" />
Expand Down
36 changes: 36 additions & 0 deletions apps/www/src/lib/registry/default/example/DateTimePickerDemo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script setup lang="ts">
import { format } from 'date-fns'
import { Calendar as CalendarIcon } from 'lucide-vue-next'

import { ref } from 'vue'
import { cn } from '@/lib/utils'
import { Button } from '@/lib/registry/default/ui/button'
import { Calendar } from '@/lib/registry/default/ui/calendar'
import {
Popover,
PopoverContent,
PopoverTrigger,
} from '@/lib/registry/default/ui/popover'

const date = ref<Date>()
</script>

<template>
<Popover>
<PopoverTrigger as-child>
<Button
:variant="'outline'"
:class="cn(
'w-[280px] justify-start text-left font-normal',
!date && 'text-muted-foreground',
)"
>
<CalendarIcon class="mr-2 h-4 w-4" />
<span>{{ date ? format(date, 'PPP - hh:mm') : "Pick a date" }}</span>
</Button>
</PopoverTrigger>
<PopoverContent class="w-auto p-0">
<Calendar v-model="date" mode="datetime" />
</PopoverContent>
</Popover>
</template>
45 changes: 45 additions & 0 deletions apps/www/src/lib/registry/default/ui/calendar/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,49 @@ onMounted(async () => {
-webkit-transform: translateY(calc(-1 * var(--vc-slide-translate)));
transform: translateY(calc(-1 * var(--vc-slide-translate)));
}
/**
* Timepicker styles
*/
.vc-time-picker {
@apply flex flex-col items-center p-2;
}
.vc-time-picker.vc-invalid {
@apply pointer-events-none opacity-50;
}
.vc-time-picker.vc-attached {
@apply border-t border-solid border-secondary mt-2;
}
.vc-time-picker > * + * {
@apply mt-1;
}
.vc-time-header {
@apply flex items-center text-sm font-semibold uppercase mt-1 px-1 leading-6;
}
.vc-time-select-group {
@apply inline-flex items-center px-1 rounded-md bg-primary-foreground border border-solid border-secondary;
}
.vc-time-select-group .vc-base-icon {
@apply mr-1 text-primary stroke-primary;
}
.vc-time-select-group select {
@apply bg-primary-foreground p-1 appearance-none outline-none text-center;
}
.vc-time-weekday {
@apply text-muted-foreground tracking-wide;
}
.vc-time-month {
@apply text-primary ml-2;
}
.vc-time-day {
@apply text-primary ml-1;
}
.vc-time-year {
@apply text-muted-foreground ml-2;
}
.vc-time-colon {
@apply mb-0.5;
}
.vc-time-decimal {
@apply ml-0.5;
}
</style>
36 changes: 36 additions & 0 deletions apps/www/src/lib/registry/new-york/example/DateTimePickerDemo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script setup lang="ts">
import { format } from 'date-fns'
import { ref } from 'vue'
import { CalendarIcon } from '@radix-icons/vue'

import { cn } from '@/lib/utils'
import { Button } from '@/lib/registry/new-york/ui/button'
import { Calendar } from '@/lib/registry/new-york/ui/calendar'
import {
Popover,
PopoverContent,
PopoverTrigger,
} from '@/lib/registry/new-york/ui/popover'

const date = ref<Date>()
</script>

<template>
<Popover>
<PopoverTrigger as-child>
<Button
:variant="'outline'"
:class="cn(
'w-[280px] justify-start text-left font-normal',
!date && 'text-muted-foreground',
)"
>
<CalendarIcon class="mr-2 h-4 w-4" />
<span>{{ date ? format(date, 'PPP - hh:mm') : "Pick a date" }}</span>
</Button>
</PopoverTrigger>
<PopoverContent class="w-auto p-0">
<Calendar v-model="date" mode="datetime" />
</PopoverContent>
</Popover>
</template>
45 changes: 45 additions & 0 deletions apps/www/src/lib/registry/new-york/ui/calendar/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,49 @@ onMounted(async () => {
-webkit-transform: translateY(calc(-1 * var(--vc-slide-translate)));
transform: translateY(calc(-1 * var(--vc-slide-translate)));
}
/**
* Timepicker styles
*/
.vc-time-picker {
@apply flex flex-col items-center p-2;
}
.vc-time-picker.vc-invalid {
@apply pointer-events-none opacity-50;
}
.vc-time-picker.vc-attached {
@apply border-t border-solid border-secondary mt-2;
}
.vc-time-picker > * + * {
@apply mt-1;
}
.vc-time-header {
@apply flex items-center text-sm font-semibold uppercase mt-1 px-1 leading-6;
}
.vc-time-select-group {
@apply inline-flex items-center px-1 rounded-md bg-primary-foreground border border-solid border-secondary;
}
.vc-time-select-group .vc-base-icon {
@apply mr-1 text-primary stroke-primary;
}
.vc-time-select-group select {
@apply bg-primary-foreground p-1 appearance-none outline-none text-center;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sadeghbarati The problem is that by doing bg-primary-foreground instead of transparent, it broke the edges:
CleanShot 2024-01-12 at 17 40 07@2x

}
.vc-time-weekday {
@apply text-muted-foreground tracking-wide;
}
.vc-time-month {
@apply text-primary ml-2;
}
.vc-time-day {
@apply text-primary ml-1;
}
.vc-time-year {
@apply text-muted-foreground ml-2;
}
.vc-time-colon {
@apply mb-0.5;
}
.vc-time-decimal {
@apply ml-0.5;
}
</style>
2 changes: 1 addition & 1 deletion apps/www/src/public/registry/styles/default/calendar.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/src/public/registry/styles/new-york/calendar.json

Large diffs are not rendered by default.

Loading