-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
2,979 additions
and
286 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
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
75 changes: 75 additions & 0 deletions
75
src/core/react/components/SpaceView/Contexts/CalendarView/CalendarHeaderView.tsx
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,75 @@ | ||
import { formatDate } from "core/utils/date"; | ||
import { Superstate } from "makemd-core"; | ||
import React from "react"; | ||
|
||
export const CalendarHeaderView = (props: { | ||
superstate: Superstate; | ||
date: Date; | ||
mode: "day" | "week" | "month"; | ||
setDate: (date: Date) => void; | ||
}) => { | ||
const monthString = formatDate( | ||
props.superstate, | ||
props.date, | ||
props.mode == "day" ? "MMMM d" : "MMMM" | ||
); | ||
return ( | ||
<div className="mk-calendar-header"> | ||
<div className="mk-calendar-header-title"> | ||
<span>{monthString}</span> | ||
{formatDate(props.superstate, props.date, "yyyy")} | ||
</div> | ||
<span></span> | ||
<button | ||
dangerouslySetInnerHTML={{ | ||
__html: props.superstate.ui.getSticker("ui//chevron-left"), | ||
}} | ||
onClick={() => { | ||
if (props.mode == "day") { | ||
props.setDate( | ||
new Date(props.date.setDate(props.date.getDate() - 1)) | ||
); | ||
return; | ||
} else if (props.mode == "week") { | ||
props.setDate( | ||
new Date(props.date.setDate(props.date.getDate() - 7)) | ||
); | ||
return; | ||
} | ||
props.setDate( | ||
new Date(props.date.setMonth(props.date.getMonth() - 1)) | ||
); | ||
}} | ||
></button> | ||
<button | ||
onClick={() => { | ||
props.setDate(new Date()); | ||
}} | ||
> | ||
Today | ||
</button> | ||
<button | ||
onClick={() => { | ||
if (props.mode == "day") { | ||
props.setDate( | ||
new Date(props.date.setDate(props.date.getDate() + 1)) | ||
); | ||
return; | ||
} | ||
if (props.mode == "week") { | ||
props.setDate( | ||
new Date(props.date.setDate(props.date.getDate() + 7)) | ||
); | ||
return; | ||
} | ||
props.setDate( | ||
new Date(props.date.setMonth(props.date.getMonth() + 1)) | ||
); | ||
}} | ||
dangerouslySetInnerHTML={{ | ||
__html: props.superstate.ui.getSticker("ui//chevron-right"), | ||
}} | ||
></button> | ||
</div> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
src/core/react/components/SpaceView/Contexts/CalendarView/DayView/DayGutter.tsx
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 @@ | ||
import React from "react"; | ||
export const DayGutter = (props: { | ||
hourHeight: number; | ||
startHour: number; | ||
endHour: number; | ||
allDay?: boolean; | ||
}) => { | ||
return ( | ||
<div className="mk-day-view-gutter"> | ||
{props.allDay && <div className="mk-day-view-hour-title">all day</div>} | ||
{Array.from({ length: props.endHour - props.startHour + 1 }).map( | ||
(_, index) => { | ||
const hour = index + props.startHour; | ||
return ( | ||
<div key={hour} className="mk-day-view-hour-title"> | ||
<span>{hour % 12 === 0 ? 12 : hour % 12}</span>{" "} | ||
{hour < 12 ? "AM" : "PM"} | ||
</div> | ||
); | ||
} | ||
)} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.