Back to Storybook

List Story Unchecked

docs/_snippets/list-story-unchecked.md

10.3.68.6 KB
Original Source
ts
import { type Meta, type StoryObj, moduleMetadata } from '@storybook/angular';

import { CommonModule } from '@angular/common';

import { List } from './list.component';
import { ListItem } from './list-item.component';

//๐Ÿ‘‡ Imports a specific story from ListItem stories
import { Unchecked } from './ListItem.stories';

const meta: Meta<List> = {
  component: List,
  decorators: [
    moduleMetadata({
      declarations: [List, ListItem],
      imports: [CommonModule],
    }),
  ],
};

export default meta;
type Story = StoryObj<List>;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const OneItem: Story = {
  render: (args) => ({
    props: args,
    template: `
      <app-list>
        <app-list-item [item]="item"></app-list-item>
      </app-list>
   `,
  }),
  args: {
    ...Unchecked.args,
  },
};
ts
import { CommonModule } from '@angular/common';

import { moduleMetadata } from '@storybook/angular';

import preview from '../.storybook/preview';

import { List } from './list.component';
import { ListItem } from './list-item.component';

//๐Ÿ‘‡ Imports a specific story from ListItem stories
import { Unchecked } from './ListItem.stories';

const meta = preview.meta({
  component: List,
  decorators: [
    moduleMetadata({
      declarations: [List, ListItem],
      imports: [CommonModule],
    }),
  ],
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const OneItem = meta.story({
  render: (args) => ({
    props: args,
    template: `
      <app-list>
        <app-list-item [item]="item"></app-list-item>
      </app-list>
   `,
  }),
  args: {
    ...Unchecked.input.args,
  },
});
jsx
import { List } from './List';

//๐Ÿ‘‡ Instead of importing ListItem, we import the stories
import { Unchecked } from './ListItem.stories';

export default {
  component: List,
};

export const OneItem = {
  render: (args) => (
    <List {...args}>
      <Unchecked {...Unchecked.args} />
    </List>
  ),
};
tsx
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
import type { Meta, StoryObj } from '@storybook/your-framework';

import { List } from './List';

//๐Ÿ‘‡ Instead of importing ListItem, we import the stories
import { Unchecked } from './ListItem.stories';

export const meta = {
  component: List,
} satisfies Meta<typeof List>;

export default meta;
type Story = StoryObj<typeof meta>;

export const OneItem: Story = {
  render: (args) => (
    <List {...args}>
      <Unchecked {...Unchecked.args} />
    </List>
  ),
};
jsx
import { List } from './List';

//๐Ÿ‘‡ Instead of importing ListItem, we import the stories
import { Unchecked } from './ListItem.stories';

export default {
  component: List,
};

export const OneItem = {
  render: (args) => (
    <List {...args}>
      <Unchecked {...Unchecked.args} />
    </List>
  ),
};
tsx
import type { Meta, StoryObj } from 'storybook-solidjs-vite';

import { List } from './List';

//๐Ÿ‘‡ Instead of importing ListItem, we import the stories
import { Unchecked } from './ListItem.stories';

export const meta = {
  component: List,
} satisfies Meta<typeof List>;

export default meta;
type Story = StoryObj<typeof meta>;

export const OneItem: Story = {
  render: (args) => (
    <List {...args}>
      <Unchecked {...Unchecked.args} />
    </List>
  ),
};
js
import List from './List.vue';
import ListItem from './ListItem.vue';

//๐Ÿ‘‡ Imports a specific story from ListItem stories
import { Unchecked } from './ListItem.stories';

export default {
  component: List,
};

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const OneItem = {
  args: {
    ...Unchecked.args,
  },
  render: (args) => ({
    components: { List, ListItem },
    setup() {
      //๐Ÿ‘‡ The args will now be passed down to the template
      return { args };
    },
    template: '<List v-bind="args"><ListItem v-bind="args"/></List>',
  }),
};
ts
import type { Meta, StoryObj } from '@storybook/vue3-vite';

import List from './List.vue';
import ListItem from './ListItem.vue';

//๐Ÿ‘‡ Imports a specific story from ListItem stories
import { Unchecked } from './ListItem.stories';

const meta = {
  component: List,
} satisfies Meta<typeof List>;

export default meta;
type Story = StoryObj<typeof meta>;

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const OneItem: Story = {
  render: (args) => ({
    components: { List, ListItem },
    setup() {
      //๐Ÿ‘‡ The args will now be passed down to the template
      return { args };
    },
    template: '<List v-bind="args"><ListItem v-bind="args"/></List>',
  }),
  args: {
    ...Unchecked.args,
  },
};
ts
import preview from '../.storybook/preview';

import List from './List.vue';
import ListItem from './ListItem.vue';

//๐Ÿ‘‡ Imports a specific story from ListItem stories
import { Unchecked } from './ListItem.stories';

const meta = preview.meta({
  component: List,
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const OneItem = meta.story({
  render: (args) => ({
    components: { List, ListItem },
    setup() {
      //๐Ÿ‘‡ The args will now be passed down to the template
      return { args };
    },
    template: '<List v-bind="args"><ListItem v-bind="args"/></List>',
  }),
  args: {
    ...Unchecked.input.args,
  },
});
<!-- JS snippets still needed while providing both CSF 3 & Next -->
js
import preview from '../.storybook/preview';

import List from './List.vue';
import ListItem from './ListItem.vue';

//๐Ÿ‘‡ Imports a specific story from ListItem stories
import { Unchecked } from './ListItem.stories';

const meta = preview.meta({
  component: List,
});

/*
 *๐Ÿ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
 * See https://storybook.js.org/docs/api/csf
 * to learn how to use render functions.
 */
export const OneItem = meta.story({
  render: (args) => ({
    components: { List, ListItem },
    setup() {
      //๐Ÿ‘‡ The args will now be passed down to the template
      return { args };
    },
    template: '<List v-bind="args"><ListItem v-bind="args"/></List>',
  }),
  args: {
    ...Unchecked.input.args,
  },
});
tsx
import preview from '../.storybook/preview';

import { List } from './List';

//๐Ÿ‘‡ Instead of importing ListItem, we import the stories
import { Unchecked } from './ListItem.stories';

const meta = preview.meta({
  component: List,
});

export const OneItem = meta.story({
  render: (args) => (
    <List {...args}>
      <Unchecked {...Unchecked.input.args} />
    </List>
  ),
});
<!-- JS snippets still needed while providing both CSF 3 & Next -->
jsx
import preview from '../.storybook/preview';

import { List } from './List';

//๐Ÿ‘‡ Instead of importing ListItem, we import the stories
import { Unchecked } from './ListItem.stories';

const meta = preview.meta({
  component: List,
});

export const OneItem = meta.story({
  render: (args) => (
    <List {...args}>
      <Unchecked {...Unchecked.input.args} />
    </List>
  ),
});