From b1b0b77b2f507e80099d49a2d8dcdc7b97200ab9 Mon Sep 17 00:00:00 2001 From: Ane Date: Fri, 20 Dec 2024 12:40:31 +0100 Subject: [PATCH] remove calltoactionsection --- README.md | 2 +- .../sections/callToAction/CallToAction.tsx | 29 ----------- .../callToAction/CallToActionPreview.tsx | 37 -------------- .../callToAction/callToAction.module.css | 41 ---------------- src/utils/renderSection.tsx | 26 ---------- studio/lib/interfaces/pages.ts | 8 ---- studio/lib/queries/pages.ts | 7 --- studio/schemas/documents/pageBuilder.ts | 2 - .../schemas/objects/sections/callToAction.ts | 48 ------------------- 9 files changed, 1 insertion(+), 199 deletions(-) delete mode 100644 src/components/sections/callToAction/CallToAction.tsx delete mode 100644 src/components/sections/callToAction/CallToActionPreview.tsx delete mode 100644 src/components/sections/callToAction/callToAction.module.css delete mode 100644 studio/schemas/objects/sections/callToAction.ts diff --git a/README.md b/README.md index 9cc5bd0d4..515959ce1 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ The `Company Information` menu allows you to configure global settings for your ### Pages - **Creating Pages**: Content editors can create and manage pages under the `Pages` menu in the Sanity Studio. -- **Adding Sections**: Each page can be customized with structured content that includes various predefined sections such as hero, article, features, callToAction and grid. +- **Adding Sections**: Each page can be customized with structured content that includes various predefined sections such as hero, article, features and grid. ## Development diff --git a/src/components/sections/callToAction/CallToAction.tsx b/src/components/sections/callToAction/CallToAction.tsx deleted file mode 100644 index d68e5de9d..000000000 --- a/src/components/sections/callToAction/CallToAction.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import LinkButton from "src/components/linkButton/LinkButton"; -import Text from "src/components/text/Text"; -import { CallToActionSection } from "studio/lib/interfaces/pages"; - -import styles from "./callToAction.module.css"; - -interface CallToActionProps { - callToAction: CallToActionSection; -} - -const CallToAction = ({ callToAction }: CallToActionProps) => { - return ( -
- {callToAction?.basicTitle} - -
- ); -}; - -export default CallToAction; diff --git a/src/components/sections/callToAction/CallToActionPreview.tsx b/src/components/sections/callToAction/CallToActionPreview.tsx deleted file mode 100644 index 288db6f9e..000000000 --- a/src/components/sections/callToAction/CallToActionPreview.tsx +++ /dev/null @@ -1,37 +0,0 @@ -"use client"; - -import { useQuery } from "@sanity/react-loader"; -import { Suspense } from "react"; - -import { PreviewProps } from "src/types/preview"; -import { CallToActionSection, PageBuilder } from "studio/lib/interfaces/pages"; -import { PAGE_QUERY } from "studio/lib/queries/pages"; - -import CallToAction from "./CallToAction"; - -export default function CallToActionPreview({ - initialData, - sectionIndex, -}: PreviewProps) { - const { data: newData } = useQuery( - PAGE_QUERY, - { id: initialData.data._id, language: initialData.data.language }, - { initial: initialData }, - ); - - const callToActionSection = newData - ? (newData.sections.find( - (section, index) => - section._type === "ctaSection" && index === sectionIndex, - ) as CallToActionSection) - : (initialData.data.sections.find( - (section, index) => - section._type === "ctaSection" && index === sectionIndex, - ) as CallToActionSection); - - return ( - - - - ); -} diff --git a/src/components/sections/callToAction/callToAction.module.css b/src/components/sections/callToAction/callToAction.module.css deleted file mode 100644 index 5e17d3204..000000000 --- a/src/components/sections/callToAction/callToAction.module.css +++ /dev/null @@ -1,41 +0,0 @@ -.article { - display: flex; - flex-direction: column; - align-items: center; - text-align: center; - gap: 1.5rem; - padding: 5rem 2rem; - background: var(--surface-green); - - @media (min-width: 640px) { - padding: 5rem 3rem; - } - - @media (min-width: 1024px) { - padding: 15rem 7.5rem; - } -} - -.list { - list-style-type: none; - margin: 0; - padding: 0; - display: flex; - flex-direction: column; - align-items: center; - gap: 1.5rem; - align-self: stretch; - - @media (min-width: 1024px) { - display: flex; - flex-direction: row; - justify-content: center; - align-items: flex-start; - } - - @media (max-width: 1024px) { - & > li { - width: 100%; - } - } -} diff --git a/src/utils/renderSection.tsx b/src/utils/renderSection.tsx index 3968e32f5..d7baa8eed 100644 --- a/src/utils/renderSection.tsx +++ b/src/utils/renderSection.tsx @@ -2,8 +2,6 @@ import { QueryResponseInitial } from "@sanity/react-loader"; import Article from "src/components/sections/article/Article"; import ArticlePreview from "src/components/sections/article/ArticlePreview"; -import CallToAction from "src/components/sections/callToAction/CallToAction"; -import CallToActionPreview from "src/components/sections/callToAction/CallToActionPreview"; import CompensationCalculator from "src/components/sections/compensation-calculator/CompensationCalculator"; import ContactBox from "src/components/sections/contact-box/ContactBox"; import CustomerCasesEntry from "src/components/sections/customerCasesEntry/CustomerCasesEntry"; @@ -26,7 +24,6 @@ import Openness from "src/components/sections/openness/Openness"; import { Locale } from "src/i18n/routing"; import { ArticleSection, - CallToActionSection, CustomerCasesEntrySection, GridSection, HeroSection, @@ -90,22 +87,6 @@ const renderArticleSection = ( ); }; -const renderCallToActionSection = ( - section: CallToActionSection, - sectionIndex: number, - isDraftMode: boolean, - initialData: QueryResponseInitial, -) => { - return isDraftMode ? ( - - ) : ( - - ); -}; - const renderImageSection = ( section: ImageSection, sectionIndex: number, @@ -200,13 +181,6 @@ const SectionRenderer = ({ isDraftMode, initialData, ); - case "ctaSection": - return renderCallToActionSection( - section, - sectionIndex, - isDraftMode, - initialData, - ); case "imageSection": return renderImageSection( section, diff --git a/studio/lib/interfaces/pages.ts b/studio/lib/interfaces/pages.ts index 1d7e434e7..1e02a729a 100644 --- a/studio/lib/interfaces/pages.ts +++ b/studio/lib/interfaces/pages.ts @@ -31,13 +31,6 @@ export interface ArticleSection { imageExtended: ImageExtendedProps; } -export interface CallToActionSection { - _type: "ctaSection"; - _key: string; - basicTitle?: string; - callToActions?: ILink[]; -} - export interface ImageSection { _type: "imageSection"; _key: string; @@ -175,7 +168,6 @@ export type Section = | HeroSection | LogoSaladSection | ArticleSection - | CallToActionSection | ImageSection | ImageSplitSection | GridSection diff --git a/studio/lib/queries/pages.ts b/studio/lib/queries/pages.ts index 5ed161b63..5303d2695 100644 --- a/studio/lib/queries/pages.ts +++ b/studio/lib/queries/pages.ts @@ -43,13 +43,6 @@ const SECTIONS_FRAGMENT = groq` ..., "image": image {${INTERNATIONALIZED_IMAGE_FRAGMENT}}, }, - _type == "ctaSection" => { - ..., - callToActions[] { - ..., - ${TRANSLATED_LINK_FRAGMENT} - } - }, _type == "compensationCalculator" => { ..., "moduleTitle": ${translatedFieldFragment("moduleTitle")}, diff --git a/studio/schemas/documents/pageBuilder.ts b/studio/schemas/documents/pageBuilder.ts index 015405e6e..de980fe53 100644 --- a/studio/schemas/documents/pageBuilder.ts +++ b/studio/schemas/documents/pageBuilder.ts @@ -48,8 +48,6 @@ const pageBuilder = defineType({ hero, logoSalad, article, - // callToAction, - // testimonals, imageSplitSection, imageSection, // grid, diff --git a/studio/schemas/objects/sections/callToAction.ts b/studio/schemas/objects/sections/callToAction.ts deleted file mode 100644 index bab19c37a..000000000 --- a/studio/schemas/objects/sections/callToAction.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { defineField } from "sanity"; - -import callToActionField from "studio/schemas/fields/callToActionFields"; -import { title } from "studio/schemas/fields/text"; - -const callToActionSectionID = "ctaSection"; - -export const callToAction = defineField({ - name: callToActionSectionID, - title: "Call to Action", - type: "object", - fields: [ - { - ...title, - description: - "This will be the title of the call to action section. Make it engaging to capture the attention of your audience.", - }, - { - name: "callToActions", - title: "Call to Actions", - description: - "The first Call to Action (CTA) will be styled as a primary link button.", - type: "array", - of: [ - { - type: "object", - fields: callToActionField.fields, - preview: callToActionField.preview, - }, - ], - validation: (rule) => rule.required(), - }, - ], - preview: { - select: { - title: "basicTitle", - }, - prepare(selection) { - const { title } = selection; - return { - title: title || "No title", - subtitle: "Call to Action", - }; - }, - }, -}); - -export default callToAction;