-
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.
- Loading branch information
Showing
4 changed files
with
294 additions
and
21 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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport' | ||
|
||
export const parameters = { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
viewport: { | ||
viewports: INITIAL_VIEWPORTS, | ||
defaultViewport: 'responsive', | ||
}, | ||
} |
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,91 @@ | ||
import { StoryFn } from '@storybook/vue3' | ||
import Button from './Button.vue' | ||
|
||
export default { | ||
title: 'Button', | ||
component: Button, | ||
args: {}, | ||
} | ||
|
||
const Template: StoryFn<unknown> = (args, { argTypes }) => ({ | ||
props: Object.keys(argTypes), | ||
viewport: { defaultViewport: 'iphonex' }, | ||
components: { Button }, | ||
setup() { | ||
return { args } | ||
}, | ||
template: ` | ||
<h2>Buttons</h2> | ||
<div> | ||
<p style="padding: 10px"> | ||
<Button :="args">あ</Button> | ||
 通常 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args" fixed-width>申し込む</Button> | ||
 長さ固定 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args">あいうえおかきくけこたちつてと</Button> | ||
 ラベルに沿って伸長 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args" disabled>あ</Button> | ||
 disabled | ||
</p> | ||
</div> | ||
<h2>RouterLinks</h2> | ||
<div> | ||
<p style="padding: 10px"> | ||
<Button :="args" to="/">あ</Button> | ||
 通常 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args" fixed-width to="/">申し込む</Button> | ||
 長さ固定 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args" to="/">あいうえおかきくけこたちつてと</Button> | ||
 ラベルに沿って伸長 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args" to="/" disabled>あ</Button> | ||
 disabled | ||
</p> | ||
</div> | ||
<h2>AnchorLinks</h2> | ||
<div> | ||
<p style="padding: 10px"> | ||
<Button :="args" href="/">あ</Button> | ||
 通常 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args" fixed-width href="/">申し込む</Button> | ||
 長さ固定 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args" href="/">あいうえおかきくけこたちつてと</Button> | ||
 ラベルに沿って伸長 | ||
</p> | ||
<p style="padding: 10px"> | ||
<Button :="args" href="/" disabled>あ</Button> | ||
 disabled | ||
</p> | ||
</div>`, | ||
}) | ||
|
||
export const Default = Template.bind({}) | ||
Default.args = {} | ||
|
||
export const Secondary = Template.bind({}) | ||
Secondary.args = { | ||
secondary: true, | ||
} | ||
|
||
// export const SubLinkButton = Template.bind({}) | ||
// SubLinkButton.args = { | ||
// backgroundColor: 'white', | ||
// color: 'vue-blue', | ||
// iconName: 'note', | ||
// } |
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,186 @@ | ||
<script setup lang="ts"> | ||
import { ButtonHTMLAttributes, ref, computed } from 'vue' | ||
Check warning on line 2 in packages/ui/components/Button.vue GitHub Actions / lint (18.19.0)
|
||
const emit = defineEmits(['click']) | ||
const props = defineProps({ | ||
secondary: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
href: { | ||
type: String, | ||
default: '', | ||
}, | ||
to: { | ||
type: String, | ||
default: '', | ||
}, | ||
target: { | ||
type: String, | ||
default: '', | ||
}, | ||
rel: { | ||
type: String, | ||
default: 'noreferrer', | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
fixedWidth: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}) | ||
const isLink = Boolean(props.href) | ||
const isRouterLink = Boolean(props.to) | ||
const myclass = computed(() => { | ||
const cls = ['button'] | ||
if (props.secondary) { | ||
cls.push('-secondary') | ||
} | ||
if (props.disabled) { | ||
cls.push('-disabled') | ||
} | ||
if (props.fixedWidth) { | ||
cls.push('-fixedWidth') | ||
} | ||
return cls.join(' ') | ||
}) | ||
const onClick = (e: Event) => { | ||
emit('click', e) | ||
} | ||
const routerLinkProps = { | ||
to: props.to, | ||
} | ||
const linkProps = { | ||
href: props.href, | ||
rel: props.rel, | ||
target: props.target, | ||
} | ||
const buttonProps = { | ||
type: props.type, | ||
onClick, | ||
} | ||
const tag = computed(() => { | ||
if (isRouterLink) { | ||
return 'NuxtLink'; | ||
} | ||
if (isLink) { | ||
return 'a' | ||
} | ||
return 'button' | ||
}) | ||
const bindProps = computed(() => { | ||
if (isRouterLink) { | ||
return { to: props.to, } | ||
} | ||
if (isLink) { | ||
return { | ||
href: props.href, | ||
rel: props.rel, | ||
target: props.target, | ||
} | ||
} | ||
return { | ||
onClick, | ||
} | ||
}) | ||
</script> | ||
|
||
|
||
<template> | ||
<component :is="tag" :class="myclass" :disabled="props.disabled || null" :aria-disabled="props.disabled" | ||
v-bind="{ ...bindProps }"> | ||
<span class="button-label"> | ||
<slot /> | ||
</span> | ||
</component> | ||
</template> | ||
|
||
<style scoped> | ||
.button { | ||
--color-vue-green-gradation: linear-gradient(to right, #42b883, #41b8aa); | ||
--color-vue-green: #42b983; | ||
--color-vue-blue: #35495e; | ||
--color-disabled: #C6CACF; | ||
--box-shadow: 0 2px 10px rgb(53, 73, 95, 0.14); | ||
display: inline-flex; | ||
justify-content: center; | ||
min-width: 198px; | ||
background: var(--color-vue-green-gradation); | ||
font-size: 18px; | ||
white-space: nowrap; | ||
border-radius: 40px; | ||
padding: 0; | ||
cursor: pointer; | ||
color: white; | ||
border: none; | ||
box-sizing: border-box; | ||
text-decoration: none; | ||
box-shadow: var(--box-shadow); | ||
font-family: 'din-2014', | ||
'Yu Gothic Medium', | ||
'游ゴシック体', | ||
YuGothic, | ||
'游ゴシック', | ||
'Yu Gothic', | ||
sans-serif; | ||
} | ||
.button:hover { | ||
background: white; | ||
color: var(--color-vue-green); | ||
box-shadow: var(--box-shadow), inset 0px 0px 0px 2px var(--color-vue-green); | ||
} | ||
.button.-fixedWidth { | ||
width: 100%; | ||
max-width: 260px; | ||
} | ||
.button.-secondary { | ||
background: white; | ||
box-shadow: var(--box-shadow), inset 0px 0px 0px 2px var(--color-vue-blue); | ||
color: var(--color-vue-blue); | ||
&:hover { | ||
background: var(--color-vue-blue); | ||
color: white; | ||
box-shadow: none; | ||
} | ||
} | ||
.button[disabled] { | ||
pointer-events: none; | ||
background: var(--color-disabled); | ||
box-shadow: var(--box-shadow); | ||
color: white; | ||
} | ||
.button.-secondary[disabled] { | ||
color: var(--color-disabled); | ||
box-shadow: var(--box-shadow), inset 0px 0px 0px 2px var(--color-disabled); | ||
background: white; | ||
} | ||
.button-label { | ||
padding: 24px 66px; | ||
line-height: 1; | ||
} | ||
@media (width <=768px) { | ||
.button, | ||
.button.-fixedWidth { | ||
width: 100%; | ||
max-width: none; | ||
} | ||
} | ||
</style> |