add BaseButton component

This commit is contained in:
Alina Beck 2019-12-10 16:25:14 +03:00
parent 8f70ce5b31
commit 2c2f69fbf8
3 changed files with 62 additions and 0 deletions

View File

@ -3,6 +3,7 @@
}
button {
padding: 0;
background: transparent;
border: none;
font-family: inherit;

View File

@ -0,0 +1,21 @@
import { storiesOf } from '@storybook/vue'
import helpers from '~/storybook/helpers'
import BaseButton from './BaseButton.vue'
storiesOf('BaseButton', module)
.addDecorator(helpers.layout)
.add('Default', () => ({
components: { BaseButton },
template: '<base-button>Click me</base-button>',
}))
.add('With Icon', () => ({
components: { BaseButton },
template: '<base-button icon="edit">With Icon</base-button>',
}))
.add('Icon Only', () => ({
components: { BaseButton },
template: '<base-button icon="trash" />',
}))

View File

@ -0,0 +1,40 @@
<template>
<button class="base-button">
<base-icon v-if="icon" :name="icon" :class="iconClass" />
<slot />
</button>
</template>
<script>
export default {
props: {
icon: {
type: String,
},
},
computed: {
iconClass() {
return this.$slots.default == null ? '--icon-only' : ''
}
}
}
</script>
<style lang="scss">
.base-button {
display: inline-flex;
align-items: center;
height: 36px;
padding: 0 12px;
color: $color-primary;
background-color: $color-neutral-90;
border: 1px solid $color-primary;
border-radius: 6px;
font-weight: $font-weight-bold;
cursor: pointer;
> .base-icon:not(.--icon-only) {
margin-right: 6px;
}
}
</style>