Files
web/components/TempDesignSystem/ShowMoreButton/index.tsx
2025-01-13 13:35:03 +01:00

58 lines
1.2 KiB
TypeScript

"use client"
import { useIntl } from "react-intl"
import { ChevronDownIcon } from "@/components/Icons"
import Button from "@/components/TempDesignSystem/Button"
import { showMoreButtonVariants } from "./variants"
import styles from "./showMoreButton.module.css"
import type { ShowMoreButtonProps } from "./showMoreButton"
export default function ShowMoreButton({
className,
intent,
disabled,
showLess,
textShowMore,
textShowLess,
loadMoreData,
}: ShowMoreButtonProps) {
const intl = useIntl()
const classNames = showMoreButtonVariants({
className,
intent,
})
if (!textShowMore) {
textShowMore = intl.formatMessage({
id: "Show more",
})
}
if (!textShowLess) {
textShowLess = intl.formatMessage({
id: "Show less",
})
}
return (
<div className={`${classNames} ${showLess ? styles.showLess : ""}`}>
<Button
className={styles.button}
disabled={disabled}
onClick={loadMoreData}
variant="icon"
type="button"
theme="base"
intent="text"
>
<ChevronDownIcon className={styles.icon} />
{showLess ? textShowLess : textShowMore}
</Button>
</div>
)
}