From 015509abf820d6a224b2828e7a9b91dc0f1412dc Mon Sep 17 00:00:00 2001
From: Alexis <35.alexis.pele@gmail.com>
Date: Tue, 2 Apr 2024 20:38:59 +0200
Subject: [PATCH] Added basic event details
---
src/components/calendar/CalendarEvent.vue | 24 ++++++++--
.../calendar/CalendarEventDetails.vue | 25 ++++++++++
src/components/calendar/CalendarMenu.vue | 2 +-
src/components/calendar/CalendarTile.vue | 2 +-
src/components/ui/button/Button.vue | 2 +-
src/components/ui/button/index.ts | 23 ++++-----
src/components/ui/popover/Popover.vue | 15 ++++++
src/components/ui/popover/PopoverContent.vue | 48 +++++++++++++++++++
src/components/ui/popover/PopoverTrigger.vue | 11 +++++
src/components/ui/popover/index.ts | 3 ++
src/components/ui/select/SelectContent.vue | 32 ++++++++-----
src/components/ui/select/SelectItem.vue | 4 +-
.../ui/select/SelectScrollDownButton.vue | 11 ++++-
.../ui/select/SelectScrollUpButton.vue | 5 +-
src/components/ui/select/SelectTrigger.vue | 10 ++--
src/stores/calendar.ts | 41 +++++++++++-----
16 files changed, 204 insertions(+), 54 deletions(-)
create mode 100644 src/components/calendar/CalendarEventDetails.vue
create mode 100644 src/components/ui/popover/Popover.vue
create mode 100644 src/components/ui/popover/PopoverContent.vue
create mode 100644 src/components/ui/popover/PopoverTrigger.vue
create mode 100644 src/components/ui/popover/index.ts
diff --git a/src/components/calendar/CalendarEvent.vue b/src/components/calendar/CalendarEvent.vue
index be4b5ad..f4b9f29 100644
--- a/src/components/calendar/CalendarEvent.vue
+++ b/src/components/calendar/CalendarEvent.vue
@@ -1,15 +1,29 @@
-
+
+
+
+
+
+
+
diff --git a/src/components/calendar/CalendarEventDetails.vue b/src/components/calendar/CalendarEventDetails.vue
new file mode 100644
index 0000000..7bf59fb
--- /dev/null
+++ b/src/components/calendar/CalendarEventDetails.vue
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ {{ event.title }}
+
+
+ {{ getFormattedDateTitle(event.date, true) }}
+
+
+ {{ event.description }}
+
+
+
+
diff --git a/src/components/calendar/CalendarMenu.vue b/src/components/calendar/CalendarMenu.vue
index 2a5cc44..3ec3693 100644
--- a/src/components/calendar/CalendarMenu.vue
+++ b/src/components/calendar/CalendarMenu.vue
@@ -28,7 +28,7 @@ const {
-
+
-
diff --git a/src/components/ui/button/Button.vue b/src/components/ui/button/Button.vue
index 5cfd668..445baad 100644
--- a/src/components/ui/button/Button.vue
+++ b/src/components/ui/button/Button.vue
@@ -11,7 +11,7 @@ interface Props extends PrimitiveProps {
}
const props = withDefaults(defineProps(), {
- as: 'button',
+ as: 'button'
})
diff --git a/src/components/ui/button/index.ts b/src/components/ui/button/index.ts
index e18f26b..9181371 100644
--- a/src/components/ui/button/index.ts
+++ b/src/components/ui/button/index.ts
@@ -8,27 +8,24 @@ export const buttonVariants = cva(
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
- destructive:
- 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
- outline:
- 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
- secondary:
- 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
+ destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
+ outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
+ secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
- link: 'text-primary underline-offset-4 hover:underline',
+ link: 'text-primary underline-offset-4 hover:underline'
},
size: {
default: 'h-10 px-4 py-2',
- sm: 'h-9 rounded-md px-3',
+ sm: 'h-9 rounded-md px-3 text-sm',
lg: 'h-11 rounded-md px-8',
- icon: 'h-10 w-10',
- },
+ icon: 'h-10 w-10'
+ }
},
defaultVariants: {
variant: 'default',
- size: 'default',
- },
- },
+ size: 'default'
+ }
+ }
)
export type ButtonVariants = VariantProps
diff --git a/src/components/ui/popover/Popover.vue b/src/components/ui/popover/Popover.vue
new file mode 100644
index 0000000..1a5873a
--- /dev/null
+++ b/src/components/ui/popover/Popover.vue
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
diff --git a/src/components/ui/popover/PopoverContent.vue b/src/components/ui/popover/PopoverContent.vue
new file mode 100644
index 0000000..5136fd6
--- /dev/null
+++ b/src/components/ui/popover/PopoverContent.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/components/ui/popover/PopoverTrigger.vue b/src/components/ui/popover/PopoverTrigger.vue
new file mode 100644
index 0000000..22f4772
--- /dev/null
+++ b/src/components/ui/popover/PopoverTrigger.vue
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/src/components/ui/popover/index.ts b/src/components/ui/popover/index.ts
new file mode 100644
index 0000000..495d55a
--- /dev/null
+++ b/src/components/ui/popover/index.ts
@@ -0,0 +1,3 @@
+export { default as Popover } from './Popover.vue'
+export { default as PopoverTrigger } from './PopoverTrigger.vue'
+export { default as PopoverContent } from './PopoverContent.vue'
diff --git a/src/components/ui/select/SelectContent.vue b/src/components/ui/select/SelectContent.vue
index 4fe234b..5371217 100644
--- a/src/components/ui/select/SelectContent.vue
+++ b/src/components/ui/select/SelectContent.vue
@@ -6,20 +6,20 @@ import {
type SelectContentProps,
SelectPortal,
SelectViewport,
- useForwardPropsEmits,
+ useForwardPropsEmits
} from 'radix-vue'
import { SelectScrollDownButton, SelectScrollUpButton } from '.'
import { cn } from '@/lib/utils'
defineOptions({
- inheritAttrs: false,
+ inheritAttrs: false
})
const props = withDefaults(
defineProps(),
{
- position: 'popper',
- },
+ position: 'popper'
+ }
)
const emits = defineEmits()
@@ -35,16 +35,26 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
-
+
diff --git a/src/components/ui/select/SelectItem.vue b/src/components/ui/select/SelectItem.vue
index b102a81..c180b2c 100644
--- a/src/components/ui/select/SelectItem.vue
+++ b/src/components/ui/select/SelectItem.vue
@@ -5,7 +5,7 @@ import {
SelectItemIndicator,
type SelectItemProps,
SelectItemText,
- useForwardProps,
+ useForwardProps
} from 'radix-vue'
import { Check } from 'lucide-vue-next'
import { cn } from '@/lib/utils'
@@ -27,7 +27,7 @@ const forwardedProps = useForwardProps(delegatedProps)
:class="
cn(
'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
- props.class,
+ props.class
)
"
>
diff --git a/src/components/ui/select/SelectScrollDownButton.vue b/src/components/ui/select/SelectScrollDownButton.vue
index 54b6c6a..b4122b6 100644
--- a/src/components/ui/select/SelectScrollDownButton.vue
+++ b/src/components/ui/select/SelectScrollDownButton.vue
@@ -1,6 +1,10 @@
-
+
diff --git a/src/components/ui/select/SelectScrollUpButton.vue b/src/components/ui/select/SelectScrollUpButton.vue
index 5535f1c..3dffaf7 100644
--- a/src/components/ui/select/SelectScrollUpButton.vue
+++ b/src/components/ui/select/SelectScrollUpButton.vue
@@ -16,7 +16,10 @@ const forwardedProps = useForwardProps(delegatedProps)
-
+
diff --git a/src/components/ui/select/SelectTrigger.vue b/src/components/ui/select/SelectTrigger.vue
index cfac8eb..22f7b75 100644
--- a/src/components/ui/select/SelectTrigger.vue
+++ b/src/components/ui/select/SelectTrigger.vue
@@ -18,10 +18,12 @@ const forwardedProps = useForwardProps(delegatedProps)
diff --git a/src/stores/calendar.ts b/src/stores/calendar.ts
index 6de1dfd..9541302 100644
--- a/src/stores/calendar.ts
+++ b/src/stores/calendar.ts
@@ -104,26 +104,27 @@ export const useCalendar = defineStore('calendar', () => {
const currentMonth = computed(() => params.month)
// Gets the label from currentMonth index
- const currentMonthName = computed(() => {
- const index = Number(currentMonth.value)
- return staticConfig.months[index]
- })
+ const currentMonthName = computed(() => getMonthName(Number(currentMonth.value)))
const currentYear = computed(() => params.year)
// Get period from currentYear
- const currentPeriod: ComputedRef = computed(() => {
- const year = Number(currentYear.value)
- return year >= 0 ? 'nante' : 'ante'
- })
- const currentPeriodAbbr: ComputedRef = computed(() => {
- return currentPeriod.value === 'ante' ? 'A.R' : 'N.R'
- })
+ const currentPeriod: ComputedRef = computed(
+ () => getPeriodOfYear(Number(currentYear.value)).long
+ )
+ const currentPeriodAbbr: ComputedRef = computed(
+ () => getPeriodOfYear(Number(currentYear.value)).short
+ )
const currentDateTitle = computed(() => {
switch (currentConfig.value.viewType) {
case 'month':
- return `${currentMonthName.value} ${currentYear.value} ${currentPeriodAbbr.value}`
+ return getFormattedDateTitle({
+ day: Number(currentDate.currentDay.value),
+ month: Number(currentDate.currentMonth.value),
+ year: Number(currentDate.currentYear.value),
+ period: currentDate.currentPeriod.value
+ })
case 'year':
return `Année ${currentYear.value} ${currentPeriodAbbr.value}`
@@ -238,6 +239,19 @@ export const useCalendar = defineStore('calendar', () => {
}
}
+ function getMonthName(monthNumber: number) {
+ const index = Number(monthNumber)
+ return staticConfig.months[index]
+ }
+
+ function getFormattedDateTitle(date: LeimDate, showNumber?: boolean): string {
+ if (showNumber) {
+ return `${date.day} ${getMonthName(date.month)} ${date.year} ${getPeriodOfYear(date.year).short}`
+ }
+
+ return `${getMonthName(date.month)} ${date.year} ${getPeriodOfYear(date.year).short}`
+ }
+
function compareTwoDates(date1: LeimDate, date2: LeimDate) {
// To refacto to be more precise
return JSON.stringify({ ...date1 }) === JSON.stringify({ ...date2 })
@@ -265,6 +279,7 @@ export const useCalendar = defineStore('calendar', () => {
incrementYear,
decrementYear,
jumpToDefaultDate,
- compareTwoDates
+ compareTwoDates,
+ getFormattedDateTitle
}
})