diff --git a/src/element/chat-message.tsx b/src/element/chat-message.tsx index 8bb84b8..aed1470 100644 --- a/src/element/chat-message.tsx +++ b/src/element/chat-message.tsx @@ -14,7 +14,7 @@ import { EmojiPicker } from "./emoji-picker"; import { Icon } from "./icon"; import { Emoji } from "./emoji"; import { Profile } from "./profile"; -import { Text } from "./text"; +import { Markdown } from "./markdown"; import { SendZapsDialog } from "./send-zap"; import { findTag } from "../utils"; import type { EmojiPack } from "../hooks/emoji"; @@ -151,7 +151,12 @@ export function ChatMessage({ pubkey={ev.pubkey} profile={profile} /> - + {(hasReactions || hasZaps) && (
{hasZaps && ( diff --git a/src/element/event.css b/src/element/event.css index 33cfcd3..bfe09dd 100644 --- a/src/element/event.css +++ b/src/element/event.css @@ -1,12 +1,22 @@ .event-container .note { max-width: 320px; + display: flex; + flex-direction: column; } .event-container .goal { font-size: 14px; } -.event-container .goal .amount { +.event-container .goal .progress-root .amount { top: -8px; font-size: 10px; } + +.message .event-container .goal .progress-root .amount { + top: -6px; +} + +.message .event-container .note { + max-width: unset; +} diff --git a/src/element/external-link.tsx b/src/element/external-link.tsx index 5659b3a..179c471 100644 --- a/src/element/external-link.tsx +++ b/src/element/external-link.tsx @@ -1,7 +1,22 @@ +import { Icon } from "element/icon"; + +export function ExternalIconLink({ size = 32, href, ...rest }) { + return ( + + window.open(href, "_blank")} + {...rest} + /> + + ); +} + export function ExternalLink({ children, href }) { return ( {children} - ) + ); } diff --git a/src/element/live-chat.css b/src/element/live-chat.css index 1f86b85..c789a60 100644 --- a/src/element/live-chat.css +++ b/src/element/live-chat.css @@ -358,16 +358,11 @@ border-radius: unset; } -.message .message-container { - display: flex; - flex-wrap: wrap; - gap: 4px; -} - -.message .message-container .markdown p { +.message .markdown { font-size: 14px; + line-height: normal; } -.message .message-container .markdown > p { - margin: 0; +.message .markdown .emoji { + width: unset; } diff --git a/src/element/markdown.tsx b/src/element/markdown.tsx index 0632b97..3511b33 100644 --- a/src/element/markdown.tsx +++ b/src/element/markdown.tsx @@ -1,7 +1,7 @@ import "./markdown.css"; +import { createElement } from "react"; import { parseNostrLink } from "@snort/system"; -import type { ReactNode } from "react"; import { useMemo } from "react"; import ReactMarkdown from "react-markdown"; @@ -190,11 +190,17 @@ function transformText(ps, tags) { } interface MarkdownProps { - children: ReactNode; + content: string; tags?: string[]; + enableParagraphs?: booleam; } -export function Markdown({ children, tags = [] }: MarkdownProps) { +export function Markdown({ + content, + tags = [], + enableParagraphs = true, + element = "div", +}: MarkdownProps) { const components = useMemo(() => { return { li: ({ children, ...props }) => { @@ -202,15 +208,20 @@ export function Markdown({ children, tags = [] }: MarkdownProps) { }, td: ({ children }) => children && {transformText(children, tags)}, - p: ({ children }) => children &&

{transformText(children, tags)}

, + p: ({ children }) => + enableParagraphs ? ( +

{transformText(children, tags)}

+ ) : ( + transformText(children, tags) + ), a: (props) => { return {props.children}; }, }; - }, [tags]); - return ( -
- -
+ }, [tags, enableParagraphs]); + return createElement( + element, + { className: "markdown" }, + {content}, ); } diff --git a/src/element/note.css b/src/element/note.css index 2fb260e..8430f38 100644 --- a/src/element/note.css +++ b/src/element/note.css @@ -4,6 +4,11 @@ border-radius: 10px; } +.note .note-header { + display: flex; + justify-content: space-between; +} + .note .note-header .profile { font-size: 14px; } diff --git a/src/element/note.tsx b/src/element/note.tsx index b79987d..ddf93fb 100644 --- a/src/element/note.tsx +++ b/src/element/note.tsx @@ -2,6 +2,7 @@ import "./note.css"; import { type NostrEvent } from "@snort/system"; import { Markdown } from "element/markdown"; +import { ExternalIconLink } from "element/external-link"; import { Profile } from "element/profile"; export function Note({ ev }: { ev: NostrEvent }) { @@ -9,9 +10,10 @@ export function Note({ ev }: { ev: NostrEvent }) {
+
- {ev.content} +
); diff --git a/src/element/stream-cards.tsx b/src/element/stream-cards.tsx index e165ff3..e7b8c83 100644 --- a/src/element/stream-cards.tsx +++ b/src/element/stream-cards.tsx @@ -9,7 +9,7 @@ import type { NostrEvent } from "@snort/system"; import { Toggle } from "element/toggle"; import { useLogin } from "hooks/login"; -import { useUserCards } from "hooks/cards"; +import { useCards, useUserCards } from "hooks/cards"; import { CARD, USER_CARDS } from "const"; import { toTag } from "utils"; import { Login, System } from "index"; @@ -55,7 +55,7 @@ const CardPreview = forwardRef( ) : ( {title} ))} - +
); }, @@ -382,12 +382,11 @@ function AddCard({ cards }: AddCardProps) { ); } -export function StreamCards({ host }) { +export function StreamCardEditor() { const login = useLogin(); - const canEdit = login?.pubkey === host; - const cards = useUserCards(login.pubkey, login.cards.tags, canEdit); + const cards = useUserCards(login.pubkey, login.cards.tags, true); const [isEditing, setIsEditing] = useState(false); - const components = ( + return ( <>
{cards.map((ev) => ( @@ -395,17 +394,35 @@ export function StreamCards({ host }) { ))} {isEditing && }
- {canEdit && ( -
- -
- )} +
+ +
); - return {components}; +} + +export function ReadOnlyStreamCards({ host }) { + const cards = useCards(host); + return ( +
+ {cards.map((ev) => ( + + ))} +
+ ); +} + +export function StreamCards({ host }) { + const login = useLogin(); + const canEdit = login?.pubkey === host; + return ( + + {canEdit ? : } + + ); }