#39 cleanup stories for Button and StarRating component

This commit is contained in:
neil 2022-11-29 20:08:07 +08:00
parent b1ba538d51
commit fa0e2d98bb
6 changed files with 16 additions and 25 deletions

View file

@ -9,7 +9,7 @@
/** @type {import('./$types').PageData} */ /** @type {import('./$types').PageData} */
export let data; export let data;
import { packages as packagesStore, initializePackages } from '$libs/stores'; import { packages as packagesStore } from '$libs/stores';
import type { Package } from '@tea/ui/types'; import type { Package } from '@tea/ui/types';

View file

@ -1,4 +1,4 @@
import Button from './Button.svelte'; import Button from './ButtonView.svelte';
// More on how to set up stories at: https://storybook.js.org/docs/7.0/svelte/writing-stories/introduction // More on how to set up stories at: https://storybook.js.org/docs/7.0/svelte/writing-stories/introduction
export default { export default {
@ -7,26 +7,12 @@ export default {
tags: ['docsPage'], tags: ['docsPage'],
render: (args) => ({ render: (args) => ({
Component: Button, Component: Button,
props: args, props: args
on: {
click: args.onClick
}
}), }),
argTypes: { argTypes: {
backgroundColor: { control: 'color' }, onClick: () => console.log('does nothing')
label: { control: 'text' },
onClick: { action: 'onClick' },
primary: { control: 'boolean' },
size: {
control: { type: 'select' },
options: ['small', 'medium', 'large']
}
} }
}; };
// More on writing stories with args: https://storybook.js.org/docs/7.0/svelte/writing-stories/args // More on writing stories with args: https://storybook.js.org/docs/7.0/svelte/writing-stories/args
export const Primary = { export const Primary = {};
args: {
primary: true
}
};

View file

@ -1,10 +1,10 @@
<script type="ts"> <script type="ts">
let clazz: string = ''; let clazz: string;
export { clazz as class }; export { clazz as class };
export let size: 'large' | 'medium' | 'small' = 'medium'; // export let size: 'large' | 'medium' | 'small' = 'medium';
export let onClick: () => void; export let onClick: undefined | (() => void) = undefined;
</script> </script>
<button <button

View file

@ -0,0 +1,5 @@
<script lang="ts">
import Button from './Button.svelte';
</script>
<Button>Click Me</Button>

View file

@ -23,7 +23,7 @@ export default {
tags: ['docsPage'], tags: ['docsPage'],
render: ({ pkg, link }: { pkg: Package; link: string }) => ({ render: ({ pkg, link }: { pkg: Package; link: string }) => ({
Component: PackageCard, Component: PackageCard,
props: { pkg } props: { pkg, link }
}), }),
argTypes: { argTypes: {
pkg: { pkg: {

View file

@ -1,8 +1,8 @@
<script type="ts"> <script type="ts">
import '../app.css'; import '../app.css';
export let rating: number = 0; export let rating = 0;
export let maxRating: number = 5; export let maxRating = 5;
let stars: string[] = []; let stars: string[] = [];
for (let i = 1; i <= maxRating; i++) { for (let i = 1; i <= maxRating; i++) {