Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ボタンコンポーネントの実装 #21

Merged
merged 3 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions src/components/UI/BaseButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<script lang="ts" setup>
import Icon from '/@/components/UI/Icon.vue'

type ButtonType = 'primary' | 'secondary' | 'danger'

interface Props {
type?: ButtonType
icon?: string
isDisabled?: boolean
}

const props = withDefaults(defineProps<Props>(), {
type: 'primary',
icon: undefined,
isDisabled: false
})
</script>

<template>
<button
:class="$style.button"
:data-button-type="props.type"
:disabled="props.isDisabled"
>
<icon v-if="props.icon" :name="props.icon" :class="$style.icon" />
<slot />
</button>
</template>

<style lang="scss" module>
.button {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
mehm8128 marked this conversation as resolved.
Show resolved Hide resolved
padding: 4px 24px;
border-radius: 6px; // todo:%で指定に変えるかも
box-shadow: 0px 2px 1px rgba(0, 0, 0, 0.1);
transition: 0.2s ease-in-out;

&[data-button-type='primary'] {
color: $color-primary-text;
background-color: $color-primary;
}
&[data-button-type='secondary'] {
color: $color-primary;
background-color: $color-background;
border: 1px solid $color-primary;
}
&[data-button-type='danger'] {
color: $color-primary-text;
background-color: $color-danger;
}

&:hover {
opacity: 0.8;
}
&[disabled] {
opacity: 0.5;
cursor: not-allowed;
}
}

.icon {
display: flex;
}
</style>
2 changes: 2 additions & 0 deletions src/styles/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ $color-secondary-text: #333E47;
$color-background: #FFFFFF;
$color-background-dim: #eff0f0;
$color-text: #222425;

$color-danger:#F26451;