Skip to content

Commit

Permalink
touchup: always place icon inside indicators
Browse files Browse the repository at this point in the history
previously was using some icons as the whole indicator,
which was inconsistent in terms of the icons' borders.
  • Loading branch information
keyserj committed Nov 1, 2024
1 parent eaa86ad commit 542f4e4
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 50 deletions.
1 change: 0 additions & 1 deletion src/web/topic/components/Indicator/CommentIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const CommentIndicator = ({ graphPartId, graphPartType, partColor }: Prop
Icon={ChatBubbleOutline}
title={`Has ${commentCount} threads`} // could count total comments as well but logic is more annoying, and doesn't seem that important
onClick={onClick}
iconHasBackground={false}
color={partColor}
/>
);
Expand Down
1 change: 0 additions & 1 deletion src/web/topic/components/Indicator/ContextIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const ContextIndicator = ({ graphPart }: Props) => {
return (
<Indicator
Icon={ControlCamera}
iconHasBackground={false}
filled={hasContext}
title={"View context"}
onClick={() => partContextMethods.viewContext(graphPart.id)}
Expand Down
4 changes: 2 additions & 2 deletions src/web/topic/components/Indicator/CriteriaTableIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TableChart } from "@mui/icons-material";
import { TableChartOutlined } from "@mui/icons-material";
import { memo, useCallback } from "react";

import { Indicator } from "@/web/topic/components/Indicator/Indicator";
Expand All @@ -24,7 +24,7 @@ const CriteriaTableIndicatorBase = ({ nodeId }: Props) => {

return (
<Indicator
Icon={TableChart}
Icon={TableChartOutlined}
filled={hasCriteria}
title={"View criteria table"}
onClick={onClick}
Expand Down
4 changes: 2 additions & 2 deletions src/web/topic/components/Indicator/DetailsIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Article } from "@mui/icons-material";
import { Notes } from "@mui/icons-material";
import { useCallback } from "react";

import { emitter } from "@/web/common/event";
Expand All @@ -18,5 +18,5 @@ export const DetailsIndicator = ({ graphPartId, notes }: Props) => {
emitter.emit("viewTopicDetails");
}, [graphPartId]);

return <Indicator Icon={Article} title={"View details"} onClick={onClick} filled={hasDetails} />;
return <Indicator Icon={Notes} title={"View details"} onClick={onClick} filled={hasDetails} />;
};
1 change: 0 additions & 1 deletion src/web/topic/components/Indicator/ForceShownIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const ForceShownIndicatorBase = ({ nodeId, partColor }: Props) => {
Icon={WbTwilight}
title={"Stop forcing node to show"}
onClick={onClick}
iconHasBackground={false}
color={partColor}
/>
);
Expand Down
7 changes: 2 additions & 5 deletions src/web/topic/components/Indicator/FoundResearchIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Code, InfoOutlined, School } from "@mui/icons-material";
import { Code, InfoOutlined, SchoolOutlined } from "@mui/icons-material";
import { type ButtonProps } from "@mui/material";
import { useCallback } from "react";

Expand Down Expand Up @@ -37,10 +37,9 @@ export const FoundResearchIndicator = ({ graphPartId, partColor }: Props) => {
if (facts.length > 0 && sources.length > 0)
return (
<Indicator
Icon={School}
Icon={SchoolOutlined}
title={`Has ${facts.length} facts and ${sources.length} sources`}
onClick={onClick}
iconHasBackground={false}
color={color}
/>
);
Expand All @@ -50,7 +49,6 @@ export const FoundResearchIndicator = ({ graphPartId, partColor }: Props) => {
Icon={InfoOutlined}
title={`Has ${facts.length} facts`}
onClick={onClick}
iconHasBackground={false}
color={color}
/>
);
Expand All @@ -60,7 +58,6 @@ export const FoundResearchIndicator = ({ graphPartId, partColor }: Props) => {
Icon={Code}
title={`Has ${sources.length} sources`}
onClick={onClick}
iconHasBackground={false}
color={color}
/>
);
Expand Down
44 changes: 11 additions & 33 deletions src/web/topic/components/Indicator/Indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ interface IndicatorProps {
Icon: MuiIcon;
title: string;
onClick?: MouseEventHandler<HTMLButtonElement>;
/**
* Determines where colors are applied, because otherwise color and hover feel inconsistent.
*
* If the icon has a background, then it will be colored and have hover effect.
* If the icon doesn't have a background, then the button will be colored and have hover effect.
*/
iconHasBackground?: boolean;
color?: ButtonProps["color"];
filled?: boolean;
}
Expand All @@ -23,7 +16,6 @@ export const Indicator = ({
Icon,
title,
onClick,
iconHasBackground = true,
color = "neutral",
filled = true,
}: IndicatorProps) => {
Expand All @@ -38,31 +30,17 @@ export const Indicator = ({

return (
<>
{iconHasBackground ? (
<StyledButton
title={title}
aria-label={title}
variant="contained"
color="neutralContrast"
onClick={onClickHandler}
// hover color for black button is impossible to see, so a custom hover is added to the svg instead of the button
className={`[&_>_svg]:hover:text-neutral-dark ${!onClick ? "pointer-events-none" : ""}`}
>
<Icon color={filled ? color : "paper"} />
</StyledButton>
) : (
<StyledButton
title={title}
aria-label={title}
variant="contained"
color={filled ? color : "paper"}
onClick={onClickHandler}
// text-base seems to fit more snuggly than the default 14px
className={`border border-solid text-base ${!onClick ? "pointer-events-none" : ""}`}
>
<Icon color="neutralContrast" fontSize="inherit" />
</StyledButton>
)}
<StyledButton
title={title}
aria-label={title}
variant="contained"
color={filled ? color : "paper"}
onClick={onClickHandler}
// text-base seems to fit more snuggly than the default 14px
className={`border border-solid text-base ${!onClick ? "pointer-events-none" : ""}`}
>
<Icon color="neutralContrast" fontSize="inherit" />
</StyledButton>
</>
);
};
3 changes: 0 additions & 3 deletions src/web/topic/components/Indicator/JustificationIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const JustificationIndicator = ({ graphPartId, partColor }: Props) => {
Icon={ThumbsUpDownOutlined}
title={`Has ${supports.length} supports and ${critiques.length} critiques`}
onClick={onClick}
iconHasBackground={false}
color={partColor}
/>
);
Expand All @@ -49,7 +48,6 @@ export const JustificationIndicator = ({ graphPartId, partColor }: Props) => {
Icon={ThumbUpOutlined}
title={`Has ${supports.length} supports`}
onClick={onClick}
iconHasBackground={false}
color={scoreColor ?? partColor}
/>
);
Expand All @@ -59,7 +57,6 @@ export const JustificationIndicator = ({ graphPartId, partColor }: Props) => {
Icon={ThumbDownOutlined}
title={`Has ${critiques.length} critiques`}
onClick={onClick}
iconHasBackground={false}
color={scoreColor ?? partColor}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const JustificationTreeIndicator = ({ graphPartId }: Props) => {
return (
<Indicator
Icon={AccountTree}
iconHasBackground={false}
filled={justificationCount > 0}
title={title}
onClick={justificationCount > 0 ? onClick : undefined}
Expand Down
1 change: 0 additions & 1 deletion src/web/topic/components/Indicator/QuestionIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const QuestionIndicator = ({ graphPartId, partColor }: Props) => {
Icon={Icon}
title={`Has ${questions.length} questions`}
onClick={onClick}
iconHasBackground={false}
color={scoreColor ?? partColor}
/>
);
Expand Down

0 comments on commit 542f4e4

Please sign in to comment.