From bd16bfd39d22c4a4b545a987747d008c267e1bbe Mon Sep 17 00:00:00 2001 From: Sanne de Vries Date: Mon, 17 Feb 2025 11:41:06 +0100 Subject: [PATCH] Fixed call-to-action card in storybook Ref https://linear.app/ghost/issue/PLG-351/standardise-naming-convention-for-call-to-action-components - Import was broken due to file name change - Editable sponsor label broke the call-to-action card in storybook --- .../ui/cards/CallToActionCard.stories.jsx | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/packages/koenig-lexical/src/components/ui/cards/CallToActionCard.stories.jsx b/packages/koenig-lexical/src/components/ui/cards/CallToActionCard.stories.jsx index 6f75519c5..d65774f7b 100644 --- a/packages/koenig-lexical/src/components/ui/cards/CallToActionCard.stories.jsx +++ b/packages/koenig-lexical/src/components/ui/cards/CallToActionCard.stories.jsx @@ -2,8 +2,8 @@ import React from 'react'; import VisibilityIndicatorIcon from '../../../assets/icons/kg-indicator-visibility.svg?react'; import populateEditor from '../../../utils/storybook/populate-storybook-editor.js'; import {BASIC_NODES} from '../../../index.js'; -import {CardWrapper} from '../CardWrapper.jsx'; -import {CtaCard} from './CtaCard'; +import {CallToActionCard} from './CallToActionCard'; +import {CardWrapper} from '../CardWrapper'; import {createEditor} from 'lexical'; const displayOptions = { @@ -18,8 +18,8 @@ const layoutOptions = { }; const story = { - title: 'Primary cards/CTA card', - component: CtaCard, + title: 'Primary cards/Call to Action card', + component: CallToActionCard, subcomponent: {CardWrapper}, argTypes: { display: { @@ -56,37 +56,42 @@ const story = { export default story; const Template = ({display, value, ...args}) => { + // Main editor setup const htmlEditor = createEditor({nodes: BASIC_NODES}); populateEditor({editor: htmlEditor, initialHtml: `${value}`}); + + // Sponsor label editor setup + let sponsorLabelHtmlEditor = null; + let sponsorLabelHtmlEditorInitialState = null; + + if (args.hasSponsorLabel) { + sponsorLabelHtmlEditor = createEditor({nodes: BASIC_NODES}); + sponsorLabelHtmlEditorInitialState = populateEditor({ + editor: sponsorLabelHtmlEditor, + initialHtml: 'Sponsored' + }); + } + return ( -
-
-
- - - -
+
+
+ + +
- {/*
-
- - - -
-
*/}
); };