Skip to content

Commit

Permalink
Refactor from ResultBlock to ResultsBlock, fix comments on pr
Browse files Browse the repository at this point in the history
  • Loading branch information
idamand committed Nov 4, 2024
1 parent ae651b2 commit 53349c1
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CustomerCaseSection as CustomerCaseSectionObject } from "studioShared/l

import ImageSection from "./image/ImageSection";
import QuoteBlock from "./quote/QuoteBlock";
import ResultBlock from "./results/ResultBlock";
import ResultsBlock from "./results/ResultsBlock";
import RichTextSection from "./richText/RichTextSection";
import SplitSection from "./splitSection/SplitSection";

Expand All @@ -20,7 +20,7 @@ export function CustomerCaseSection({
return <QuoteBlock section={section} />;
case "imageBlock":
return <ImageSection section={section} />;
case "resultBlock":
return <ResultBlock section={section} />;
case "resultsBlock":
return <ResultsBlock section={section} />;
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import Text from "src/components/text/Text";
import { ResultBlock as ResultBlockObject } from "studioShared/lib/interfaces/resultBlock";
import { ResultsBlock as ResultsBlockObject } from "studioShared/lib/interfaces/resultsBlock";

import styles from "./resultBlock.module.css";
import styles from "./resultsBlock.module.css";

export interface ResultBlockProps {
section: ResultBlockObject;
export interface ResultsBlockProps {
section: ResultsBlockObject;
}

export default function QuoteBlock({ section }: ResultBlockProps) {
export default function ResultsBlock({ section }: ResultsBlockProps) {
return (
section.resultBlockTitle && (
section.resultsBlockTitle && (
<div className={styles.wrapper}>
<div className={styles.resultblock}>
<Text type="h4" className={styles.blocktitle}>
{section.resultBlockTitle}
{section.resultsBlockTitle}
</Text>
<div className={styles.resultrow}>
{section.resultList?.map((result) => (
{section.resultsList?.map((result) => (
<div className={styles.results} key={result._key}>
<Text type="h2" className={styles.mainresult}>
{result.result}
</Text>
<Text type="labelRegular">{result.description}</Text>
</div>
))}{" "}
))}
</div>
</div>
</div>
Expand Down
10 changes: 1 addition & 9 deletions src/components/text/text.module.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
:where(.desktopLink,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
.bodyXl) {
:where(.desktopLink, .h1, .h2, .h3, .h4, .h5, .h6, .bodyXl) {
font-family: var(--font-britti-sans);
}


.bodyBig,
.bodyNormal,
.labelSmall,
Expand Down
4 changes: 2 additions & 2 deletions studioShared/lib/interfaces/customerCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IImage } from "studio/lib/interfaces/media";

import { ImageBlock } from "./imageBlock";
import { QuoteBlock } from "./quoteBlock";
import { ResultBlock } from "./resultBlock";
import { ResultsBlock } from "./resultsBlock";
import { RichTextBlock } from "./richTextBlock";
import { SplitSection } from "./splitSection";

Expand Down Expand Up @@ -34,7 +34,7 @@ export type BaseCustomerCaseSection = RichTextBlock | ImageBlock | QuoteBlock;
export type CustomerCaseSection =
| BaseCustomerCaseSection
| SplitSection
| ResultBlock;
| ResultsBlock;

export interface CustomerCase extends CustomerCaseBase {
projectInfo: CustomerCaseProjectInfo;
Expand Down
12 changes: 0 additions & 12 deletions studioShared/lib/interfaces/resultBlock.ts

This file was deleted.

12 changes: 12 additions & 0 deletions studioShared/lib/interfaces/resultsBlock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
interface ResultsListItem {
result: string;
description: string;
_key: string;
}

export interface ResultsBlock {
_key: string;
_type: "resultsBlock";
resultsBlockTitle?: string;
resultsList?: ResultsListItem[];
}
6 changes: 3 additions & 3 deletions studioShared/lib/queries/customerCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export const CUSTOMER_CASE_QUERY = groq`
${BASE_SECTIONS_FRAGMENT}
}
},
_type == "resultBlock" => {
"resultBlockTitle": ${translatedFieldFragment("resultBlockTitle")},
"resultList": resultList[] {
_type == "resultsBlock" => {
"resultsBlockTitle": ${translatedFieldFragment("resultsBlockTitle")},
"resultsList": resultsList[] {
_key,
result,
"description": ${translatedFieldFragment("description")},
Expand Down
4 changes: 2 additions & 2 deletions studioShared/schemas/documents/customerCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { titleSlug } from "studio/schemas/schemaTypes/slug";
import { buildDraftId, buildPublishedId } from "studio/utils/documentUtils";
import { firstTranslation } from "studio/utils/i18n";
import { customerCaseProjectInfo } from "studioShared/schemas/fields/customerCaseProjectInfo";
import resultBlock from "studioShared/schemas/objects/resultBlock";
import resultsBlock from "studioShared/schemas/objects/resultsBlock";
import { baseCustomerCaseSections } from "studioShared/schemas/objects/sections";
import splitSection from "studioShared/schemas/objects/splitSection";

Expand All @@ -17,7 +17,7 @@ export const customerCaseID = "customerCase";
export const customerCaseSections = [
...baseCustomerCaseSections,
splitSection,
resultBlock,
resultsBlock,
];

const customerCase = defineType({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import { defineField } from "sanity";
import { isInternationalizedString } from "studio/lib/interfaces/global";
import { firstTranslation } from "studio/utils/i18n";

const resultBlock = defineField({
name: "resultBlock",
const resultsBlock = defineField({
name: "resultsBlock",
type: "object",
title: "Result Block",
title: "Results Block",
description: "This block can be used to add some results from the project.",
fields: [
{
name: "resultBlockTitle",
title: "Result Block Title",
name: "resultsBlockTitle",
title: "Results Block Title",
description:
"Please provide a title for the result block, for example: 'These are the results from the project'",
type: "internationalizedArrayString",
},
{
name: "resultList",
name: "resultsList",
title: "List of results",
description: "Add up to five results to be included in this list",
type: "array",
Expand Down Expand Up @@ -67,7 +67,7 @@ const resultBlock = defineField({
],
preview: {
select: {
title: "resultBlockTitle",
title: "resultsBlockTitle",
},
prepare({ title }) {
if (title !== undefined && !isInternationalizedString(title)) {
Expand All @@ -85,4 +85,4 @@ const resultBlock = defineField({
},
});

export default resultBlock;
export default resultsBlock;

0 comments on commit 53349c1

Please sign in to comment.