Skip to content

Commit

Permalink
add submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
kokoakuma committed Feb 24, 2024
1 parent 5d814f6 commit b97836a
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/ui/components/forms/SubmitButton.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { StoryFn } from '@storybook/vue3'
import SubmitButton from './SubmitButton.vue'

export default {
title: 'Forms/SubmitButton',
component: SubmitButton,
args: {
default: 'Submit',
disabled: false,
},
argTypes: {
default: {
description: 'Slot for submit button',
control: {
type: 'text',
},
},
},
}

const StoryTemplate: StoryFn<unknown> = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { SubmitButton },
setup() {
return { args }
},
template: '<SubmitButton v-bind="args">{{ args.default }}</SubmitButton>',
})

export const Default = StoryTemplate.bind({})

export const Disabled = StoryTemplate.bind({})
Disabled.args = {
disabled: true,
}
53 changes: 53 additions & 0 deletions packages/ui/components/forms/SubmitButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<script setup lang="ts">
import { toRefs, ButtonHTMLAttributes } from 'vue'
import CssResetButton from '../CssResetButton.vue'
type _SubmitButtonProps = Omit<ButtonHTMLAttributes, 'disabled' | 'onClick'>
interface SubmitButtonProps extends /* @vue-ignore */ _SubmitButtonProps {
disabled?: boolean
}
interface SubmitButtonEmit {
(event: 'on-click'): void

Check warning on line 10 in packages/ui/components/forms/SubmitButton.vue

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'event' is defined but never used
}
const props = defineProps<SubmitButtonProps>()
const { disabled = false } = toRefs(props)

Check warning on line 13 in packages/ui/components/forms/SubmitButton.vue

View workflow job for this annotation

GitHub Actions / lint (18.19.0)

'disabled' is assigned a value but never used
const emit = defineEmits<SubmitButtonEmit>()
const handleClick = () => {
emit('on-click')
}
</script>

<template>
<CssResetButton
type="submit"
class="submit-button"
v-bind="props"
@click="handleClick"
>
<slot />
</CssResetButton>
</template>

<style scoped>
/* TODO デザイン適用 */
.submit-button {
display: inline-flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;
max-width: 500px;
height: 80px;
border-radius: 40px;
font-weight: bold;
font-size: 20px;
cursor: pointer;
background: #42B983;
color: #FFFFFF;
}
.submit-button:disabled {
pointer-events: none;
background-color: #C9DAEA;
}
</style>

0 comments on commit b97836a

Please sign in to comment.