-
Notifications
You must be signed in to change notification settings - Fork 53
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
6 changed files
with
86 additions
and
47 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
26 changes: 26 additions & 0 deletions
26
src/website/public/components/messages/DayChangeMarker.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,26 @@ | ||
import React from "react"; | ||
|
||
export default DayChangeMarker; | ||
|
||
interface Props { | ||
date: Date | ||
} | ||
|
||
function DayChangeMarker(props : Props) { | ||
const dayOfWeek = props.date.toLocaleDateString("en", { weekday: "long" }); | ||
const dayOfMonth = props.date.getDate(); | ||
const month = props.date.toLocaleDateString("en", { month: "long" }); | ||
const ordinal = getOrdinal(dayOfMonth); | ||
const year = props.date.getFullYear(); | ||
|
||
const text = `-- ${dayOfWeek} ${dayOfMonth}${ordinal} ${month} ${year} --`; | ||
|
||
return ( | ||
<div style={{fontSize: "smaller"}}>{text}</div> | ||
); | ||
} | ||
|
||
function getOrdinal(n: number) : string { | ||
// Taken from https://stackoverflow.com/a/39466341 | ||
return [,"st","nd","rd"][n/10%10^1&&n%10]||"th"; | ||
} |
6 changes: 2 additions & 4 deletions
6
src/website/public/components/messages/DirectMessageSentByThem.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
4 changes: 1 addition & 3 deletions
4
src/website/public/components/messages/GroupMessageSentByElse.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
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