Skip to content
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

fix: Fix markdown lazy load preview message background color #401

Merged
merged 6 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/components/ParsedBotMessageBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ type Props = {
};

const TextContainer = styled.div`
width: inherit;
text-align: start;
word-break: break-word;
padding: 8px 12px;
gap: 12px;
white-space: pre-wrap;
padding: 0 12px;
`;

const MultipleTokenTypeContainer = styled.div`
bang9 marked this conversation as resolved.
Show resolved Hide resolved
padding: 8px 0; // Bubble top and bottom padding. Side padding is applied for token containers.
border-radius: 16px;
overflow: auto;
background-color: ${({ theme }) => theme.bgColor.incomingMessage};
`;

/**
Expand All @@ -30,14 +34,10 @@ export default function ParsedBotMessageBody(props: Props) {
const { text, tokens, sources } = props;

return (
<Suspense
fallback={
<TextContainer className="sendbird-word" style={{ borderRadius: 16 }}>
{text}
</TextContainer>
}
>
<TokensBody tokens={tokens} sources={sources} />
</Suspense>
<MultipleTokenTypeContainer className="sendbird-word">
bang9 marked this conversation as resolved.
Show resolved Hide resolved
<Suspense fallback={<TextContainer>{text}</TextContainer>}>
<TokensBody tokens={tokens} sources={sources} />
</Suspense>
</MultipleTokenTypeContainer>
);
}
11 changes: 2 additions & 9 deletions src/components/TokensBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,11 @@ const BlockContainer = styled.div`
margin: 0.5em 0;
`;

const MultipleTokenTypeContainer = styled.div`
padding: 8px 0; // Bubble top and bottom padding. Side padding is applied for token containers.
border-radius: 16px;
overflow: auto;
background-color: ${({ theme }) => theme.bgColor.incomingMessage};
`;

export default function TokensBody({ tokens, sources }: TokensBodyProps) {
const { enableSourceMessage } = useConstantState();

return (
<MultipleTokenTypeContainer className="sendbird-word">
<>
{tokens.map((token: Token, i) => {
// Normal text part of the message.
if (token.type === TokenType.string) {
Expand Down Expand Up @@ -95,6 +88,6 @@ export default function TokensBody({ tokens, sources }: TokensBodyProps) {
<BotMessageBottom />
</div>
) : null}
</MultipleTokenTypeContainer>
</>
);
}
Loading