Clarify prop usage by renaming in more self-evident name

This commit is contained in:
Florian Scholdei
2020-10-21 12:23:58 +02:00
parent 5ef3e2ed52
commit e141e33aa3
2 changed files with 9 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ import Tooltip from "../Tooltip";
type Props = { type Props = {
modalTitle: string; modalTitle: string;
modalBody: ReactNode; modalBody: ReactNode;
useTitleTooltip?: boolean; // not recommended tooltipStyle?: "tooltipComponent" | "htmlTitle";
}; };
const Button = styled.a` const Button = styled.a`
@@ -41,14 +41,18 @@ const Button = styled.a`
} }
`; `;
const OpenInFullscreenButton: FC<Props> = ({ modalTitle, modalBody, useTitleTooltip = false }) => { const OpenInFullscreenButton: FC<Props> = ({ modalTitle, modalBody, tooltipStyle = "tooltipComponent" }) => {
const [t] = useTranslation("repos"); const [t] = useTranslation("repos");
const [showModal, setShowModal] = useState(false); const [showModal, setShowModal] = useState(false);
const tooltip = t("diff.fullscreen.open"); const tooltip = t("diff.fullscreen.open");
const content = ( const content = (
<> <>
<Button title={useTitleTooltip ? tooltip : undefined} className="button" onClick={() => setShowModal(true)}> <Button
title={tooltipStyle === "htmlTitle" ? tooltip : undefined}
className="button"
onClick={() => setShowModal(true)}
>
<i className="fas fa-search-plus" /> <i className="fas fa-search-plus" />
</Button> </Button>
{showModal && ( {showModal && (
@@ -62,7 +66,7 @@ const OpenInFullscreenButton: FC<Props> = ({ modalTitle, modalBody, useTitleTool
</> </>
); );
if (useTitleTooltip) { if (tooltipStyle === "htmlTitle") {
return <>{content}</>; return <>{content}</>;
} }
return ( return (

View File

@@ -138,7 +138,7 @@ class Content extends React.Component<Props, State> {
<OpenInFullscreenButton <OpenInFullscreenButton
modalTitle={file?.name} modalTitle={file?.name}
modalBody={<BorderLessDiv className="panel">{content}</BorderLessDiv>} modalBody={<BorderLessDiv className="panel">{content}</BorderLessDiv>}
useTitleTooltip={true} tooltipStyle="htmlTitle"
/> />
<ExtensionPoint <ExtensionPoint
name="repos.sources.content.actionbar" name="repos.sources.content.actionbar"