mirror of
https://github.com/wassname/talk.git
synced 2026-07-04 03:37:14 +08:00
Fix story message boxes to wrap text properly (#2761)
Need to set the message content width so that the text knows how to wrap. Also accounts for when the icon is present to set width to the correct value so it doesn't shift past the edge of the message box container. CORL-802 Co-authored-by: Kim Gardner <kgardnr@gmail.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
.withIcon {
|
||||
width: calc(100% - 18px - var(--spacing-3));
|
||||
}
|
||||
|
||||
.withoutIcon {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
|
||||
import { MessageBoxContainer_story as StoryData } from "coral-stream/__generated__/MessageBoxContainer_story.graphql";
|
||||
|
||||
import styles from "./MessageBoxContainer.css";
|
||||
|
||||
interface Props {
|
||||
story: StoryData;
|
||||
className?: string;
|
||||
@@ -24,7 +26,11 @@ const MessageBoxContainer: FunctionComponent<Props> = ({
|
||||
{story.settings.messageBox.icon && (
|
||||
<MessageBoxIcon>{story.settings.messageBox.icon}</MessageBoxIcon>
|
||||
)}
|
||||
<MessageBoxContent>
|
||||
<MessageBoxContent
|
||||
className={
|
||||
story.settings.messageBox.icon ? styles.withIcon : styles.withoutIcon
|
||||
}
|
||||
>
|
||||
{story.settings.messageBox.content || ""}
|
||||
</MessageBoxContent>
|
||||
</MessageBox>
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
.preview {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.withIcon {
|
||||
width: calc(100% - 18px - var(--spacing-3));
|
||||
}
|
||||
|
||||
.withoutIcon {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,13 @@ const MessageBoxConfig: FunctionComponent<Props> = ({ disabled }) => (
|
||||
<MessageBoxIcon>{iconInput.value}</MessageBoxIcon>
|
||||
)}
|
||||
{/* Using a zero width join character to ensure that the space is used */}
|
||||
<MessageBoxContent>
|
||||
<MessageBoxContent
|
||||
className={
|
||||
iconInput.value
|
||||
? styles.withIcon
|
||||
: styles.withoutIcon
|
||||
}
|
||||
>
|
||||
{contentInput.value || " "}
|
||||
</MessageBoxContent>
|
||||
</MessageBox>
|
||||
|
||||
+4
-4
@@ -74,7 +74,7 @@ exports[`renders message box when commenting disabled 1`] = `
|
||||
chat
|
||||
</i>
|
||||
<div
|
||||
className="Markdown-root MessageBoxContent-root"
|
||||
className="Markdown-root MessageBoxContent-root MessageBoxContainer-withIcon"
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "<p><strong>What do you think</strong>?</p>
|
||||
@@ -279,7 +279,7 @@ exports[`renders message box when logged in 1`] = `
|
||||
chat
|
||||
</i>
|
||||
<div
|
||||
className="Markdown-root MessageBoxContent-root"
|
||||
className="Markdown-root MessageBoxContent-root MessageBoxContainer-withIcon"
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "<p><strong>What do you think</strong>?</p>
|
||||
@@ -597,7 +597,7 @@ exports[`renders message box when not logged in 1`] = `
|
||||
chat
|
||||
</i>
|
||||
<div
|
||||
className="Markdown-root MessageBoxContent-root"
|
||||
className="Markdown-root MessageBoxContent-root MessageBoxContainer-withIcon"
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "<p><strong>What do you think</strong>?</p>
|
||||
@@ -889,7 +889,7 @@ exports[`renders message box when story isClosed 1`] = `
|
||||
className="MessageBox-root coral coral-createComment-message PostCommentFormClosed-messageBox"
|
||||
>
|
||||
<div
|
||||
className="Markdown-root MessageBoxContent-root"
|
||||
className="Markdown-root MessageBoxContent-root MessageBoxContainer-withoutIcon"
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "<p><strong>What do you think</strong>?</p>
|
||||
|
||||
Reference in New Issue
Block a user