Skip to content

Commit

Permalink
feat: actual day implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
DominMFD committed Sep 19, 2024
1 parent 924b63d commit f64c702
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
@use '~styles/breakpoints.scss' as breakpoints;

.date-selector-composer {
width: 100%;

cursor: pointer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ DayButton.prototype = Object.assign(DayButton.prototype, Component.prototype, {
desactive() {
this.$dayButton.classList.remove('day__button--active');
},

actualDay() {
this.$dayButton.classList.add('day__button--actual');
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
background-color: colors.$blue150;
}

&--actual {
color: colors.$primary200;
font-weight: fonts.$semiBold;
}

&--previousMonth,
&--nextMonth {
color: rgba(160, 174, 192, 1);
Expand Down
26 changes: 19 additions & 7 deletions src/components/Calendar/components/DayComposer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export default function DayComposer({
this.$dayComposer = this.selected.get('day-composer');
this.activeDayButton = null;

const actualDay = dayjs().date();
const actualMonth = dayjs().month() + 1;
const actualYear = dayjs().year();

const totalDaysInCalendar = 42;
this.totalDaysInMonth = dayjs(`${this.year}-${this.month}-1`).daysInMonth();
this.firstDayInWeek = dayjs(`${this.year}-${this.month}-1`).day();
Expand All @@ -44,6 +48,14 @@ export default function DayComposer({
this.actualMonthDay,
this.actualMonthDay === this.day && 'active',
);

if (
this.actualMonthDay === actualDay &&
this.month === actualMonth &&
this.year === actualYear
)
this.dayButton.actualDay();

this.actualMonthDay += 1;
}
}
Expand All @@ -54,18 +66,18 @@ DayComposer.prototype = Object.assign(
Component.prototype,
{
mountDay(day, state) {
const dayButton = new DayButton(day, state);
this.dayButton = new DayButton(day, state);

if (state === 'active') this.activeDayButton = dayButton;
if (state === 'active') this.activeDayButton = this.dayButton;

dayButton.mount(this.$dayComposer);
dayButton.listen('day:active', (activeDay) =>
this.handleDayActive(dayButton, activeDay),
this.dayButton.mount(this.$dayComposer);
this.dayButton.listen('day:active', (activeDay) =>
this.handleDayActive(this.dayButton, activeDay),
);
dayButton.listen('day:previousMonth', () =>
this.dayButton.listen('day:previousMonth', () =>
this.emit('day:previousMonth'),
);
dayButton.listen('day:nextMonth', () => this.emit('day:nextMonth'));
this.dayButton.listen('day:nextMonth', () => this.emit('day:nextMonth'));
},

handleDayActive(dayButton, activeDay) {
Expand Down

0 comments on commit f64c702

Please sign in to comment.