Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3 - feat: make ResultBlock responsive and colorable #948

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,34 @@ 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}
></StackedHighlights>
trulshj marked this conversation as resolved.
Show resolved Hide resolved
</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);
}
}
Loading