-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The latest stable release doesn't support Svelte 5, so we have to use the v8 pre-release.
- Loading branch information
1 parent
49cef3a
commit de6bb22
Showing
32 changed files
with
8,117 additions
and
705 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,27 @@ | ||
import type { StorybookConfig } from "@storybook/sveltekit"; | ||
|
||
import { join, dirname } from "path"; | ||
|
||
/** | ||
* This function is used to resolve the absolute path of a package. | ||
* It is needed in projects that use Yarn PnP or are set up within a monorepo. | ||
*/ | ||
function getAbsolutePath(value: string): any { | ||
return dirname(require.resolve(join(value, "package.json"))); | ||
} | ||
const config: StorybookConfig = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: [ | ||
getAbsolutePath("@storybook/addon-links"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@storybook/addon-interactions"), | ||
], | ||
framework: { | ||
name: getAbsolutePath("@storybook/sveltekit"), | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
}; | ||
export default config; |
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 @@ | ||
import type { Preview } from "@storybook/svelte"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
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
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,48 @@ | ||
import type { Meta, StoryObj } from '@storybook/svelte'; | ||
|
||
import Button from './Button.svelte'; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories | ||
const meta = { | ||
title: 'Example/Button', | ||
component: Button, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
backgroundColor: { control: 'color' }, | ||
size: { | ||
control: { type: 'select' }, | ||
options: ['small', 'medium', 'large'], | ||
}, | ||
}, | ||
} satisfies Meta<Button>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args | ||
export const Primary: Story = { | ||
args: { | ||
primary: true, | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Secondary: Story = { | ||
args: { | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Large: Story = { | ||
args: { | ||
size: 'large', | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Small: Story = { | ||
args: { | ||
size: 'small', | ||
label: 'Button', | ||
}, | ||
}; |
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,34 @@ | ||
<script lang="ts"> | ||
import './button.css'; | ||
/** | ||
* Is this the principal call to action on the page? | ||
*/ | ||
export let primary = false; | ||
/** | ||
* What background color to use | ||
*/ | ||
export let backgroundColor: string | undefined = undefined; | ||
/** | ||
* How large should the button be? | ||
*/ | ||
export let size: 'small' | 'medium' | 'large' = 'medium'; | ||
/** | ||
* Button contents | ||
*/ | ||
export let label: string = ''; | ||
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; | ||
$: style = backgroundColor ? `background-color: ${backgroundColor}` : ''; | ||
</script> | ||
|
||
<button | ||
type="button" | ||
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')} | ||
{style} | ||
on:click | ||
> | ||
{label} | ||
</button> |
Oops, something went wrong.