generated from unplugin/unplugin-starter
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add documentations via custom docs block (#53)
Fixes #49
- Loading branch information
1 parent
157dd57
commit 77e010a
Showing
13 changed files
with
372 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<template> | ||
<div class="checkbox"> | ||
<input | ||
type="checkbox" | ||
:checked="checked" | ||
:disabled="disabled" | ||
@change="onChange" | ||
/> | ||
<label>{{ label }}</label> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
const props = defineProps({ | ||
label: { | ||
type: String, | ||
required: true, | ||
}, | ||
checked: { | ||
type: Boolean, | ||
required: false, | ||
default: false, | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
required: false, | ||
default: false, | ||
}, | ||
}) | ||
const checked = ref(props.checked) | ||
const onChange = () => { | ||
checked.value = !checked.value | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script lang="ts" setup> | ||
import MyButton from '../components/Button.vue' | ||
</script> | ||
|
||
<template> | ||
<Stories | ||
:component="MyButton" | ||
title="Tests/Docs" | ||
> | ||
<Story title="Default"> | ||
<MyButton label="Button" /> | ||
</Story> | ||
</Stories> | ||
</template> | ||
|
||
<docs lang="md"> | ||
import { Canvas } from '@storybook/blocks'; | ||
|
||
# Documentation | ||
|
||
Everything in one place. Isn't it great? | ||
|
||
You can render stories in the docs using the `<Canvas>` component. | ||
|
||
<Canvas /> | ||
|
||
See [Storybook Docs](https://storybook.js.org/docs/vue/writing-docs/introduction) for more information. | ||
</docs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{/* Checkbox.mdx */} | ||
|
||
import { Canvas, Meta, Story } from '@storybook/blocks' | ||
|
||
import * as CheckboxStories from './mdx-1.basic-example.stories.ts' | ||
|
||
<Meta of={CheckboxStories} /> | ||
|
||
# Checkbox | ||
|
||
A checkbox is a square box that can be activated or deactivated when ticked. | ||
|
||
Use checkboxes to select one or more options from a list of choices. | ||
|
||
<Canvas of={CheckboxStories.Unchecked} /> |
24 changes: 24 additions & 0 deletions
24
examples/vite/src/writing_docs/mdx-1.basic-example.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Checkbox.stories.ts|tsx | ||
|
||
// Replace your-framework with the name of your framework | ||
import type { Meta, StoryObj } from '@storybook/vue3' | ||
|
||
import Checkbox from '../components/Checkbox.vue' | ||
|
||
const meta: Meta<typeof Checkbox> = { | ||
/* 👇 The title prop is optional. | ||
* See https://storybook.js.org/docs/react/configure/overview#configure-story-loading | ||
* to learn how to generate automatic titles | ||
*/ | ||
title: 'docs/Writing docs/MDX/1. Basic Example/classical', | ||
component: Checkbox, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof Checkbox> | ||
|
||
export const Unchecked: Story = { | ||
args: { | ||
label: 'Unchecked', | ||
}, | ||
} |
24 changes: 24 additions & 0 deletions
24
examples/vite/src/writing_docs/mdx-1.basic-example.stories.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup lang="ts"> | ||
import Checkbox from '../components/Checkbox.vue' | ||
</script> | ||
<template> | ||
<Stories | ||
:component="Checkbox" | ||
title="docs/Writing docs/MDX/1. Basic Example/native" | ||
> | ||
<Story title="Unchecked"> | ||
<Checkbox label="Unchecked" /> | ||
</Story> | ||
</Stories> | ||
</template> | ||
<docs lang="md"> | ||
import { Canvas } from '@storybook/blocks'; | ||
|
||
# Checkbox | ||
|
||
A checkbox is a square box that can be activated or deactivated when ticked. | ||
|
||
Use checkboxes to select one or more options from a list of choices. | ||
|
||
<Canvas of={Unchecked} /> | ||
</docs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.