SW-1182 Updated popover to modal
This commit is contained in:
@@ -11,7 +11,7 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|||||||
import Title from "@/components/TempDesignSystem/Text/Title"
|
import Title from "@/components/TempDesignSystem/Text/Title"
|
||||||
import { formatPrice } from "@/utils/numberFormatting"
|
import { formatPrice } from "@/utils/numberFormatting"
|
||||||
|
|
||||||
import Modal from "../../Modal"
|
import Modal from "../../../Modal"
|
||||||
|
|
||||||
import styles from "./modal.module.css"
|
import styles from "./modal.module.css"
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|||||||
import useLang from "@/hooks/useLang"
|
import useLang from "@/hooks/useLang"
|
||||||
import { formatPrice } from "@/utils/numberFormatting"
|
import { formatPrice } from "@/utils/numberFormatting"
|
||||||
|
|
||||||
import Modal from "../../Modal"
|
import Modal from "../../../Modal"
|
||||||
import PriceDetailsTable from "../PriceDetailsTable"
|
import PriceDetailsTable from "../PriceDetailsTable"
|
||||||
|
|
||||||
import styles from "./ui.module.css"
|
import styles from "./ui.module.css"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { CloseLargeIcon } from "@/components/Icons"
|
import { CloseLargeIcon } from "@/components/Icons"
|
||||||
|
import Preamble from "@/components/TempDesignSystem/Text/Preamble"
|
||||||
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -34,6 +35,7 @@ function InnerModal({
|
|||||||
isOpen,
|
isOpen,
|
||||||
children,
|
children,
|
||||||
title,
|
title,
|
||||||
|
subtitle,
|
||||||
}: PropsWithChildren<InnerModalProps>) {
|
}: PropsWithChildren<InnerModalProps>) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
function modalStateHandler(newAnimationState: AnimationState) {
|
function modalStateHandler(newAnimationState: AnimationState) {
|
||||||
@@ -74,11 +76,18 @@ function InnerModal({
|
|||||||
{({ close }) => (
|
{({ close }) => (
|
||||||
<>
|
<>
|
||||||
<header className={styles.header}>
|
<header className={styles.header}>
|
||||||
{title && (
|
<div>
|
||||||
<Subtitle type="one" color="uiTextHighContrast">
|
{title && (
|
||||||
{title}
|
<Subtitle type="one" color="uiTextHighContrast">
|
||||||
</Subtitle>
|
{title}
|
||||||
)}
|
</Subtitle>
|
||||||
|
)}
|
||||||
|
{subtitle && (
|
||||||
|
<Preamble asChild>
|
||||||
|
<span>{subtitle}</span>
|
||||||
|
</Preamble>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<button onClick={close} type="button" className={styles.close}>
|
<button onClick={close} type="button" className={styles.close}>
|
||||||
<CloseLargeIcon color="uiTextMediumContrast" />
|
<CloseLargeIcon color="uiTextMediumContrast" />
|
||||||
@@ -99,6 +108,7 @@ export default function Modal({
|
|||||||
isOpen,
|
isOpen,
|
||||||
onToggle,
|
onToggle,
|
||||||
title,
|
title,
|
||||||
|
subtitle,
|
||||||
children,
|
children,
|
||||||
}: PropsWithChildren<ModalProps>) {
|
}: PropsWithChildren<ModalProps>) {
|
||||||
const [animation, setAnimation] = useState<AnimationState>(
|
const [animation, setAnimation] = useState<AnimationState>(
|
||||||
@@ -111,6 +121,9 @@ export default function Modal({
|
|||||||
isOpen ? AnimationStateEnum.visible : AnimationStateEnum.hidden
|
isOpen ? AnimationStateEnum.visible : AnimationStateEnum.hidden
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (typeof isOpen === "undefined") {
|
||||||
|
setAnimation(AnimationStateEnum.unmounted)
|
||||||
|
}
|
||||||
}, [isOpen])
|
}, [isOpen])
|
||||||
|
|
||||||
if (!trigger) {
|
if (!trigger) {
|
||||||
@@ -122,6 +135,7 @@ export default function Modal({
|
|||||||
onToggle={onToggle}
|
onToggle={onToggle}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title={title}
|
title={title}
|
||||||
|
subtitle={subtitle}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</InnerModal>
|
</InnerModal>
|
||||||
@@ -142,6 +156,7 @@ export default function Modal({
|
|||||||
animation={animation}
|
animation={animation}
|
||||||
setAnimation={setAnimation}
|
setAnimation={setAnimation}
|
||||||
title={title}
|
title={title}
|
||||||
|
subtitle={subtitle}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</InnerModal>
|
</InnerModal>
|
||||||
@@ -33,8 +33,8 @@
|
|||||||
|
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
height: var(--button-dimension);
|
min-height: var(--button-dimension);
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: var(--Spacing-x2) var(--Spacing-x3) 0;
|
padding: var(--Spacing-x2) var(--Spacing-x3) 0;
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,8 @@
|
|||||||
height: var(--button-dimension);
|
height: var(--button-dimension);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
padding: 0;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 768px) {
|
@media screen and (min-width: 768px) {
|
||||||
@@ -11,6 +11,7 @@ export type AnimationState = keyof typeof AnimationStateEnum
|
|||||||
export type ModalProps = {
|
export type ModalProps = {
|
||||||
onAnimationComplete?: VoidFunction
|
onAnimationComplete?: VoidFunction
|
||||||
title?: string
|
title?: string
|
||||||
|
subtitle?: string
|
||||||
} & (
|
} & (
|
||||||
| { trigger: JSX.Element; isOpen?: never; onToggle?: never }
|
| { trigger: JSX.Element; isOpen?: never; onToggle?: never }
|
||||||
| {
|
| {
|
||||||
@@ -77,24 +77,15 @@ input[type="radio"]:checked + .card .checkIcon {
|
|||||||
margin: 0 auto var(--Spacing-x2);
|
margin: 0 auto var(--Spacing-x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.popover {
|
.modal section:focus-visible {
|
||||||
background-color: var(--Main-Grey-White);
|
|
||||||
border-radius: var(--Corner-radius-Medium);
|
|
||||||
left: 0px;
|
|
||||||
max-height: 400px;
|
|
||||||
padding: var(--Spacing-x2);
|
|
||||||
top: calc(55px + var(--Spacing-x1));
|
|
||||||
width: 100%;
|
|
||||||
box-shadow: 0px 0px 14px 6px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.popover section:focus-visible {
|
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
.popover .popoverText {
|
.terms {
|
||||||
margin-bottom: var(--Spacing-x-half);
|
margin-top: var(--Spacing-x3);
|
||||||
|
margin-bottom: var(--Spacing-x3);
|
||||||
}
|
}
|
||||||
.popover .popoverHeading {
|
.termsText:nth-child(n) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
margin-bottom: var(--Spacing-x1);
|
margin-bottom: var(--Spacing-x1);
|
||||||
font-weight: 600; /* TODO: Remove when this is updated in Design system */
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import { useEffect, useRef } from "react"
|
|||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { CheckIcon, InfoCircleIcon } from "@/components/Icons"
|
import { CheckIcon, InfoCircleIcon } from "@/components/Icons"
|
||||||
|
import Button from "@/components/TempDesignSystem/Button"
|
||||||
import Label from "@/components/TempDesignSystem/Form/Label"
|
import Label from "@/components/TempDesignSystem/Form/Label"
|
||||||
import Popover from "@/components/TempDesignSystem/Popover"
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||||
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||||
|
|
||||||
|
import Modal from "../../../Modal/index"
|
||||||
import { RATE_CARD_EQUAL_HEIGHT_CLASS } from "../utils"
|
import { RATE_CARD_EQUAL_HEIGHT_CLASS } from "../utils"
|
||||||
import PriceTable from "./PriceList"
|
import PriceTable from "./PriceList"
|
||||||
|
|
||||||
@@ -116,33 +118,36 @@ export default function FlexibilityOption({
|
|||||||
/>
|
/>
|
||||||
<div className={`${styles.card} ${RATE_CARD_EQUAL_HEIGHT_CLASS}`}>
|
<div className={`${styles.card} ${RATE_CARD_EQUAL_HEIGHT_CLASS}`}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<Popover
|
<Modal
|
||||||
placement="bottom left"
|
trigger={
|
||||||
triggerContent={
|
<Button intent="text">
|
||||||
<InfoCircleIcon
|
<InfoCircleIcon
|
||||||
width={16}
|
width={16}
|
||||||
height={16}
|
height={16}
|
||||||
color="uiTextMediumContrast"
|
color="uiTextMediumContrast"
|
||||||
/>
|
/>
|
||||||
|
</Button>
|
||||||
}
|
}
|
||||||
|
title={name}
|
||||||
|
subtitle={paymentTerm}
|
||||||
>
|
>
|
||||||
<Caption
|
<div className={styles.terms}>
|
||||||
color="uiTextHighContrast"
|
{priceInformation?.map((info) => (
|
||||||
type="bold"
|
<Body
|
||||||
className={styles.popoverHeading}
|
key={info}
|
||||||
>
|
color="uiTextHighContrast"
|
||||||
{name}
|
className={styles.termsText}
|
||||||
</Caption>
|
>
|
||||||
{priceInformation?.map((info) => (
|
<CheckIcon
|
||||||
<Caption
|
color="uiSemanticSuccess"
|
||||||
key={info}
|
width={20}
|
||||||
color="uiTextHighContrast"
|
height={20}
|
||||||
className={styles.popoverText}
|
></CheckIcon>
|
||||||
>
|
{info}
|
||||||
{info}
|
</Body>
|
||||||
</Caption>
|
))}
|
||||||
))}
|
</div>
|
||||||
</Popover>
|
</Modal>
|
||||||
<div className={styles.priceType}>
|
<div className={styles.priceType}>
|
||||||
<Caption color="uiTextHighContrast">{name}</Caption>
|
<Caption color="uiTextHighContrast">{name}</Caption>
|
||||||
<Caption color="uiTextPlaceholder">({paymentTerm})</Caption>
|
<Caption color="uiTextPlaceholder">({paymentTerm})</Caption>
|
||||||
|
|||||||
Reference in New Issue
Block a user