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(VDatePicker): add events and event-color support for date picker #20965

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maryamBaratii
Copy link

Description

  • Restores the events and event-color props in VDatePicker for month view.
  • Allows event markers to be displayed on months, similar to the behavior in Vuetify 2.
  • Ensures the correct color is applied to event markers.
  • Updated documentation to reflect the new props.

Fixes #19296

Screenshot 2025-02-07 at 02 14 56

Markup:

<template>
  <v-app>
    <v-container>
      <v-date-picker
        :event-color="date => date[9] % 2 ? 'red' : 'yellow'"
        :events="functionEvents"
        :v-model="date2"
      />
    </v-container>
  </v-app>
</template>

<script setup>
  import { onMounted, ref } from 'vue'

  const arrayEvents = ref(null)
  const date2 = ref((new Date(Date.now() - (new Date()).getTimezoneOffset() * 60000)).toISOString().substr(0, 10))
  function functionEvents (date) {
    const [, , day] = date.split('-')
    if ([12, 17, 28].includes(parseInt(day, 10))) return true
    if ([1, 19, 22].includes(parseInt(day, 10))) return ['red', '#00f']
    return false
  }
  onMounted(() => {
    arrayEvents.value = [...Array(6)].map(() => {
      const day = Math.floor(Math.random() * 30)
      const d = new Date()
      d.setDate(day)
      return d.toISOString().substr(0, 10)
    })
  })
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Month picker in VDatePicker 3.5.4 - events and event-color props missing
1 participant