fix(BOOK-293): changed variants and props on IconButton component * fix(BOOK-293): changed variants and props on IconButton component * fix(BOOK-293): inherit color for icon Approved-by: Bianca Widstam Approved-by: Christel Westerberg
65 lines
1.3 KiB
TypeScript
65 lines
1.3 KiB
TypeScript
"use client"
|
|
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { Button } from "@scandic-hotels/design-system/Button"
|
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
|
|
|
import type { ComponentProps } from "react"
|
|
|
|
interface ShowMoreButtonProps extends ComponentProps<typeof Button> {
|
|
showLess?: boolean
|
|
textShowMore?: string
|
|
textShowLess?: string
|
|
loadMoreData: () => void
|
|
}
|
|
|
|
export default function ShowMoreButton({
|
|
variant = "Text",
|
|
color = "Primary",
|
|
size = "md",
|
|
showLess,
|
|
textShowMore,
|
|
textShowLess,
|
|
loadMoreData,
|
|
...props
|
|
}: ShowMoreButtonProps) {
|
|
const intl = useIntl()
|
|
|
|
if (!textShowMore) {
|
|
textShowMore = intl.formatMessage({
|
|
id: "common.showMore",
|
|
defaultMessage: "Show more",
|
|
})
|
|
}
|
|
|
|
if (!textShowLess) {
|
|
textShowLess = intl.formatMessage({
|
|
id: "common.showLess",
|
|
defaultMessage: "Show less",
|
|
})
|
|
}
|
|
|
|
return (
|
|
<Button
|
|
variant={variant}
|
|
color={color}
|
|
size={size}
|
|
onPress={loadMoreData}
|
|
{...props}
|
|
>
|
|
{showLess ? (
|
|
<>
|
|
<MaterialIcon icon="keyboard_arrow_up" color="CurrentColor" />
|
|
<span>{textShowLess}</span>
|
|
</>
|
|
) : (
|
|
<>
|
|
<MaterialIcon icon="keyboard_arrow_down" color="CurrentColor" />
|
|
<span>{textShowMore}</span>
|
|
</>
|
|
)}
|
|
</Button>
|
|
)
|
|
}
|