-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Display starred messages in dedicated component (which will disp…
…lay at the top of Composer articles) Co-Authored-By: Tom Richards <[email protected]>
- Loading branch information
1 parent
28165b1
commit f560d5c
Showing
8 changed files
with
101 additions
and
29 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,76 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import { Item } from "shared/graphql/graphql"; | ||
import root from "react-shadow/emotion"; | ||
import { UserLookup } from "../types/UserLookup"; | ||
import { FormattedDateTime } from "../formattedDateTime"; | ||
import { css } from "@emotion/react"; | ||
import { agateSans } from "../../fontNormaliser"; | ||
import { neutral, space } from "@guardian/source-foundations"; | ||
|
||
export const STARRED_MESSAGES_HTML_TAG = "pinboard-starred-messages"; | ||
|
||
// interface StarredMessagesProps {} | ||
const StarredItemDisplay = ({ | ||
item, | ||
userLookup, | ||
}: { | ||
item: Item; | ||
userLookup: UserLookup; | ||
}) => { | ||
const user = userLookup?.[item.userEmail]; | ||
const userDisplayName = user | ||
? `${user.firstName} ${user.lastName}` | ||
: item.userEmail; | ||
return ( | ||
<div | ||
css={css` | ||
${agateSans.xsmall()}; | ||
display: flex; | ||
align-items: flex-end; | ||
gap: ${space[1]}px; | ||
color: ${neutral[20]}; | ||
`} | ||
> | ||
<span | ||
css={css` | ||
color: ${neutral[0]}; | ||
${agateSans.medium()}; | ||
`} | ||
> | ||
{item.message} | ||
</span> | ||
<span title={item.userEmail}>{userDisplayName}</span> | ||
<span> | ||
<FormattedDateTime timestamp={item.timestamp} withAgo /> | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
const StarredMessages = (/* props: StarredMessagesProps */) => ( | ||
<div> | ||
<p>Starred Messages</p> | ||
</div> | ||
); | ||
interface StarredMessagesProps { | ||
items: Item[]; | ||
userLookup: UserLookup; | ||
} | ||
|
||
const StarredMessages = ({ items, userLookup }: StarredMessagesProps) => { | ||
const starredMessages = items.filter( | ||
(item) => item.isStarred && !item.deletedAt | ||
); | ||
return ( | ||
<root.div> | ||
{starredMessages.map((item) => ( | ||
<StarredItemDisplay key={item.id} item={item} userLookup={userLookup} /> | ||
))} | ||
</root.div> | ||
); | ||
}; | ||
|
||
interface StarredMessagesPortalProps { | ||
interface StarredMessagesPortalProps extends StarredMessagesProps { | ||
node: Element; | ||
} | ||
|
||
export const StarredMessagesPortal = ({ node }: StarredMessagesPortalProps) => | ||
ReactDOM.createPortal(<StarredMessages />, node); | ||
export const StarredMessagesPortal = ({ | ||
node, | ||
...props | ||
}: StarredMessagesPortalProps) => | ||
ReactDOM.createPortal(<StarredMessages {...props} />, node); |
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