Files
blitzkit/packages/website/src/components/ToolCard.astro
T

138 lines
3.4 KiB
Plaintext
Raw Normal View History

2024-09-14 13:24:24 -05:00
---
2025-04-05 16:00:52 -05:00
import { assertSecret } from '@blitzkit/core';
2024-09-14 13:24:24 -05:00
import { CaretRightIcon } from '@radix-ui/react-icons';
2024-12-27 14:01:59 -06:00
import { Box, Button, Code, Flex, Heading, Text } from '@radix-ui/themes';
2024-09-14 13:24:24 -05:00
import type { Tool } from '../constants/tools';
2025-01-06 20:09:11 -06:00
import { getStrings } from '../core/i18n/getStrings';
2024-12-27 14:01:59 -06:00
import { LinkI18n } from './LinkI18n';
2024-09-14 13:24:24 -05:00
interface Props {
tool: Tool;
}
const { tool } = Astro.props;
const disabled = tool.branches?.every(
2025-06-08 17:32:13 +00:00
(branch) => branch !== assertSecret(import.meta.env.PUBLIC_BRANCH),
2024-09-14 13:24:24 -05:00
);
2024-12-27 14:01:59 -06:00
const { locale } = Astro.params;
2025-01-06 20:09:11 -06:00
const strings = getStrings(locale);
const toolStrings =
strings.website.tools[
2025-04-05 16:00:52 -05:00
(tool.stringsId ?? tool.id) as keyof typeof strings.website.tools
2025-01-06 20:09:11 -06:00
];
2024-09-14 13:24:24 -05:00
---
<style>
.container {
border-radius: var(--radius-2);
background-size: cover;
background-position: center;
height: 16rem;
&[data-disabled='true'] {
opacity: 0.25;
}
&[data-significant='true'] {
height: min(20rem, 50vh);
}
}
.link {
display: flex;
width: 100%;
height: 100%;
flex-direction: column;
color: inherit;
}
</style>
<Flex
2025-04-05 16:00:52 -05:00
style={{ backgroundImage: `url(/assets/images/tools/${tool.id}.webp)` }}
2024-09-14 18:32:36 -05:00
data-disabled={disabled}
data-significant={tool.significant}
className="container"
position="relative"
overflow="hidden"
2024-09-14 13:24:24 -05:00
flexGrow={tool.significant ? undefined : '1'}
flexBasis={tool.significant ? undefined : { initial: undefined, sm: '0' }}
>
2024-12-27 14:01:59 -06:00
<LinkI18n
{locale}
2024-09-14 13:24:24 -05:00
className="link"
underline="none"
2025-05-15 23:44:20 -05:00
href={disabled ? '#' : (tool.href ?? `/${tool.id}`)}
2024-09-14 13:24:24 -05:00
target={tool.href ? '_blank' : undefined}
>
<Box
flexGrow="1"
style={{
2025-04-05 16:00:52 -05:00
backgroundImage: `url(/assets/images/tools/${tool.id}.webp)`,
2024-09-14 13:24:24 -05:00
backgroundSize: 'cover',
backgroundPosition: 'center',
}}
/>
<Flex
px={{ initial: '6', md: tool.significant ? '8' : '6' }}
py={{ initial: '4', sm: tool.significant ? '6' : '4' }}
gap="4"
align="center"
justify="between"
width="100%"
direction={{ initial: 'column', xs: 'row' }}
style={{
backgroundColor: 'var(--color-panel-translucent)',
backdropFilter: 'blur(64px)',
WebkitBackdropFilter: 'blur(64px)',
}}
>
<Flex
direction="column"
justify="center"
align={{ initial: 'center', xs: 'start' }}
>
<Heading
align={{ initial: 'center', sm: 'left' }}
size={{ initial: '6', sm: tool.significant ? '7' : '5' }}
weight="medium"
>
2025-01-06 20:09:11 -06:00
{toolStrings.name}
2024-09-14 13:24:24 -05:00
</Heading>
<Text
align={{ initial: 'center', sm: 'left' }}
size={{ initial: '3', sm: tool.significant ? '4' : '3' }}
color="gray"
>
{
disabled ? (
<>
Unavailable on{' '}
2025-06-08 17:32:13 +00:00
<Code>{assertSecret(import.meta.env.PUBLIC_BRANCH)}</Code>
2024-09-14 13:24:24 -05:00
</>
) : (
2025-01-06 20:09:11 -06:00
toolStrings.description
2024-09-14 13:24:24 -05:00
)
}
</Text>
</Flex>
{
!disabled && (
<Button
highContrast={tool.button.highContrast}
size={{
initial: undefined,
sm: tool.significant ? '3' : undefined,
}}
color={tool.button.color}
style={{ cursor: 'inherit' }}
>
2025-01-06 20:09:11 -06:00
{toolStrings.button}
2024-09-14 13:24:24 -05:00
<CaretRightIcon />
</Button>
)
}
</Flex>
2024-12-27 14:01:59 -06:00
</LinkI18n>
2024-09-14 13:24:24 -05:00
</Flex>