refactor: organize css
This commit is contained in:
+78
@@ -0,0 +1,78 @@
|
||||
.benefitCard {
|
||||
background-color: var(--Main-Grey-White);
|
||||
border: 1px solid var(--Base-Border-Subtle);
|
||||
border-radius: var(--Corner-radius-Small);
|
||||
color: var(--Main-Brand-Burgundy);
|
||||
padding: 0 var(--Spacing-x2);
|
||||
z-index: 2;
|
||||
grid-column: 1/3;
|
||||
}
|
||||
|
||||
.benefitValueContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--Spacing-x-one-and-half);
|
||||
}
|
||||
|
||||
.benefitValue {
|
||||
background-color: var(--Main-Brand-Burgundy);
|
||||
border-radius: var(--Corner-radius-Medium);
|
||||
color: var(--Base-Surface-Primary-Hover-alt, #fff);
|
||||
font-size: var(--typography-Footnote-Regular-fontSize);
|
||||
padding: var(--Spacing-x-half) var(--Spacing-x1);
|
||||
}
|
||||
|
||||
.benefitValueDetails {
|
||||
font-size: var(--typography-Footnote-Regular-fontSize);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.benefitCardHeader {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
}
|
||||
|
||||
.benefitCardDescription {
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
.benefitInfo {
|
||||
border-bottom: 1px solid var(--Base-Border-Subtle);
|
||||
padding: var(--Spacing-x-one-and-half) 0;
|
||||
}
|
||||
|
||||
.benefitComparison {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.comparisonItem {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: var(--Spacing-x-one-and-half);
|
||||
}
|
||||
|
||||
.details[open] .chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.summary {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 950px) {
|
||||
.benefitComparison {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { ChevronDown, Minus } from "react-feather"
|
||||
|
||||
import CheckCircle from "@/components/Icons/CheckCircle"
|
||||
import Title from "@/components/Title"
|
||||
|
||||
import styles from "./benefitCard.module.css"
|
||||
|
||||
import {
|
||||
BenefitCardProps,
|
||||
BenefitValueProps,
|
||||
} from "@/types/components/loyalty/blocks"
|
||||
|
||||
function BenefitValue({ benefit }: BenefitValueProps) {
|
||||
if (!benefit.unlocked) {
|
||||
return <Minus />
|
||||
}
|
||||
if (!benefit.value) {
|
||||
return <CheckCircle height={32} width={32} />
|
||||
}
|
||||
return (
|
||||
<div className={styles.benefitValueContainer}>
|
||||
<span className={styles.benefitValue}>{benefit.value}</span>
|
||||
{benefit.valueDetails && (
|
||||
<span className={styles.benefitValueDetails}>
|
||||
{benefit.valueDetails}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function BenefitCard({
|
||||
comparedValues,
|
||||
title,
|
||||
description,
|
||||
}: BenefitCardProps) {
|
||||
return (
|
||||
<div className={styles.benefitCard}>
|
||||
<div className={styles.benefitInfo}>
|
||||
<details className={styles.details}>
|
||||
<summary className={styles.summary}>
|
||||
<hgroup className={styles.benefitCardHeader}>
|
||||
<Title as="h5" level="h2" className={styles.benefitCardTitle}>
|
||||
{title}
|
||||
</Title>
|
||||
<span className={styles.chevron}>
|
||||
<ChevronDown />
|
||||
</span>
|
||||
</hgroup>
|
||||
</summary>
|
||||
<p className={styles.benefitCardDescription}>{description}</p>
|
||||
</details>
|
||||
</div>
|
||||
<div className={styles.benefitComparison}>
|
||||
{comparedValues.map((benefit, idx) => (
|
||||
<div key={idx} className={styles.comparisonItem}>
|
||||
<BenefitValue benefit={benefit} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user