-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from jiftechnify/custom-emoji-in-name
Support displaying custom emojis in profile
- Loading branch information
Showing
12 changed files
with
174 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { css } from "@shadow-panda/styled-system/css"; | ||
import { type NostrEvent, parseEventContent } from "../../nostr"; | ||
import { ExternalLink } from "../ExternalLink"; | ||
import { renderEventContentParts } from "./renderEventContentParts"; | ||
|
||
type GeneralStatusProps = { | ||
srcEvent?: NostrEvent; | ||
linkUrl?: string; | ||
}; | ||
|
||
export const GeneralStatusView = ({ srcEvent, linkUrl }: GeneralStatusProps) => { | ||
if (srcEvent === undefined) { | ||
return <NoStatus />; | ||
} | ||
|
||
const parts = parseEventContent(srcEvent); | ||
return parts.length > 0 ? ( | ||
<p | ||
className={css({ | ||
textStyle: "main-status", | ||
wordBreak: "break-all", | ||
})} | ||
> | ||
{renderEventContentParts(parts)} | ||
{linkUrl && <ExternalLink href={linkUrl} />} | ||
</p> | ||
) : ( | ||
<NoStatus /> | ||
); | ||
}; | ||
|
||
const NoStatus = () => { | ||
return ( | ||
<p | ||
className={css({ | ||
textStyle: "main-status", | ||
color: "text.no-status", | ||
})} | ||
> | ||
No status | ||
</p> | ||
); | ||
}; |
2 changes: 1 addition & 1 deletion
2
src/components/MusicStatusView.tsx → src/components/status/MusicStatusView.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
11 changes: 8 additions & 3 deletions
11
src/components/StatusDetailsView.tsx → src/components/status/StatusDetailsView.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { css } from "@shadow-panda/styled-system/css"; | ||
import { hstack } from "@shadow-panda/styled-system/patterns"; | ||
import { type NostrEvent, parseEventContent } from "../../nostr"; | ||
import { AppAvatar } from "../AppAvatar"; | ||
import { renderEventContentParts } from "./renderEventContentParts"; | ||
|
||
type UserProfileViewProps = { | ||
srcEvent?: NostrEvent; | ||
picture?: string; | ||
displayName: string; | ||
subName?: string; | ||
}; | ||
|
||
export const UserProfileView = ({ picture, displayName, subName, srcEvent }: UserProfileViewProps) => { | ||
return ( | ||
<div className={hstack({ gap: "1" })}> | ||
<AppAvatar imgSrc={picture} size="sm" /> | ||
<div | ||
className={hstack({ | ||
gap: "1", | ||
alignItems: "end", | ||
})} | ||
> | ||
<DisplayName {...{ displayName, srcEvent }} /> | ||
{subName !== undefined && <SubName {...{ subName, srcEvent }} />} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const DisplayName = ({ displayName, srcEvent }: { displayName: string; srcEvent?: NostrEvent }) => { | ||
const parts = parseEventContent(srcEvent, displayName); | ||
return <p className={css({ textStyle: "display-name" })}>{renderEventContentParts(parts)}</p>; | ||
}; | ||
|
||
const SubName = ({ subName, srcEvent }: { subName: string; srcEvent?: NostrEvent }) => { | ||
const parts = parseEventContent(srcEvent, subName); | ||
return <p className={css({ textStyle: "sub-name", color: "text.sub" })}>{renderEventContentParts(parts)}</p>; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { css } from "@shadow-panda/styled-system/css"; | ||
import { type EventContentPart, eventContentPartKey } from "../../nostr"; | ||
import { CustomEmoji } from "../CustomEmoji"; | ||
|
||
export const renderEventContentParts = (parts: EventContentPart[]): React.ReactNode[] => { | ||
if (parts.length === 0) { | ||
return []; | ||
} | ||
|
||
return parts.map((part) => { | ||
const key = eventContentPartKey(part); | ||
switch (part.type) { | ||
case "text": | ||
return ( | ||
<span key={key} className={css({ verticalAlign: "middle" })}> | ||
{part.text} | ||
</span> | ||
); | ||
case "custom-emoji": | ||
return <CustomEmoji key={key} imgUrl={part.imgUrl} shortcode={part.shortcode} />; | ||
} | ||
}); | ||
}; |
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
Oops, something went wrong.