Skip to content

Commit

Permalink
limit the minimum width of the speechbox so that it doesn't squash th…
Browse files Browse the repository at this point in the history
…e speechbox arrow 🙂
  • Loading branch information
arnard76 committed Jul 29, 2023
1 parent 10fb2e9 commit 8d37280
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/SpeechboxArrow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import Triangle from "components/Triangle";

const SpeechTextboxArrow = React.memo(({ borderWidth }) => {
const SpeechTextboxArrow = React.memo(({ borderWidth, setArrowWidth }) => {
const arrowHeight = 25; // px
const arrowWidth = 25; // px

Expand Down Expand Up @@ -43,6 +43,7 @@ const SpeechTextboxArrow = React.memo(({ borderWidth }) => {

const borderTriangleWidth = calculateBorderTriangleWidth();
const borderTriangleHeight = calculateBorderTriangleHeight();
setArrowWidth(borderTriangleWidth);

return (
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useState } from "react";
import SpeechTextboxArrow from "components/SpeechboxArrow";
import { Typography } from "@material-ui/core";
import useStyles from "./components.styles";
Expand All @@ -18,16 +18,24 @@ const borderWidth = 3.429; // px
export default function SpeechTextComponent({ id, onClick, component }) {
const { defaultComponentStyling, speechTextComponentStyles } =
useStyles(component);
const [speechTextboxArrowWidth, setArrowWidth] = useState(null);

return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
<div
className={defaultComponentStyling}
style={{ display: "flex", flexDirection: "column" }}
style={{
display: "flex",
flexDirection: "column",
minWidth: speechTextboxArrowWidth + 10, // speechbox slightly wider than arrow
}}
onClick={onClick}
id={id}
>
<SpeechTextboxArrow borderWidth={borderWidth} />
<SpeechTextboxArrow
borderWidth={borderWidth}
setArrowWidth={setArrowWidth}
/>

<Typography
style={{ borderWidth, flex: 1 }}
Expand Down

0 comments on commit 8d37280

Please sign in to comment.