|
| 1 | +import EmailIndicatorIcon from '../../../assets/icons/kg-indicator-email.svg?react'; |
| 2 | +import React from 'react'; |
| 3 | +import populateEditor from '../../../utils/storybook/populate-storybook-editor.js'; |
| 4 | +import {BASIC_NODES} from '../../../index.js'; |
| 5 | +import {CardWrapper} from './../CardWrapper'; |
| 6 | +import {CtaCard} from './CtaCard'; |
| 7 | +import {createEditor} from 'lexical'; |
| 8 | + |
| 9 | +const displayOptions = { |
| 10 | + Default: {isSelected: false, isEditing: false}, |
| 11 | + Selected: {isSelected: true, isEditing: false}, |
| 12 | + Editing: {isSelected: true, isEditing: true} |
| 13 | +}; |
| 14 | + |
| 15 | +const story = { |
| 16 | + title: 'Primary cards/CTA card', |
| 17 | + component: CtaCard, |
| 18 | + subcomponent: {CardWrapper}, |
| 19 | + argTypes: { |
| 20 | + display: { |
| 21 | + options: Object.keys(displayOptions), |
| 22 | + mapping: displayOptions, |
| 23 | + control: { |
| 24 | + type: 'radio', |
| 25 | + labels: { |
| 26 | + Default: 'Default', |
| 27 | + Selected: 'Selected', |
| 28 | + Editing: 'Editing' |
| 29 | + }, |
| 30 | + defaultValue: displayOptions.Default |
| 31 | + } |
| 32 | + } |
| 33 | + }, |
| 34 | + parameters: { |
| 35 | + status: { |
| 36 | + type: 'uiReady' |
| 37 | + } |
| 38 | + } |
| 39 | +}; |
| 40 | +export default story; |
| 41 | + |
| 42 | +const Template = ({display, value, ...args}) => { |
| 43 | + const htmlEditor = createEditor({nodes: BASIC_NODES}); |
| 44 | + populateEditor({editor: htmlEditor, initialHtml: `${value}`}); |
| 45 | + return ( |
| 46 | + <div> |
| 47 | + <div className="kg-prose"> |
| 48 | + <div className="mx-auto my-8 min-w-[initial] max-w-[740px]"> |
| 49 | + <CardWrapper IndicatorIcon={EmailIndicatorIcon} wrapperStyle='wide' {...display} {...args}> |
| 50 | + <CtaCard {...display} {...args} htmlEditor={htmlEditor} /> |
| 51 | + </CardWrapper> |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + <div className="kg-prose dark bg-black px-4 py-8"> |
| 55 | + <div className="mx-auto my-8 min-w-[initial] max-w-[740px]"> |
| 56 | + <CardWrapper IndicatorIcon={EmailIndicatorIcon} wrapperStyle='wide' {...display} {...args}> |
| 57 | + <CtaCard {...display} {...args} htmlEditor={htmlEditor} /> |
| 58 | + </CardWrapper> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + ); |
| 63 | +}; |
| 64 | + |
| 65 | +export const Empty = Template.bind({}); |
| 66 | +Empty.args = { |
| 67 | + display: 'Editing', |
| 68 | + value: '', |
| 69 | + showButton: false, |
| 70 | + buttonText: '', |
| 71 | + buttonUrl: '', |
| 72 | + suggestedUrls: [] |
| 73 | +}; |
| 74 | + |
| 75 | +export const Populated = Template.bind({}); |
| 76 | +Populated.args = { |
| 77 | + display: 'Editing', |
| 78 | + value: 'Want to get access to premium content?', |
| 79 | + showButton: true, |
| 80 | + buttonText: 'Upgrade', |
| 81 | + buttonUrl: 'https://ghost.org/', |
| 82 | + suggestedUrls: [{label: 'Homepage', value: 'https://localhost.org/'}] |
| 83 | +}; |
| 84 | + |
0 commit comments