Skip to content

Commit

Permalink
show icon if help text defined
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Dec 1, 2024
1 parent 7600c40 commit 6a757e3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Help from "@mui/icons-material/Help";
import Box from "@mui/material/Box";
import {
ComponentType as TYPES,
Expand Down Expand Up @@ -25,10 +26,11 @@ type Props = {
} & NodeTags;

const Checklist: React.FC<Props> = React.memo((props) => {
const [isClone, childNodes, copyNode] = useStore((state) => [
const [isClone, childNodes, copyNode, showHelpText] = useStore((state) => [
state.isClone,
state.childNodesOf(props.id),
state.copyNode,
state.showHelpText,
]);

const parent = getParentId(props.parent);
Expand Down Expand Up @@ -76,6 +78,9 @@ const Checklist: React.FC<Props> = React.memo((props) => {

const Icon = ICONS[props.type];

const hasHelpText =
props.data.policyRef || props.data.info || props.data.howMeasured;

return (
<>
<Hanger hidden={isDragging} before={props.id} parent={parent} />
Expand Down Expand Up @@ -109,6 +114,9 @@ const Checklist: React.FC<Props> = React.memo((props) => {
)}
<Box sx={{ display: "flex", flexDirection: "row" }}>
{Icon && <Icon />}
{showHelpText && hasHelpText && (
<Help fontSize="small" color="primary" />
)}
<span>{props.text}</span>
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ErrorIcon from "@mui/icons-material/Error";
import Help from "@mui/icons-material/Help";
import Box from "@mui/material/Box";
import {
ComponentType as TYPES,
Expand All @@ -25,10 +26,11 @@ type Props = {
} & NodeTags;

const Question: React.FC<Props> = React.memo((props) => {
const [isClone, childNodes, copyNode] = useStore((state) => [
const [isClone, childNodes, copyNode, showHelpText] = useStore((state) => [
state.isClone,
state.childNodesOf(props.id),
state.copyNode,
state.showHelpText,
]);

const parent = getParentId(props.parent);
Expand Down Expand Up @@ -60,6 +62,9 @@ const Question: React.FC<Props> = React.memo((props) => {
// If there is an error, the icon has a semantic meaning and needs a title
const iconTitleAccess = props.type === "Error" ? "Error" : undefined;

const hasHelpText =
props.data.policyRef || props.data.info || props.data.howMeasured;

return (
<>
<Hanger hidden={isDragging} before={props.id} parent={parent} />
Expand Down Expand Up @@ -91,6 +96,9 @@ const Question: React.FC<Props> = React.memo((props) => {
/>
)}
{Icon && <Icon titleAccess={iconTitleAccess} />}
{showHelpText && hasHelpText && (
<Help fontSize="small" color="primary" />
)}
<span>{props.text}</span>
</Link>
{props.type !== TYPES.SetValue && props.data?.fn && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import HelpTextIcon from "@mui/icons-material/SpeakerNotes";
import HelpTextOffIcon from "@mui/icons-material/SpeakerNotesOff";
import HelpTextOffIcon from "@mui/icons-material/DoNotDisturbOff";
import HelpTextIcon from "@mui/icons-material/Help";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import { useStore } from "pages/FlowEditor/lib/store";
Expand Down

0 comments on commit 6a757e3

Please sign in to comment.