Skip to content

Commit

Permalink
feat(card-in-card): update to sb8
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioBecerra committed Apr 25, 2024
1 parent bec02d2 commit dad9467
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 57 deletions.
11 changes: 11 additions & 0 deletions packages/web-components/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,19 @@ const stories = glob.sync(
// '../docs/**/*.mdx',
// '../src/**/*.mdx',
// '../src/**/*.stories.@(js|jsx|ts|tsx)',
// '../src/**/back-to-top.mdx',
// '../src/**/back-to-top.stories.ts',
'../src/**/button.mdx',
'../src/**/button.stories.ts',
'../src/**/button-group.mdx',
'../src/**/button-group.stories.ts',
'../src/**/card.mdx',
'../src/**/card.stories.ts',
'../src/**/carousel.mdx',
'../src/**/carousel.stories.ts',
'../src/**/card-in-card.mdx',
'../src/**/card-in-card.stories.ts',

],
{
ignore: ['../src/**/docs/*.mdx'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {
Preview,
Props,
Description,
Story,
} from '@storybook/addon-docs/blocks';
import { ArgTypes, Markdown, Meta } from '@storybook/blocks';
import contributing from '../../../../../../docs/contributing-license.md?raw';
import { cdnJs, cdnCss } from '../../../globals/internal/storybook-cdn';
import * as CardInCard from './card-in-card.stories';

<Meta of={CardInCard} />

# Card in Card

Expand Down Expand Up @@ -96,7 +94,7 @@ attribute to `card-in-card`.

## Props

<Props of="c4d-card-in-card" />
<ArgTypes of="c4d-card-in-card" />

## Stable selectors

Expand All @@ -108,4 +106,4 @@ to see how Web Components selector and `data-autoid` should be used.
| ----------------------- | --------------------------------- | ----------- |
| `<c4d-card-in-card>` | `data-autoid="c4d--card-in-card"` | Component |

<Description markdown={contributing} />
<Markdown>{contributing}</Markdown>
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,57 @@ import '../../cta/card-cta-footer';
import '../../cta/video-cta-container';
import { html } from 'lit';
import { ifDefined } from 'lit/directives/if-defined.js';
import { boolean } from '@storybook/addon-knobs';

import imgXlg16x9 from '../../../../.storybook/storybook-images/assets/1312/fpo--16x9--1312x738--005.jpg';
import imgMd16x9 from '../../../../.storybook/storybook-images/assets/960/fpo--16x9--960x540--005.jpg';
import imgSm4x3 from '../../../../.storybook/storybook-images/assets/480/fpo--4x3--480x360--005.jpg';

import readme from './README.stories.mdx';
import textNullable from '../../../../.storybook/knob-text-nullable';
const defaultArgs = {
video: false,
alt: 'Image alt text',
defaultSrc: imgSm4x3,
heading: 'Standard Bank Group prepares to embrace Africa’s AI opportunity',
href: 'https://example.com',
eyebrow: 'Label'
};

const controls = {
video: {
control: 'boolean',
description: 'Video'
},
alt: {
control: 'text',
description: 'Image alt text (alt)',
if: { arg: 'video', eq: false }
},
defaultSrc: {
control: 'text',
description: 'Image src (defaultSrc)',
if: { arg: 'video', eq: false }
},
heading: {
control: 'text',
description: 'Card Heading (heading)',
if: { arg: 'video', eq: false }
},
href: {
control: 'text',
description: 'Card Href (href)',
if: { arg: 'video', eq: false }
},
eyebrow: {
control: 'text',
description: 'Card Eyebrow (eyebrow)'
}
};


export const Default = {
args: defaultArgs,
argTypes: controls,
render: ( {video, eyebrow, heading, defaultSrc, alt, href }) => {

export const Default = (args) => {
const { video, eyebrow, heading, defaultSrc, alt, href } =
args?.['c4d-card-in-card'] ?? {};
if (video) {
const card = document.querySelector('c4d-card') as any;
const videoCopy = card?.videoTitle;
Expand Down Expand Up @@ -58,7 +97,8 @@ export const Default = (args) => {
<c4d-card-footer></c4d-card-footer>
</c4d-card-in-card>
`;
};
}
}

export default {
title: 'Components/Card in card',
Expand All @@ -72,48 +112,9 @@ export default {
`,
],
parameters: {
...readme.parameters,
hasStoryPadding: true,
knobs: {
'c4d-card-in-card': () => {
const video = boolean('video', false);
const alt = video
? undefined
: textNullable('Image alt text (alt):', 'Image alt text');
const defaultSrc = video
? undefined
: textNullable('Image src (defaultSrc):', imgSm4x3);
const heading = video
? undefined
: textNullable(
'Card Heading (heading):',
'Standard Bank Group prepares to embrace Africa’s AI opportunity'
);
const href = video
? undefined
: textNullable('Card Href (href):', 'https://example.com');
return {
video,
alt,
defaultSrc,
heading,
href,
eyebrow: textNullable('Card Eyebrow (eyebrow):', 'Label'),
};
},
},
propsSet: {
default: {
'c4d-card-in-card': {
video: false,
alt: 'Image alt text',
defaultSrc: imgSm4x3,
heading:
'Standard Bank Group prepares to embrace Africa’s AI opportunity',
href: 'https://example.com',
eyebrow: 'Label',
},
},
},
controls: {
exclude:/defaultSrc|eyebrow|heading|href|copy|alt/g
}
},
};

0 comments on commit dad9467

Please sign in to comment.