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(b-calendar): add a parameter to the calendar to display 6 weeks #7155

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export const props = makePropsConfigurable(
// Day of week to start calendar on
// `0` (Sunday), `1` (Monday), ... `6` (Saturday)
startWeekday: makeProp(PROP_TYPE_NUMBER_STRING, 0),
// always display 6 weeks even when a month only have 5
alwaysSixWeeks: makeProp(PROP_TYPE_BOOLEAN, false),
// Variant color to use for today's date (defaults to `selectedVariant`)
todayVariant: makeProp(PROP_TYPE_STRING),
// Always return the `v-model` value as a date object
Expand Down Expand Up @@ -460,7 +462,7 @@ export const BCalendar = extend({
const weekOffset = (this.computedWeekStarts > startIndex ? 7 : 0) - this.computedWeekStarts
// Build the calendar matrix
let currentDay = 0 - weekOffset - startIndex
for (let week = 0; week < 6 && currentDay < daysInMonth; week++) {
for (let week = 0; week < 6 && (this.alwaysSixWeeks || currentDay < daysInMonth); week++) {
// For each week
matrix[week] = []
// The following could be a map function
Expand Down
4 changes: 4 additions & 0 deletions src/components/calendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"component": "BCalendar",
"version": "2.5.0",
"props": [
{
"prop": "alwaysSixWeeks",
"description": "When `false`, the number of weeks in a month will be 5 or 6 to avoid displaying a while week of the next month. When `true`, always display 6 weeks per month, event if the current month have 5 weeks. THis prevent layout shift when navigating from month to month"
},
{
"prop": "block",
"description": "Makes the calendar full width"
Expand Down