-
Notifications
You must be signed in to change notification settings - Fork 22
Conversation UI #81
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
Closed
Closed
Conversation UI #81
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
acc0711
header ui
arjunkalburgi e785da1
messages
arjunkalburgi d733450
reply box
arjunkalburgi a5103ee
colours
arjunkalburgi 95940b6
fixing box placements
arjunkalburgi 1b42031
perfecting the replybox
arjunkalburgi baf2df2
proper dates
arjunkalburgi 5aac40e
avatar defaults
arjunkalburgi ca3c714
update colours, font, breakpoints and message width
arjunkalburgi 8f0ca5f
mobile header
arjunkalburgi 0503149
removing introduced bug for testing
arjunkalburgi 4afa13a
PR comments
arjunkalburgi 5c666ba
update contact strings for ts error
arjunkalburgi 78bb20d
update ts
arjunkalburgi 9420624
update events error
arjunkalburgi 84d9b09
fixing bugs
arjunkalburgi 0f4cb7b
rebuild
arjunkalburgi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,33 @@ | ||
import type { Participant, Account } from "@commons/types/Nylas"; | ||
|
||
export function getNameInitials(name: string): string { | ||
const nameParts = name.split(" "); | ||
return nameParts | ||
.map((n, i) => (i === 0 || i === nameParts.length - 1 ? n[0] : "")) | ||
.join(""); | ||
} | ||
|
||
export function getContactInitialForAvatar( | ||
contact: Participant | Partial<Account>, | ||
): string { | ||
const participant = <Participant>contact; | ||
const account = <Partial<Account>>contact; | ||
|
||
// if participant type | ||
if (participant.email) { | ||
if (participant.name) { | ||
return getNameInitials(participant.name); | ||
} | ||
return participant.email[0]; | ||
} | ||
|
||
// else account type | ||
// since this is partial, need to check every attr and have a fallback | ||
if (account.name) { | ||
return getNameInitials(account.name); | ||
} else if (account.email_address) { | ||
return account.email_address[0]; | ||
} else { | ||
return "?"; | ||
} | ||
} |
This file contains hidden or 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,51 @@ | ||
export function getTimeString(date: Date): string { | ||
// 11:11am | ||
return date | ||
.toLocaleTimeString([], { timeStyle: "short" }) | ||
.replaceAll(/\./g, ""); | ||
} | ||
|
||
export function getYearString(date: Date): string { | ||
// Jul 5th 2020 | ||
const suffixMapper = (num: number): string => { | ||
if ([31, 21, 1].includes(num)) return "st "; | ||
if ([22, 2].includes(num)) return "nd "; | ||
if ([23, 3].includes(num)) return "rd "; | ||
return "th "; | ||
}; | ||
return date | ||
.toLocaleDateString(undefined, { | ||
year: "numeric", | ||
month: "short", | ||
day: "numeric", | ||
}) | ||
.replaceAll(/, /g, suffixMapper(date.getDate())) | ||
.replaceAll(/[.]/g, ""); | ||
} | ||
|
||
export function getDateString(date: Date): string { | ||
// Sep 22 | ||
return date | ||
.toLocaleDateString(undefined, { month: "short", day: "numeric" }) | ||
.replaceAll(/[.]/g, ""); | ||
} | ||
|
||
// Date logic: https://www.figma.com/file/oiCKNsHDfAo9KnH1Sbs8Xj/Email-%26-Mailbox-Component?node-id=128%3A51 | ||
export function getDate(date: Date): string { | ||
const today = new Date(); | ||
if (today.toDateString() === date.toDateString()) { | ||
return getTimeString(date); | ||
} | ||
|
||
const diff_years = today.getFullYear() - date.getFullYear(); | ||
if (diff_years !== 0) { | ||
return getYearString(date); | ||
} | ||
|
||
const yesterday = new Date(today.getDate() - 1); | ||
if (yesterday.toDateString() === date.toDateString()) { | ||
return "Yesterday"; | ||
} | ||
|
||
return getDateString(date); | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix for above is to upgrade typescript microsoft/TypeScript#38266 (comment)