From 69e3a7cac7e785993afec1672f59ffd2e7b2a804 Mon Sep 17 00:00:00 2001 From: HagerDakroury Date: Mon, 22 Apr 2024 15:57:04 +0200 Subject: [PATCH] feat(SLB-314): style CTA block --- .../src/fragments/PageContent/BlockCta.gql | 2 + packages/schema/src/schema.graphql | 7 ++++ .../Organisms/PageContent/BlockCta.stories.ts | 37 +++++++++++++++++++ .../Organisms/PageContent/BlockCta.tsx | 36 ++++++++++++++++-- 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 packages/ui/src/components/Organisms/PageContent/BlockCta.stories.ts diff --git a/packages/schema/src/fragments/PageContent/BlockCta.gql b/packages/schema/src/fragments/PageContent/BlockCta.gql index 2dae0fda2..958d9e283 100644 --- a/packages/schema/src/fragments/PageContent/BlockCta.gql +++ b/packages/schema/src/fragments/PageContent/BlockCta.gql @@ -2,4 +2,6 @@ fragment BlockCta on BlockCta { url text openInNewTab + displayIcon + iconPosition } diff --git a/packages/schema/src/schema.graphql b/packages/schema/src/schema.graphql index 9300972cb..62357ed6f 100644 --- a/packages/schema/src/schema.graphql +++ b/packages/schema/src/schema.graphql @@ -73,6 +73,11 @@ enum Locale @default @value(string: "en") { de } +enum VerticalPosition { + Right + Left +} + """ Inteface for anything that can appear in the content hub. """ @@ -242,6 +247,8 @@ type BlockCta @type(id: "custom/cta") { url: Url @resolveEditorBlockAttribute(key: "url") text: String @resolveEditorBlockAttribute(key: "text") openInNewTab: Boolean @resolveEditorBlockAttribute(key: "openInNewTab") + displayIcon: Boolean + iconPosition: VerticalPosition } input PaginationInput { diff --git a/packages/ui/src/components/Organisms/PageContent/BlockCta.stories.ts b/packages/ui/src/components/Organisms/PageContent/BlockCta.stories.ts new file mode 100644 index 000000000..7c6dc1566 --- /dev/null +++ b/packages/ui/src/components/Organisms/PageContent/BlockCta.stories.ts @@ -0,0 +1,37 @@ +import { Url, VerticalPosition } from '@custom/schema'; +import { Meta, StoryObj } from '@storybook/react'; + +import { BlockCta } from './BlockCta'; + +export default { + component: BlockCta, +} satisfies Meta; + +export const BlockCtaDefault = { + args: { + text: 'Support center', + url: 'https://example.com' as Url, + openInNewTab: false, + displayIcon: true, + iconPosition: VerticalPosition.Right, + }, +} satisfies StoryObj; + +export const BlockCtaStoryIconLeft = { + args: { + text: 'Support center', + url: 'https://example.com' as Url, + openInNewTab: false, + displayIcon: true, + iconPosition: VerticalPosition.Left, + }, +} satisfies StoryObj; + +export const BlockCtaStoryNoIcon = { + args: { + text: 'Support center', + url: 'https://example.com' as Url, + openInNewTab: false, + displayIcon: false, + }, +} satisfies StoryObj; diff --git a/packages/ui/src/components/Organisms/PageContent/BlockCta.tsx b/packages/ui/src/components/Organisms/PageContent/BlockCta.tsx index a652f30b5..a0e5aa82d 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockCta.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockCta.tsx @@ -1,7 +1,37 @@ -import { BlockCtaFragment } from '@custom/schema'; +import { BlockCtaFragment, VerticalPosition } from '@custom/schema'; +import clsx from 'clsx'; import React from 'react'; export function BlockCta(props: BlockCtaFragment) { - console.log(props); - return
; + return ( + + {props.text} + {!!props.displayIcon && } + + ); } + +const ArrowRightIcon = () => ( + + + +);