Skip to content

Commit

Permalink
fix: rewrite tool icon/text links as separate items
Browse files Browse the repository at this point in the history
  • Loading branch information
paulschreiber committed Nov 29, 2023
1 parent ea65f1b commit 12fe4fb
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions src/tool/components/ToolCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,37 @@ import theme from 'theme';
const ToolIconAndLink = ({ tool, title, external }) => {
const { t } = useTranslation();
const toolImage = require(`assets/${t(`tools.${tool}.img.src`)}`);
const toolUrl = t(`tools.${tool}.url`);
const toolText = t('tool.go_to', { tool: title });
const toolIcon = (
<Box
component="img"
src={toolImage}
alt={t(`tools.${tool}.img.alt`)}
width={t(`tools.${tool}.img.width`)}
height={t(`tools.${tool}.img.height`)}
sx={{
width: `${t(`tools.${tool}.img.width`)}px`,
height: `${t(`tools.${tool}.img.height`)}px`,
borderRadius: '4px',
border: '1px solid rgba(0, 0, 0, 0.12)',
}}
/>
);

return (
<React.Fragment>
<Box
component="img"
src={toolImage}
alt={t(`tools.${tool}.img.alt`)}
width={t(`tools.${tool}.img.width`)}
height={t(`tools.${tool}.img.height`)}
sx={{
width: `${t(`tools.${tool}.img.width`)}px`,
height: `${t(`tools.${tool}.img.height`)}px`,
borderRadius: '4px',
border: '1px solid rgba(0, 0, 0, 0.12)',
}}
/>
{external ? (
<ExternalLink href={toolUrl}>{toolIcon}</ExternalLink>
) : (
<Link href={toolUrl}>{toolIcon}</Link>
)}
<p>
{t('tool.go_to', { tool: title })}
{external ? (
<ExternalLink href={toolUrl}>{toolText}</ExternalLink>
) : (
<Link href={toolUrl}>{toolText}</Link>
)}
{external && (
<LaunchIcon
sx={{
Expand Down Expand Up @@ -147,23 +160,11 @@ const ToolCard = ({ tool }) => {
</section>

<section>
{isToolExternal ? (
<ExternalLink href={t(`tools.${tool}.url`)}>
<ToolIconAndLink
tool={tool}
title={toolTitle}
external={isToolExternal}
/>
</ExternalLink>
) : (
<Link href={t(`tools.${tool}.url`)}>
<ToolIconAndLink
tool={tool}
title={toolTitle}
external={isToolExternal}
/>
</Link>
)}
<ToolIconAndLink
tool={tool}
title={toolTitle}
external={isToolExternal}
/>
</section>
</Stack>
</Card>
Expand Down

0 comments on commit 12fe4fb

Please sign in to comment.