chore(SW-3246): Moved Alert component into design system * chore(SW-3246): Moved Alert component into design system * chore(SW-3246): Optimsed code and imports * chore(SW-3246): Moved type AlertTypeEnum and other to common package Approved-by: Anton Gunnarsson
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
import { useIntl } from 'react-intl'
|
|
|
|
import { MaterialIcon } from '../../Icons/MaterialIcon'
|
|
import { JsonToHtml } from '../../JsonToHtml/JsonToHtml'
|
|
import { Button } from '../../Button'
|
|
import SidePeek from '../../SidePeek'
|
|
|
|
import styles from './sidepeek.module.css'
|
|
|
|
import type { AlertSidepeekProps } from './sidepeek'
|
|
|
|
export default function AlertSidepeek({
|
|
ctaText,
|
|
sidePeekContent,
|
|
}: AlertSidepeekProps) {
|
|
const intl = useIntl()
|
|
const [sidePeekIsOpen, setSidePeekIsOpen] = useState(false)
|
|
const { heading, content } = sidePeekContent
|
|
|
|
return (
|
|
<div className={styles.alertSidepeek}>
|
|
<Button
|
|
onPress={() => setSidePeekIsOpen(true)}
|
|
variant="Text"
|
|
color="Primary"
|
|
size="Small"
|
|
wrapping
|
|
typography="Body/Supporting text (caption)/smBold"
|
|
>
|
|
{ctaText}
|
|
<MaterialIcon icon="chevron_right" size={20} color="CurrentColor" />
|
|
</Button>
|
|
|
|
<SidePeek
|
|
title={heading}
|
|
isOpen={sidePeekIsOpen}
|
|
handleClose={() => setSidePeekIsOpen(false)}
|
|
closeLabel={intl.formatMessage({
|
|
defaultMessage: 'Close',
|
|
})}
|
|
>
|
|
<JsonToHtml
|
|
nodes={content.json.children}
|
|
embeds={content.embedded_itemsConnection.edges}
|
|
/>
|
|
</SidePeek>
|
|
</div>
|
|
)
|
|
}
|