Skip to content

Commit

Permalink
V3 - feat: make ResultBlock responsive and colorable (#948)
Browse files Browse the repository at this point in the history
Co-authored-by: Petter Hohle <[email protected]>
  • Loading branch information
trulshj and petterhh authored Dec 5, 2024
1 parent 7d8c494 commit 7eb239f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 12 deletions.
6 changes: 5 additions & 1 deletion src/components/customerCases/customerCase/CustomerCase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export default async function CustomerCase({
</div>
<div className={styles.sectionsWrapper}>
{customerCase.sections.map((section) => (
<CustomerCaseSection key={section._key} section={section} />
<CustomerCaseSection
key={section._key}
section={section}
clientColors={customerCase.clientColors}
/>
))}
</div>
{consultantsResult?.ok && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { CustomerCaseSection as CustomerCaseSectionObject } from "studioShared/lib/interfaces/customerCases";
import {
CustomerCaseClientColors,
CustomerCaseSection as CustomerCaseSectionObject,
} from "studioShared/lib/interfaces/customerCases";

import ImageSection from "./image/ImageSection";
import ListBlock from "./list/ListBlock";
Expand All @@ -7,16 +10,20 @@ import SplitSection from "./splitSection/SplitSection";

export function CustomerCaseSection({
section,
clientColors,
}: {
section: CustomerCaseSectionObject;
clientColors?: CustomerCaseClientColors;
}) {
switch (section._type) {
case "splitSection":
return <SplitSection section={section} />;
case "imageBlock":
return <ImageSection section={section} />;
case "resultsBlock":
return <ResultsBlock section={section} />;
return (
<ResultsBlock section={section} blockColor={clientColors?.color} />
);
case "listBlock":
return <ListBlock section={section} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@ import styles from "./resultsBlock.module.css";

export interface ResultsBlockProps {
section: ResultsBlockObject;
blockColor?: string;
}

export default function ResultsBlock({ section }: ResultsBlockProps) {
export default function ResultsBlock({
section,
blockColor,
}: ResultsBlockProps) {
return (
section.resultsBlockTitle && (
<div className={styles.wrapper}>
<div>
<StackedHighlights section={section}></StackedHighlights>
<StackedHighlights section={section} blockColor={blockColor} />
</div>
</div>
)
);
}

function StackedHighlights({ section }: ResultsBlockProps) {
function StackedHighlights({ section, blockColor }: ResultsBlockProps) {
const style = {
"--block-color": blockColor ?? "var(--surface-yellow)",
} as React.CSSProperties;

return (
<div className={styles.highlightWrapper}>
<div className={styles.highlightWrapper} style={style}>
<div className={styles.highlightBlock}>
<Text type="labelRegular" className={styles.highlightOutside}>
{section.resultsBlockTitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
}

.highlightCard {
border: 3px solid var(--surface-yellow);
border: 3px solid var(--block-color);
border-radius: 0.25rem;
background-color: var(--surface-yellow);
background-color: var(--block-color);
}

.highlightCard .innerContent {
Expand All @@ -29,7 +29,7 @@
}

.highlightOutside {
background-color: var(--surface-yellow);
background-color: var(--block-color);
color: var(--text-primary);
display: inline-block;
padding: 0.25rem 1.25rem;
Expand Down Expand Up @@ -77,6 +77,7 @@
margin-top: calc(3px * -1);
border-top-left-radius: 0;
height: auto;
width: 100%;
}

.highlightRow .highlightCard:not(:last-child) {
Expand All @@ -93,6 +94,28 @@
border-top-left-radius: 0;
}

.highlightRow .highlightCard {
width: 100%;
@media (max-width: 425px) {
div:has(> .highlightWrapper) {
width: 100%;
}

.highlightOutside {
margin-bottom: 0;
}

.highlightRow {
flex-direction: column;
}

.highlightRow .highlightCard:first-child {
border-top-right-radius: 0.25rem;
}

.highlightRow .highlightCard:last-child {
border-bottom-left-radius: 0.25rem;
}

.highlightRow .highlightCard:not(:first-child) {
border-left: 3px solid var(--block-color);
}
}

0 comments on commit 7eb239f

Please sign in to comment.