Skip to content

Commit

Permalink
add day of week header
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmojicatech committed Jan 29, 2023
1 parent 6d5501a commit 6d5fe32
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
8 changes: 8 additions & 0 deletions libs/pmt-calendar/src/components/month-view/month-view.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.monthViewContainer {
padding: 0 1rem;
}
.dayOfWeek {
display: inline-flex;
width: 100%;
justify-content: space-between;
}
18 changes: 16 additions & 2 deletions libs/pmt-calendar/src/components/month-view/month-view.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import { Component, h, Prop } from "@stencil/core";
import { DAY_OF_WEEK } from "../../models/calendar.const";

@Component({
tag: 'pmt-month-view',
shadow: true
shadow: true,
styleUrl: 'month-view.scss'
})
export class MonthViewComponent {

@Prop()
currentDate: Date;

readonly DAYS_OF_WEEK = Object.values(DAY_OF_WEEK);



render() {
return (
<div>{this.currentDate.toLocaleDateString()}</div>
<section class="monthViewContainer">
<div class="dayOfWeek">
{this.DAYS_OF_WEEK.map(dow => {
return (
<div>{dow}</div>
);
})}
</div>
</section>
);
}
}
10 changes: 10 additions & 0 deletions libs/pmt-calendar/src/models/calendar.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ export const CALENDAR_VIEW = {
month: 'Month',
year: 'Year'
}

export const DAY_OF_WEEK = {
0: 'Sunday',
1: 'Monday',
2: 'Tuesday',
3: 'Wednesday',
4: 'Thursday',
5: 'Friday',
6: 'Saturday'
}
7 changes: 7 additions & 0 deletions libs/pmt-calendar/src/utils/date-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {getDay} from 'date-fns';
import { DAY_OF_WEEK } from '../models/calendar.const';

export function getDayOfWeekGivenDate(date: Date): string {
const dow = getDay(date);
return DAY_OF_WEEK[dow];
}

0 comments on commit 6d5fe32

Please sign in to comment.