-
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
1 parent
1c884a5
commit 98d4cf9
Showing
2 changed files
with
126 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { StoryFn } from '@storybook/vue3' | ||
import LinkButton from './LinkButton.vue' | ||
|
||
export default { | ||
title: 'common/LinkButton', | ||
component: LinkButton, | ||
args: { | ||
title: 'button', | ||
backgroundColor: 'vue-green', | ||
color: 'white', | ||
href: 'https://example.com', | ||
iconName: 'x', | ||
}, | ||
} | ||
|
||
const Template: StoryFn<unknown> = (args, { argTypes }) => ({ | ||
props: Object.keys(argTypes), | ||
components: { LinkButton }, | ||
setup() { | ||
return { args } | ||
}, | ||
template: `<div style="width: 400px;"> | ||
<LinkButton :="args">{{ args.title }}</LinkButton> | ||
</div>`, | ||
}) | ||
|
||
export const Default = Template.bind({}) | ||
|
||
export const TargetBlank = Template.bind({}) | ||
TargetBlank.args = { | ||
target:'_blank' | ||
} | ||
|
||
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,87 @@ | ||
<script setup lang="ts"> | ||
import { ButtonHTMLAttributes, ref, computed } from 'vue' | ||
import CssResetButton from './CssResetButton.vue' | ||
import Icon from './Icon.vue' | ||
import type { Color as ColorType, IconName } from '@vuejs-jp/model' | ||
import { useColor } from '@vuejs-jp/composable' | ||
type _LinkButtonProps = Omit<ButtonHTMLAttributes, 'onClick'> | ||
interface LinkButtonProps extends /* @vue-ignore */ _LinkButtonProps { | ||
backgroundColor: ColorType | ||
color: ColorType | ||
href: string | ||
target: string | ||
iconName: IconName | ||
} | ||
const props = defineProps<LinkButtonProps>() | ||
const { color } = useColor() | ||
const hover = ref(false) | ||
const hoverIn = () => { | ||
hover.value = true | ||
} | ||
const hoverOut = () => { | ||
hover.value = false | ||
} | ||
const style = computed(() =>{ | ||
if (hover.value){ | ||
return { | ||
color: color(props.backgroundColor), | ||
backgroundColor: color(props.color), | ||
borderSize:'1px', | ||
borderColor:props.backgroundColor | ||
} | ||
} | ||
return { | ||
backgroundColor: color(props.backgroundColor), | ||
color: color(props.color) | ||
} | ||
}) | ||
const iconColor = computed(() =>{ | ||
if (hover.value){ | ||
return props.backgroundColor | ||
} | ||
return props.color | ||
}) | ||
</script> | ||
|
||
<template> | ||
<a :href="props.href" :target="target" @mouseover="hoverIn" @mouseleave="hoverOut" @focus="{}" @blur="{}"> | ||
<CssResetButton | ||
type="button" | ||
:style="style" | ||
class="link-button" | ||
:="props" | ||
> | ||
<Icon | ||
:color="iconColor" | ||
:name="props.iconName" | ||
class="icon" | ||
/> | ||
<slot /> | ||
</CssResetButton> | ||
</a> | ||
</template> | ||
|
||
<style scoped> | ||
.link-button { | ||
display: inline-flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
padding: 22px 66px; | ||
border-radius: 40px; | ||
font-weight: bold; | ||
font-size: 20px; | ||
cursor: pointer; | ||
border-style: solid; | ||
} | ||
.link-button:hover { | ||
transition: .2s; | ||
} | ||
.icon { | ||
margin-right: 8px; | ||
} | ||
</style> |