-
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 fcb82b4
Showing
2 changed files
with
101 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,31 @@ | ||
import { StoryFn } from '@storybook/vue3' | ||
import LinkButton from './LinkButton.vue' | ||
|
||
export default { | ||
title: 'LinkButton', | ||
component: LinkButton, | ||
args: { | ||
title: 'button', | ||
backgroundColor: 'vue-green', | ||
color: 'white', | ||
href: 'https://example.com', | ||
}, | ||
} | ||
|
||
const Template: StoryFn<unknown> = (args, { argTypes }) => ({ | ||
props: Object.keys(argTypes), | ||
components: { LinkButton }, | ||
setup() { | ||
return { args } | ||
}, | ||
template: `<div style="width: 400px;"> | ||
<LinkButton v-bind="args">{{ args.title }}</LinkButton> | ||
</div>`, | ||
}) | ||
|
||
export const Default = Template.bind({}) | ||
|
||
export const TargetBlank = Template.bind({}) | ||
TargetBlank.args = { | ||
target:'_blank' | ||
} |
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,70 @@ | ||
<script setup lang="ts"> | ||
import { ButtonHTMLAttributes,ref,computed } from 'vue' | ||
import CssResetButton from './CssResetButton.vue' | ||
import type { Color as ColorType } 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 | ||
} | ||
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) | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<a :href="props.href" :target="target" @mouseover="hoverIn" @mouseleave="hoverOut" @focus="{}" @blur="{}"> | ||
<CssResetButton | ||
type="button" | ||
:style="style" | ||
class="link-button" | ||
v-bind="props"> | ||
<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; | ||
} | ||
</style> |