-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: APPS-3049 Create Calendar component (Part 1) (#655)
* task: install vuetify v3.4.9 * task: setup vuetify config * task: install vite vuetify plugin * task: add vuetify lab import to vite config * wip: add minimal calendar * task: uninstall vuetify * task: remove unneeded vuetify plugin folder/file * task: adjusting/refining vuetify config * fix: linting * wip: display test events * wip: calendar navigation * wip: calendar styling/theming * fix: linting * wip: configure storybook vuetify integration * add baseCalendar stories * wip: update calendar styling * fix: linting * fix: set fix min width for calendar cells * Add preview export to storybook/vuetify config * wip: move vuetify config into plugins folder * task: clean up commented vuetify code in main.ts * wip: testing storybook preview.ts update * adjust config for vuetify-storybook, add style to wrap comp * task: uninstall vite-plugin-vuetify * ci: fix cypress binary error * ci: add cypress verify command to ci.yml * feat: refactor vuetifywrapper and make it external for the build * fix: eslint errors --------- Co-authored-by: tinuola <[email protected]> Co-authored-by: Parinita Mulak <[email protected]>
- Loading branch information
1 parent
44d1010
commit c9ddce8
Showing
18 changed files
with
783 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- Integrating Vuetify with Storybook --> | ||
<!-- https://storybook.js.org/recipes/vuetify --> | ||
<!-- https://github.com/storybookjs/vue3-code-examples/blob/main/.storybook/VuetifyAppWrapper.vue --> | ||
|
||
<template> | ||
<div class="vuetify-storybook-wrapper"> | ||
<slot name="story"></slot> | ||
</div> | ||
</template> | ||
|
||
<style> | ||
.vuetify-storybook-wrapper { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Integrating Vuetify with Storybook | ||
// https://storybook.js.org/recipes/vuetify | ||
|
||
import { h } from 'vue' | ||
import StoryWrapper from './VuetifyStoryWrapper.vue' | ||
|
||
// Define a decorator function | ||
export const withVuetifyTheme = (storyFn, context) => { | ||
// Call the original story function to get the story component | ||
const story = storyFn() | ||
|
||
// Return a new function that will be used as the story component | ||
return () => { | ||
// Use the "h" function to create a StoryWrapper element | ||
return h( | ||
StoryWrapper, // Component to create | ||
{}, // Props for StoryWrapper (empty in this case) | ||
{ | ||
// Pass the story component into the "story" slot of StoryWrapper | ||
story: () => h(story, { ...context.args }) // The storyFn with context args | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<script setup> | ||
import { computed, onMounted, useTemplateRef } from 'vue' | ||
import format from 'date-fns/format' | ||
import { useTheme } from '@/composables/useTheme' | ||
const { events, value } = defineProps({ | ||
events: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
value: { | ||
type: Array, | ||
default: () => [new Date()] | ||
} | ||
}) | ||
// const newDateRef = ref(value) | ||
const calendarRef = useTemplateRef('calendar') | ||
onMounted(() => { | ||
updateCalendarWeekdays() | ||
}) | ||
const parsedEvents = computed(() => { | ||
if (events.length === 0) | ||
return [] | ||
const calendarEvents = events.map((obj) => { | ||
const rawDate = obj.startDateWithTime | ||
return { | ||
title: obj.title, | ||
start: new Date(rawDate), | ||
end: new Date(rawDate), | ||
time: formatEventTime(rawDate), | ||
} | ||
}) | ||
return calendarEvents | ||
}) | ||
// console.log(parsedEvents.value) | ||
// Format time as '00:00 PM' | ||
function formatEventTime(date) { | ||
const formattedTime = format(new Date(date), 'h:mm aaa') | ||
return formattedTime.toUpperCase() | ||
} | ||
// Vuetify calendar day format is single-lettered: S, M, etc. | ||
// Update day to full name: Sunday, Monday, etc. | ||
function updateCalendarWeekdays() { | ||
const weekDayLabels = calendarRef.value.querySelectorAll('.v-calendar-weekly__head-weekday-with-weeknumber') | ||
const weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] | ||
weekDayLabels.forEach((elem, idx) => elem.innerHTML = weekDays[idx]) | ||
} | ||
const theme = useTheme() | ||
const classes = computed(() => { | ||
return ['base-calendar', theme?.value || ''] | ||
}) | ||
</script> | ||
<template> | ||
<div | ||
ref="calendar" | ||
:class="classes" | ||
> | ||
<div class="calendar-wrapper"> | ||
<v-sheet class="calendar-body"> | ||
<v-calendar | ||
:events="parsedEvents" | ||
view-mode="month" | ||
> | ||
<!-- Vuetify calendar header slot --> | ||
<!-- | ||
<template #header="header"> | ||
{{ header.title }} | ||
</template> | ||
--> | ||
<!-- Vuetify calendar event slot --> | ||
<template #event="event"> | ||
<div class="calendar-event-item"> | ||
<p class="calendar-event-title"> | ||
{{ event.event.title }} | ||
</p> | ||
<p class="calendar-event-time"> | ||
{{ event.event.time }} | ||
</p> | ||
</div> | ||
</template> | ||
</v-calendar> | ||
</v-sheet> | ||
</div> | ||
</div> | ||
</template> | ||
<style lang="scss"> | ||
@import "@/styles/default/_base-calendar.scss"; | ||
@import "@/styles/ftva/_base-calendar.scss"; | ||
</style> |
Oops, something went wrong.
c9ddce8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://ucla-library-storybook.netlify.app as production
🚀 Deployed on https://67468029ebd87462fe3ec228--ucla-library-storybook.netlify.app