Skip to content

Commit

Permalink
feat: form button component
Browse files Browse the repository at this point in the history
  • Loading branch information
paring-chan committed Mar 20, 2024
1 parent 7a18aed commit b62a842
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/lib/components/button/FormButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts">
import { useActions, type ActionArray } from 'svelte-component-actions'
export let use: ActionArray = []
export let href: string | null = null
</script>

{#if href}
<a {href} use:useActions={use} class="button" {...$$restProps}>
<slot />
</a>
{:else}
<button on:click use:useActions={use} class="button" {...$$restProps}>
<slot />
</button>
{/if}

<style lang="scss">
.button {
height: 48px;
display: flex;
width: 100%;
justify-content: center;
align-items: center;
font-size: 16px;
font-weight: 500;
border-radius: 6px;
background-color: rgba(255, 255, 255, 0.2);
transition: background-color ease 0.2s;
&:hover,
&:focus {
background-color: rgba(255, 255, 255, 0.4);
}
}
</style>
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export { default as Popover } from './components/Popover.svelte'
// Buttons
export { default as RoundedOutlinedButton } from './components/button/RoundedOutlinedButton.svelte'
export { default as TextButton } from './components/button/TextButton.svelte'
export { default as FormButton } from './components/button/FormButton.svelte'

// Nav
export { default as Nav } from './components/nav/Nav.svelte'
Expand Down
21 changes: 21 additions & 0 deletions src/stories/button/FormButton.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script lang="ts" context="module">
import { FormButton } from '$lib/index.js'
export const meta = {
title: 'Components/Button/Form Button',
component: FormButton
}
</script>

<script lang="ts">
import { TextButton } from '$lib/index.js'
import { Story, Template } from '@storybook/addon-svelte-csf'
</script>

<Template let:args>
<FormButton {...args}>Button</FormButton>
</Template>

<Story name="Default" args={{}} />

<Story name="Link" args={{ href: 'https://adofai.gg' }} />

0 comments on commit b62a842

Please sign in to comment.