fix(SW-438): add ContentCard, ScriptedCard and Shortcuts to ContentPage sidebar
This commit is contained in:
@@ -45,10 +45,8 @@ export default function CardsGrid({
|
|||||||
theme={cards_grid.theme ?? "one"}
|
theme={cards_grid.theme ?? "one"}
|
||||||
key={card.system.uid}
|
key={card.system.uid}
|
||||||
scriptedTopTitle={card.scripted_top_title}
|
scriptedTopTitle={card.scripted_top_title}
|
||||||
heading={card.heading}
|
|
||||||
bodyText={card.body_text}
|
bodyText={card.body_text}
|
||||||
secondaryButton={card.secondaryButton}
|
{...card}
|
||||||
primaryButton={card.primaryButton}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case CardsGridEnum.cards.TeaserCard:
|
case CardsGridEnum.cards.TeaserCard:
|
||||||
@@ -57,21 +55,15 @@ export default function CardsGrid({
|
|||||||
key={card.system.uid}
|
key={card.system.uid}
|
||||||
title={card.heading}
|
title={card.heading}
|
||||||
description={card.body_text}
|
description={card.body_text}
|
||||||
primaryButton={card.primaryButton}
|
{...card}
|
||||||
secondaryButton={card.secondaryButton}
|
|
||||||
sidePeekButton={card.sidePeekButton}
|
|
||||||
sidePeekContent={card.sidePeekContent}
|
|
||||||
image={card.image}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case CardsGridEnum.cards.LoyaltyCard:
|
case CardsGridEnum.cards.LoyaltyCard:
|
||||||
return (
|
return (
|
||||||
<LoyaltyCard
|
<LoyaltyCard
|
||||||
key={card.system.uid}
|
key={card.system.uid}
|
||||||
image={card.image}
|
|
||||||
heading={card.heading}
|
|
||||||
bodyText={card.body_text}
|
bodyText={card.body_text}
|
||||||
link={card.link}
|
{...card}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import JsonToHtml from "@/components/JsonToHtml"
|
import JsonToHtml from "@/components/JsonToHtml"
|
||||||
|
|
||||||
|
import ShortcutsList from "../Blocks/ShortcutsList"
|
||||||
|
import Card from "../TempDesignSystem/Card"
|
||||||
|
import TeaserCard from "../TempDesignSystem/TeaserCard"
|
||||||
import JoinLoyaltyContact from "./JoinLoyalty"
|
import JoinLoyaltyContact from "./JoinLoyalty"
|
||||||
import MyPagesNavigation from "./MyPagesNavigation"
|
import MyPagesNavigation from "./MyPagesNavigation"
|
||||||
|
|
||||||
@@ -26,6 +29,19 @@ export default function Sidebar({ blocks }: SidebarProps) {
|
|||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
case SidebarEnums.blocks.ContentCard:
|
||||||
|
console.log("EEE", block.content_card)
|
||||||
|
return (
|
||||||
|
<TeaserCard
|
||||||
|
{...block.content_card}
|
||||||
|
title={block.content_card.heading}
|
||||||
|
description={block.content_card.body_text}
|
||||||
|
style={
|
||||||
|
block.content_card.theme === "gray" ? "default" : "featured"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
case SidebarEnums.blocks.DynamicContent:
|
case SidebarEnums.blocks.DynamicContent:
|
||||||
switch (block.dynamic_content.component) {
|
switch (block.dynamic_content.component) {
|
||||||
case DynamicContentEnum.Sidebar.components.my_pages_navigation:
|
case DynamicContentEnum.Sidebar.components.my_pages_navigation:
|
||||||
@@ -40,6 +56,20 @@ export default function Sidebar({ blocks }: SidebarProps) {
|
|||||||
key={`${block.typename}-${idx}`}
|
key={`${block.typename}-${idx}`}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
case SidebarEnums.blocks.ScriptedCard:
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
{...block.scripted_card}
|
||||||
|
bodyText={block.scripted_card.body_text}
|
||||||
|
scriptedTopTitle={block.scripted_card.scripted_top_title}
|
||||||
|
theme={block.scripted_card.theme ?? "image"}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
/*case SidebarEnums.blocks.Shortcuts:
|
||||||
|
console.log("SSS", block)
|
||||||
|
return <ShortcutsList {...block.shortcuts} />*/
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
container-name: sidebar;
|
container-name: sidebar;
|
||||||
container-type: inline-size;
|
container-type: inline-size;
|
||||||
|
gap: var(--Spacing-x3);
|
||||||
|
|
||||||
|
border-top: 1px solid var(--Base-Border-Subtle);
|
||||||
|
padding-top: var(--Spacing-x4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
@@ -11,8 +15,10 @@
|
|||||||
@media screen and (min-width: 1367px) {
|
@media screen and (min-width: 1367px) {
|
||||||
.aside {
|
.aside {
|
||||||
align-content: flex-start;
|
align-content: flex-start;
|
||||||
display: grid;
|
|
||||||
gap: var(--Spacing-x4);
|
gap: var(--Spacing-x4);
|
||||||
|
|
||||||
|
border-top: 0;
|
||||||
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
37
lib/graphql/Fragments/Sidebar/ContentCard.graphql
Normal file
37
lib/graphql/Fragments/Sidebar/ContentCard.graphql
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#import "../AccountPage/Ref.graphql"
|
||||||
|
#import "../ContentPage/Ref.graphql"
|
||||||
|
#import "../LoyaltyPage/Ref.graphql"
|
||||||
|
|
||||||
|
#import "../PageLink/AccountPageLink.graphql"
|
||||||
|
#import "../PageLink/ContentPageLink.graphql"
|
||||||
|
#import "../PageLink/LoyaltyPageLink.graphql"
|
||||||
|
|
||||||
|
#import "../Blocks/TeaserCard.graphql"
|
||||||
|
#import "../Blocks/Refs/TeaserCard.graphql"
|
||||||
|
|
||||||
|
fragment ContentCardSidebar_ContentPage on ContentPageSidebarContentCard {
|
||||||
|
__typename
|
||||||
|
content_card {
|
||||||
|
theme
|
||||||
|
content_cardConnection {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
__typename
|
||||||
|
...TeaserCardBlock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment ContentCardSidebar_ContentPageRefs on ContentPageSidebarContentCard {
|
||||||
|
content_card {
|
||||||
|
content_cardConnection {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
...TeaserCardBlockRef
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
lib/graphql/Fragments/Sidebar/QuickLinks.graphql
Normal file
22
lib/graphql/Fragments/Sidebar/QuickLinks.graphql
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#import "../AccountPage/Ref.graphql"
|
||||||
|
#import "../ContentPage/Ref.graphql"
|
||||||
|
#import "../LoyaltyPage/Ref.graphql"
|
||||||
|
|
||||||
|
#import "../PageLink/AccountPageLink.graphql"
|
||||||
|
#import "../PageLink/ContentPageLink.graphql"
|
||||||
|
#import "../PageLink/LoyaltyPageLink.graphql"
|
||||||
|
|
||||||
|
#import "../Blocks/Shortcuts.graphql"
|
||||||
|
|
||||||
|
fragment QuickLinksSidebar_ContentPage on ContentPageSidebarShortcuts {
|
||||||
|
__typename
|
||||||
|
shortcuts {
|
||||||
|
...Shortcuts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment QuickLinksSidebar_ContentPageRefs on ContentPageSidebarShortcuts {
|
||||||
|
shortcuts {
|
||||||
|
...ShortcutsRefs
|
||||||
|
}
|
||||||
|
}
|
||||||
37
lib/graphql/Fragments/Sidebar/ScriptedCard.graphql
Normal file
37
lib/graphql/Fragments/Sidebar/ScriptedCard.graphql
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#import "../AccountPage/Ref.graphql"
|
||||||
|
#import "../ContentPage/Ref.graphql"
|
||||||
|
#import "../LoyaltyPage/Ref.graphql"
|
||||||
|
|
||||||
|
#import "../PageLink/AccountPageLink.graphql"
|
||||||
|
#import "../PageLink/ContentPageLink.graphql"
|
||||||
|
#import "../PageLink/LoyaltyPageLink.graphql"
|
||||||
|
|
||||||
|
#import "../Blocks/Card.graphql"
|
||||||
|
#import "../Blocks/Refs/Card.graphql"
|
||||||
|
|
||||||
|
fragment ScriptedCardSidebar_ContentPage on ContentPageSidebarScriptedCard {
|
||||||
|
__typename
|
||||||
|
scripted_card {
|
||||||
|
theme
|
||||||
|
scripted_cardConnection {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
__typename
|
||||||
|
...CardBlock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment ScriptedCardSidebar_ContentPageRefs on ContentPageSidebarContentCard {
|
||||||
|
scripted_card {
|
||||||
|
scripted_cardConnection {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
...CardBlockRef
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
#import "../../Fragments/Sidebar/Content.graphql"
|
#import "../../Fragments/Sidebar/Content.graphql"
|
||||||
#import "../../Fragments/Sidebar/DynamicContent.graphql"
|
#import "../../Fragments/Sidebar/DynamicContent.graphql"
|
||||||
#import "../../Fragments/Sidebar/JoinLoyaltyContact.graphql"
|
#import "../../Fragments/Sidebar/JoinLoyaltyContact.graphql"
|
||||||
|
#import "../../Fragments/Sidebar/ContentCard.graphql"
|
||||||
|
#import "../../Fragments/Sidebar/ScriptedCard.graphql"
|
||||||
|
#import "../../Fragments/Sidebar/QuickLinks.graphql"
|
||||||
|
|
||||||
query GetContentPage($locale: String!, $uid: String!) {
|
query GetContentPage($locale: String!, $uid: String!) {
|
||||||
content_page(uid: $uid, locale: $locale) {
|
content_page(uid: $uid, locale: $locale) {
|
||||||
@@ -28,6 +31,9 @@ query GetContentPage($locale: String!, $uid: String!) {
|
|||||||
...ContentSidebar_ContentPage
|
...ContentSidebar_ContentPage
|
||||||
...DynamicContentSidebar_ContentPage
|
...DynamicContentSidebar_ContentPage
|
||||||
...JoinLoyaltyContactSidebar_ContentPage
|
...JoinLoyaltyContactSidebar_ContentPage
|
||||||
|
...ContentCardSidebar_ContentPage
|
||||||
|
...ScriptedCardSidebar_ContentPage
|
||||||
|
...QuickLinksSidebar_ContentPage
|
||||||
}
|
}
|
||||||
system {
|
system {
|
||||||
...System
|
...System
|
||||||
|
|||||||
@@ -34,11 +34,14 @@ import {
|
|||||||
contentRefsSchema as sidebarContentRefsSchema,
|
contentRefsSchema as sidebarContentRefsSchema,
|
||||||
contentSchema as sidebarContentSchema,
|
contentSchema as sidebarContentSchema,
|
||||||
} from "../schemas/sidebar/content"
|
} from "../schemas/sidebar/content"
|
||||||
|
import { contentCardsSchema } from "../schemas/sidebar/contentCard"
|
||||||
import { dynamicContentSchema as sidebarDynamicContentSchema } from "../schemas/sidebar/dynamicContent"
|
import { dynamicContentSchema as sidebarDynamicContentSchema } from "../schemas/sidebar/dynamicContent"
|
||||||
import {
|
import {
|
||||||
joinLoyaltyContactRefsSchema,
|
joinLoyaltyContactRefsSchema,
|
||||||
joinLoyaltyContactSchema,
|
joinLoyaltyContactSchema,
|
||||||
} from "../schemas/sidebar/joinLoyaltyContact"
|
} from "../schemas/sidebar/joinLoyaltyContact"
|
||||||
|
import { quickLinksSchema } from "../schemas/sidebar/quickLinks"
|
||||||
|
import { scriptedCardsSchema } from "../schemas/sidebar/scriptedCard"
|
||||||
import { systemSchema } from "../schemas/system"
|
import { systemSchema } from "../schemas/system"
|
||||||
|
|
||||||
import { ContentPageEnum } from "@/types/enums/contentPage"
|
import { ContentPageEnum } from "@/types/enums/contentPage"
|
||||||
@@ -122,10 +125,31 @@ export const contentPageJoinLoyaltyContact = z
|
|||||||
})
|
})
|
||||||
.merge(joinLoyaltyContactSchema)
|
.merge(joinLoyaltyContactSchema)
|
||||||
|
|
||||||
|
export const contentPageSidebarQuicklinks = z
|
||||||
|
.object({
|
||||||
|
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.QuickLinks),
|
||||||
|
})
|
||||||
|
.merge(quickLinksSchema)
|
||||||
|
|
||||||
|
export const contentPageSidebarContentCard = z
|
||||||
|
.object({
|
||||||
|
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ContentCard),
|
||||||
|
})
|
||||||
|
.merge(contentCardsSchema)
|
||||||
|
|
||||||
|
export const contentPageSidebarScriptedCard = z
|
||||||
|
.object({
|
||||||
|
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ScriptedCard),
|
||||||
|
})
|
||||||
|
.merge(scriptedCardsSchema)
|
||||||
|
|
||||||
export const sidebarSchema = z.discriminatedUnion("__typename", [
|
export const sidebarSchema = z.discriminatedUnion("__typename", [
|
||||||
contentPageSidebarContent,
|
contentPageSidebarContent,
|
||||||
|
contentPageSidebarContentCard,
|
||||||
contentPageSidebarDynamicContent,
|
contentPageSidebarDynamicContent,
|
||||||
contentPageJoinLoyaltyContact,
|
contentPageJoinLoyaltyContact,
|
||||||
|
contentPageSidebarScriptedCard,
|
||||||
|
contentPageSidebarQuicklinks,
|
||||||
])
|
])
|
||||||
|
|
||||||
const navigationLinksSchema = z
|
const navigationLinksSchema = z
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
|
|
||||||
import { ContentEnum } from "@/types/enums/content"
|
import { ContentEnum } from "@/types/enums/content"
|
||||||
import { SidebarEnums } from "@/types/enums/sidebar"
|
import { SidebarEnums } from "@/types/enums/sidebar"
|
||||||
import { System } from "@/types/requests/system"
|
|
||||||
|
|
||||||
export const contentSchema = z.object({
|
export const contentSchema = z.object({
|
||||||
typename: z
|
typename: z
|
||||||
|
|||||||
45
server/routers/contentstack/schemas/sidebar/contentCard.ts
Normal file
45
server/routers/contentstack/schemas/sidebar/contentCard.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import {
|
||||||
|
teaserCardBlockRefsSchema,
|
||||||
|
teaserCardBlockSchema,
|
||||||
|
transformTeaserCardBlock,
|
||||||
|
} from "../blocks/cardsGrid"
|
||||||
|
|
||||||
|
import { SidebarEnums } from "@/types/enums/sidebar"
|
||||||
|
|
||||||
|
export const contentCardsSchema = z.object({
|
||||||
|
typename: z
|
||||||
|
.literal(SidebarEnums.blocks.ContentCard)
|
||||||
|
.optional()
|
||||||
|
.default(SidebarEnums.blocks.ContentCard),
|
||||||
|
content_card: z
|
||||||
|
.object({
|
||||||
|
theme: z.enum(["gray", "white"]).nullable().default("gray"),
|
||||||
|
content_cardConnection: z.object({
|
||||||
|
edges: z.array(
|
||||||
|
z.object({
|
||||||
|
node: teaserCardBlockSchema,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.transform((data) => {
|
||||||
|
return {
|
||||||
|
...transformTeaserCardBlock(data.content_cardConnection.edges[0].node),
|
||||||
|
theme: data.theme,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const contentCardRefschema = z.object({
|
||||||
|
content_card: z.object({
|
||||||
|
content_cardConnection: z.object({
|
||||||
|
edges: z.array(
|
||||||
|
z.object({
|
||||||
|
node: teaserCardBlockRefsSchema,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
18
server/routers/contentstack/schemas/sidebar/quickLinks.ts
Normal file
18
server/routers/contentstack/schemas/sidebar/quickLinks.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import { shortcutsRefsSchema, shortcutsSchema } from "../blocks/shortcuts"
|
||||||
|
|
||||||
|
import { SidebarEnums } from "@/types/enums/sidebar"
|
||||||
|
|
||||||
|
export const quickLinksSchema = z
|
||||||
|
.object({
|
||||||
|
typename: z
|
||||||
|
.literal(SidebarEnums.blocks.Shortcuts)
|
||||||
|
.optional()
|
||||||
|
.default(SidebarEnums.blocks.Shortcuts),
|
||||||
|
})
|
||||||
|
.merge(shortcutsSchema)
|
||||||
|
|
||||||
|
export const quickLinksSRefschema = z.object({
|
||||||
|
shortcutsRefsSchema,
|
||||||
|
})
|
||||||
55
server/routers/contentstack/schemas/sidebar/scriptedCard.ts
Normal file
55
server/routers/contentstack/schemas/sidebar/scriptedCard.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import {
|
||||||
|
cardBlockRefsSchema,
|
||||||
|
cardBlockSchema,
|
||||||
|
transformCardBlock,
|
||||||
|
} from "../blocks/cardsGrid"
|
||||||
|
|
||||||
|
import { SidebarEnums } from "@/types/enums/sidebar"
|
||||||
|
|
||||||
|
export const scriptedCardsSchema = z.object({
|
||||||
|
typename: z
|
||||||
|
.literal(SidebarEnums.blocks.ScriptedCard)
|
||||||
|
.optional()
|
||||||
|
.default(SidebarEnums.blocks.ScriptedCard),
|
||||||
|
scripted_card: z
|
||||||
|
.object({
|
||||||
|
theme: z
|
||||||
|
.enum([
|
||||||
|
"one",
|
||||||
|
"two",
|
||||||
|
"three",
|
||||||
|
"primaryDim",
|
||||||
|
"primaryDark",
|
||||||
|
"primaryInverted",
|
||||||
|
"primaryStrong",
|
||||||
|
])
|
||||||
|
.nullable(),
|
||||||
|
scripted_cardConnection: z.object({
|
||||||
|
edges: z.array(
|
||||||
|
z.object({
|
||||||
|
node: cardBlockSchema,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.transform((data) => {
|
||||||
|
return {
|
||||||
|
theme: data.theme,
|
||||||
|
...transformCardBlock(data.scripted_cardConnection.edges[0].node),
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const scriptedCardRefschema = z.object({
|
||||||
|
cripted_card: z.object({
|
||||||
|
scripted_cardConnection: z.object({
|
||||||
|
edges: z.array(
|
||||||
|
z.object({
|
||||||
|
node: cardBlockRefsSchema,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
@@ -13,8 +13,11 @@ export namespace ContentPageEnum {
|
|||||||
|
|
||||||
export const enum sidebar {
|
export const enum sidebar {
|
||||||
Content = "ContentPageSidebarContent",
|
Content = "ContentPageSidebarContent",
|
||||||
|
ContentCard = "ContentPageSidebarContentCard",
|
||||||
DynamicContent = "ContentPageSidebarDynamicContent",
|
DynamicContent = "ContentPageSidebarDynamicContent",
|
||||||
JoinLoyaltyContact = "ContentPageSidebarJoinLoyaltyContact",
|
JoinLoyaltyContact = "ContentPageSidebarJoinLoyaltyContact",
|
||||||
|
ScriptedCard = "ContentPageSidebarScriptedCard",
|
||||||
|
QuickLinks = "ContentPageSidebarShortcuts",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
export namespace SidebarEnums {
|
export namespace SidebarEnums {
|
||||||
export const enum blocks {
|
export const enum blocks {
|
||||||
Content = "Content",
|
Content = "Content",
|
||||||
|
ContentCard = "ContentCard",
|
||||||
DynamicContent = "DynamicContent",
|
DynamicContent = "DynamicContent",
|
||||||
JoinLoyaltyContact = "JoinLoyaltyContact",
|
JoinLoyaltyContact = "JoinLoyaltyContact",
|
||||||
|
ScriptedCard = "ScriptedCard",
|
||||||
|
Shortcuts = "Shortcuts",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user