Files
tuono/apps/documentation/src/components/NavigationButtons/NavigationButtons.tsx
T

64 lines
1.5 KiB
TypeScript
Raw Normal View History

import type { JSX } from 'react'
2024-11-03 22:02:10 +01:00
import { Box, Button, Text, Title, Flex } from '@mantine/core'
import { IconArrowRight, IconArrowLeft } from '@tabler/icons-react'
import { Link } from 'tuono'
2024-11-03 22:02:10 +01:00
interface NavigationButtonData {
2024-11-03 22:07:22 +01:00
href: string
title: string
2024-11-03 22:02:10 +01:00
}
interface NavigationButtonsProps {
prev?: NavigationButtonData
next?: NavigationButtonData
2024-11-03 22:02:10 +01:00
}
export default function NavigationButtons({
2024-11-03 22:07:22 +01:00
prev,
next,
2024-11-03 22:02:10 +01:00
}: NavigationButtonsProps): JSX.Element {
2024-11-03 22:07:22 +01:00
return (
<Flex mt={50} gap={10}>
{prev && <NavigationBtn type="prev" {...prev} />}
{next && <NavigationBtn type="next" {...next} />}
</Flex>
)
2024-11-03 22:02:10 +01:00
}
interface NavigationBtnProps extends NavigationButtonData {
2024-11-03 22:07:22 +01:00
type: 'next' | 'prev'
2024-11-03 22:02:10 +01:00
}
const NavigationBtn = ({
2024-11-03 22:07:22 +01:00
type,
title,
href,
}: NavigationBtnProps): JSX.Element => {
2024-11-03 22:07:22 +01:00
const heading = type === 'next' ? 'Next' : 'Previous'
const textAlign = type === 'next' ? 'left' : 'right'
const variant = type === 'next' ? 'filled' : 'outline'
2024-11-03 22:02:10 +01:00
2024-11-03 22:07:22 +01:00
return (
<Button
component={Link}
fullWidth
variant={variant}
href={href}
justify="space-between"
h="auto"
rightSection={type === 'next' && <IconArrowRight />}
leftSection={type === 'prev' && <IconArrowLeft />}
p="20"
>
<Box>
<Title component="span" display="block" order={4} style={{ textAlign }}>
{heading}
</Title>
<Text component="span" display="block" style={{ textAlign }}>
{title}
</Text>
</Box>
</Button>
)
2024-11-03 22:02:10 +01:00
}