Skip to content

Commit

Permalink
Merge pull request #1 from storybookjs/docs-of-demo
Browse files Browse the repository at this point in the history
Demonstration of Docs
  • Loading branch information
JReinhold authored May 13, 2024
2 parents 882d3c3 + 23c7b0b commit fd939b4
Show file tree
Hide file tree
Showing 12 changed files with 370 additions and 31 deletions.
23 changes: 23 additions & 0 deletions .storybook/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
* {
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Open Sans',
'Helvetica Neue',
sans-serif;
}

pre,
code,
kbd,
samp {
font-family: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro',
'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
}
1 change: 1 addition & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Preview } from '@storybook/svelte';
import './global.css';

const preview: Preview = {
parameters: {
Expand Down
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ With this we're hoping to gain insights into how the features map to this altern

These are the following Storybook features we attempt to uncover in this project and their current conclusion:

| Status | Feature | Summary | Links |
| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----- |
|| [`title`](https://storybook.js.org/docs/writing-stories/naming-components-and-hierarchy#naming-stories) | | |
|| [`name`](https://storybook.js.org/docs/writing-stories#rename-stories) | | |
|| `component` | | |
|| [`subcomponents`](https://storybook.js.org/docs/writing-stories/stories-for-multiple-components) | | |
|| [`argTypes`](https://storybook.js.org/docs/api/arg-types#argtypes) | | |
|| [`args`](https://storybook.js.org/docs/writing-stories/args) | | |
|| [`parameters`](https://storybook.js.org/docs/writing-stories/parameters) | | |
|| [`beforeEach`](https://storybook.js.org/docs/8.1/writing-stories/mocking-modules#using-mocked-modules-in-stories) (not implemented yet in Svelte CSF AFAIK) | | |
|| [`loaders`](https://storybook.js.org/docs/writing-stories/loaders) | | |
|| [`decorators`](https://storybook.js.org/docs/writing-stories/decorators) | | |
|| [`render`](https://storybook.js.org/docs/api/csf#custom-render-functions) | | |
|| [`play`](https://storybook.js.org/docs/writing-stories/play-function) | | |
|| [How to type the meta object and stories](https://storybook.js.org/docs/writing-stories/typescript) | | |
|| [JSDoc comments as descriptions](https://storybook.js.org/docs/api/doc-block-description#writing-descriptions) (from component, meta and stories) | | |
| | [MDX docs](https://storybook.js.org/docs/writing-docs/mdx) including stories with the `of` prop | | |
|| [Non-story exports](https://storybook.js.org/docs/api/csf#non-story-exports) | | |
| Status | Feature | Links |
| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --- |
|| [`title`](https://storybook.js.org/docs/writing-stories/naming-components-and-hierarchy#naming-stories) | | |
|| [`name`](https://storybook.js.org/docs/writing-stories#rename-stories) | | |
|| `component` | | |
|| [`subcomponents`](https://storybook.js.org/docs/writing-stories/stories-for-multiple-components) | | |
|| [`argTypes`](https://storybook.js.org/docs/api/arg-types#argtypes) | | |
|| [`args`](https://storybook.js.org/docs/writing-stories/args) | | |
|| [`parameters`](https://storybook.js.org/docs/writing-stories/parameters) | | |
|| [`beforeEach`](https://storybook.js.org/docs/8.1/writing-stories/mocking-modules#using-mocked-modules-in-stories) (not implemented yet in Svelte CSF AFAIK) | | |
|| [`loaders`](https://storybook.js.org/docs/writing-stories/loaders) | | |
|| [`decorators`](https://storybook.js.org/docs/writing-stories/decorators) | | |
|| [`render`](https://storybook.js.org/docs/api/csf#custom-render-functions) | | |
|| [`play`](https://storybook.js.org/docs/writing-stories/play-function) | | |
|| [How to type the meta object and stories](https://storybook.js.org/docs/writing-stories/typescript) | | |
|| [JSDoc comments as descriptions](https://storybook.js.org/docs/api/doc-block-description#writing-descriptions) (from component, meta and stories) | | |
| 🟡 | [Docs](https://storybook.js.org/docs/writing-docs/mdx), including autodocs, MDX docs and `useOf` | [PR](https://github.com/storybookjs/svelte-csf-demo/pull/1), [stories](https://main--663faba8e103e55dccd640dc.chromatic.com/?path=/docs/docs) |
|| [Non-story exports](https://storybook.js.org/docs/api/csf#non-story-exports) | | |

- ⏳: No demo yet
- ✅: Demoed, no problems
Expand All @@ -49,6 +49,8 @@ A few guide lines:
2. **Don't ask to be assigned a feature**. There's no need to be assigned a feature or to reserve it. If you want to contribute, just ask questions, open issues or pull requests. History shows that contributors being assigned to tasks often don't finish them, but still blocks other contributors from picking them up.
3. **Be explicit in the demo's intend**. Eg. if you're building a demo for `argTypes`, don't create a `Button.svelte` component and `Button.stories.svelte` stories and come up with examples for how to write `argTypes` for buttons. Instead, build an `ArgTypes.svelte` component and stories that clearly and _only_ demonstrates `argTypes`.

See (PR #1)[https://github.com/storybookjs/svelte-csf-demo/pull/1] for an example of all of this.

### Prerequiristes

- Node.js version >=18.20.2
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"chromatic": "^11.3.2",
"http-serve": "^1.0.1",
"prettier": "^3.2.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"storybook": "^8.1.0-beta.0",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions src/Empty.stories.svelte

This file was deleted.

118 changes: 118 additions & 0 deletions src/docs/AttachedToRegularCSF.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import {
Meta,
Story,
Canvas,
Primary,
Title,
Stories,
Description,
Controls,
ArgTypes,
useOf,
} from '@storybook/blocks';
import * as RegularStories from './Docs.stories.ts';
import { NoArgs, TrueArgs, FalseArgs } from './Docs.stories.ts';
import { UseOf } from './UseOf.tsx';
import DocsComponent from './DocsComponent.svelte';

<Meta of={RegularStories} name='Attached to Regular CSF' />

# Attached to Regular CSF stories

## Story Doc Block

### `<Story of={RegularStories.NoArgs} />`

<Story of={RegularStories.NoArgs} />

### `<Story of={TrueArgs} />`

<Story of={TrueArgs} />

## `<Story />`

<Story />

## Canvas Doc Block

### `<Canvas of={RegularStories.NoArgs} />`

<Canvas of={RegularStories.NoArgs} />

### `<Canvas of={TrueArgs} />`

<Canvas of={TrueArgs} />

### `<Canvas of={FalseArgs} />`

<Canvas of={FalseArgs} />

## `<Primary />`

<Primary />

## `<Controls of={RegularStories.NoArgs} />`

<Controls of={RegularStories.NoArgs} />

## `<ArgTypes of={RegularStories.NoArgs} />`

<ArgTypes of={RegularStories.NoArgs} />

## Description Doc Block

### `<Description of={RegularStories.NoArgs} />`

<Description of={RegularStories.NoArgs} />

### `<Description of={RegularStories} />`

<Description of={RegularStories} />

## `<Stories />`

<Stories />

## `useOf` hook

### `useOf(RegularStories)`

The CSF file:

<UseOf of={RegularStories} />

### `useOf(RegularStories.default)`

The meta:

<UseOf of={RegularStories.default} />

### `useOf(TrueArgs)`

A story:

<UseOf of={TrueArgs} />

### `useOf(DocsComponent)`

The Svelte component:

<UseOf of={DocsComponent} />

### `useOf("meta")`

The meta of the attached stories:

<UseOf of='meta' />

### `useOf("story")`

The primary story of the attached stories:

<UseOf of='story' />

### `useOf("component")`

The component of the attached stories:

<UseOf of='component' />
118 changes: 118 additions & 0 deletions src/docs/AttachedToSvelteCSF.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import {
Meta,
Story,
Canvas,
Primary,
Title,
Stories,
Description,
Controls,
ArgTypes,
useOf,
} from '@storybook/blocks';
import * as SvelteStories from './Docs.stories.svelte';
import { NoArgs, TrueArgs, FalseArgs } from './Docs.stories.svelte';
import { UseOf } from './UseOf.tsx';
import DocsComponent from './DocsComponent.svelte';

<Meta of={SvelteStories} name='Attached to Svelte CSF' />

# Attached to Regular CSF stories

## Story Doc Block

### `<Story of={SvelteStories.NoArgs} />`

<Story of={SvelteStories.NoArgs} />

### `<Story of={TrueArgs} />`

<Story of={TrueArgs} />

## `<Story />`

<Story />

## Canvas Doc Block

### `<Canvas of={SvelteStories.NoArgs} />`

<Canvas of={SvelteStories.NoArgs} />

### `<Canvas of={TrueArgs} />`

<Canvas of={TrueArgs} />

### `<Canvas of={FalseArgs} />`

<Canvas of={FalseArgs} />

## `<Primary />`

<Primary />

## `<Controls of={SvelteStories.NoArgs} />`

<Controls of={SvelteStories.NoArgs} />

## `<ArgTypes of={SvelteStories.NoArgs} />`

<ArgTypes of={SvelteStories.NoArgs} />

## Description Doc Block

### `<Description of={SvelteStories.NoArgs} />`

<Description of={SvelteStories.NoArgs} />

### `<Description of={SvelteStories} />`

<Description of={SvelteStories} />

## `<Stories />`

<Stories />

## `useOf` hook

### `useOf(SvelteStories)`

The CSF file:

<UseOf of={SvelteStories} />

### `useOf(SvelteStories.default)`

The meta:

<UseOf of={SvelteStories.default} />

### `useOf(TrueArgs)`

A story:

<UseOf of={TrueArgs} />

### `useOf(DocsComponent)`

The Svelte component:

<UseOf of={DocsComponent} />

### `useOf("meta")`

The meta of the attached stories:

<UseOf of='meta' />

### `useOf("story")`

The primary story of the attached stories:

<UseOf of='story' />

### `useOf("component")`

The component of the attached stories:

<UseOf of='component' />
25 changes: 25 additions & 0 deletions src/docs/Docs.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script lang="ts" context="module">
import DocsComponent from './DocsComponent.svelte';
import type { Meta } from '@storybook/svelte';
import { Story, Template } from '@storybook/addon-svelte-csf';
/**
* This is a description for the `meta` of regular CSF.
*/
export const meta = {
title: 'Docs/Svelte CSF',
component: DocsComponent,
tags: ['autodocs'],
} satisfies Meta<DocsComponent>;
</script>

<Template let:args>
<DocsComponent {...args} />
</Template>

<!-- This is a description for the _primary_ story, `NoArgs`. -->
<Story name="NoArgs" />

<Story name="TrueArgs" args={{ someBoolProp: true }}/>

<Story name="FalseArgs" args={{ someBoolProp: false }}/>
Loading

0 comments on commit fd939b4

Please sign in to comment.