replace ds-button with base-button (wip)

This commit is contained in:
Alina Beck 2019-12-19 00:50:27 +05:30
parent 7cf8aec283
commit 7c7a800bc2
9 changed files with 49 additions and 41 deletions

View File

@ -3,16 +3,16 @@
<ds-flex :gutter="{ base: 'xx-small', md: 'small', lg: 'xx-small' }"> <ds-flex :gutter="{ base: 'xx-small', md: 'small', lg: 'xx-small' }">
<div v-for="category in categories" :key="category.id"> <div v-for="category in categories" :key="category.id">
<ds-flex-item> <ds-flex-item>
<ds-button <base-button
size="small"
:data-test="categoryButtonsId(category.id)" :data-test="categoryButtonsId(category.id)"
@click.prevent="toggleCategory(category.id)" @click="toggleCategory(category.id)"
:primary="isActive(category.id)" :primary="isActive(category.id)"
:disabled="isDisabled(category.id)" :disabled="isDisabled(category.id)"
:icon="category.icon"
size="small"
> >
<base-icon :name="category.icon" />
{{ $t(`contribution.category.name.${category.slug}`) }} {{ $t(`contribution.category.name.${category.slug}`) }}
</ds-button> </base-button>
</ds-flex-item> </ds-flex-item>
</div> </div>
</ds-flex> </ds-flex>

View File

@ -1,28 +1,17 @@
<template> <template>
<ds-form v-model="form" @submit="handleSubmit"> <ds-form v-model="form" @submit="handleSubmit" class="comment-form">
<template slot-scope="{ errors }"> <template slot-scope="{ errors }">
<ds-card> <ds-card>
<!-- with client-only the content is not shown --> <!-- with client-only the content is not shown -->
<hc-editor ref="editor" :users="users" :value="form.content" @input="updateEditorContent" /> <hc-editor ref="editor" :users="users" :value="form.content" @input="updateEditorContent" />
<ds-space /> <div class="buttons">
<ds-flex :gutter="{ base: 'small', md: 'small', sm: 'x-large', xs: 'x-large' }"> <base-button :disabled="disabled && !update" @click="handleCancel">
<ds-flex-item :width="{ base: '0%', md: '50%', sm: '0%', xs: '0%' }" /> {{ $t('actions.cancel') }}
<ds-flex-item :width="{ base: '40%', md: '20%', sm: '30%', xs: '30%' }"> </base-button>
<ds-button <base-button type="submit" :loading="loading" :disabled="disabled || errors" primary>
:disabled="disabled && !update" {{ $t('post.comment.submit') }}
ghost </base-button>
class="cancelBtn" </div>
@click.prevent="handleCancel"
>
{{ $t('actions.cancel') }}
</ds-button>
</ds-flex-item>
<ds-flex-item :width="{ base: '40%', md: '20%', sm: '40%', xs: '40%' }">
<ds-button type="submit" :loading="loading" :disabled="disabled || errors" primary>
{{ $t('post.comment.submit') }}
</ds-button>
</ds-flex-item>
</ds-flex>
</ds-card> </ds-card>
</template> </template>
</ds-form> </ds-form>
@ -78,6 +67,7 @@ export default {
this.$emit('showEditCommentMenu', false) this.$emit('showEditCommentMenu', false)
}, },
handleCancel() { handleCancel() {
console.log('handle cancel')
if (!this.update) { if (!this.update) {
this.clear() this.clear()
} else { } else {
@ -146,3 +136,17 @@ export default {
}, },
} }
</script> </script>
<style lang="scss">
.comment-form {
.buttons {
display: flex;
justify-content: flex-end;
margin: $space-small 0;
> .base-button {
margin-left: $space-x-small;
}
}
}
</style>

View File

@ -46,7 +46,7 @@ describe('ContentMenu.vue', () => {
store, store,
localVue, localVue,
}) })
menuToggle = wrapper.find('.content-menu-trigger') menuToggle = wrapper.find('[data-test="content-menu-button"]')
menuToggle.trigger('click') menuToggle.trigger('click')
return wrapper return wrapper
} }

View File

@ -2,9 +2,14 @@
<dropdown class="content-menu" :placement="placement" offset="5"> <dropdown class="content-menu" :placement="placement" offset="5">
<template slot="default" slot-scope="{ toggleMenu }"> <template slot="default" slot-scope="{ toggleMenu }">
<slot name="button" :toggleMenu="toggleMenu"> <slot name="button" :toggleMenu="toggleMenu">
<ds-button class="content-menu-trigger" size="small" ghost @click.prevent="toggleMenu"> <base-button
<base-icon name="ellipsis-v" /> data-test="content-menu-button"
</ds-button> icon="ellipsis-v"
size="small"
circle
ghost
@click="toggleMenu"
/>
</slot> </slot>
</template> </template>
<div slot="popover" slot-scope="{ toggleMenu }" class="content-menu-popover"> <div slot="popover" slot-scope="{ toggleMenu }" class="content-menu-popover">

View File

@ -257,7 +257,7 @@ describe('ContributionForm.vue', () => {
describe('cancel', () => { describe('cancel', () => {
it('calls $router.back() when cancel button clicked', () => { it('calls $router.back() when cancel button clicked', () => {
cancelBtn = wrapper.find('.cancel-button') cancelBtn = wrapper.find('[data-test="cancel-button"]')
cancelBtn.trigger('click') cancelBtn.trigger('click')
expect(mocks.$router.back).toHaveBeenCalledTimes(1) expect(mocks.$router.back).toHaveBeenCalledTimes(1)
}) })

View File

@ -82,17 +82,16 @@
</ds-text> </ds-text>
<ds-space /> <ds-space />
<div slot="footer" style="text-align: right"> <div slot="footer" style="text-align: right">
<ds-button <base-button
class="cancel-button" data-test="cancel-button"
:disabled="loading" :disabled="loading"
ghost @click="$router.back()"
@click.prevent="$router.back()"
> >
{{ $t('actions.cancel') }} {{ $t('actions.cancel') }}
</ds-button> </base-button>
<ds-button type="submit" icon="check" :loading="loading" :disabled="errors" primary> <base-button type="submit" icon="check" :loading="loading" :disabled="errors" primary>
{{ $t('actions.save') }} {{ $t('actions.save') }}
</ds-button> </base-button>
</div> </div>
<ds-space margin-bottom="large" /> <ds-space margin-bottom="large" />
</ds-card> </ds-card>

View File

@ -32,7 +32,7 @@ describe('DonationInfo.vue', () => {
it('displays a call to action button', () => { it('displays a call to action button', () => {
expect( expect(
Wrapper() Wrapper()
.find('.ds-button') .find('.base-button')
.text(), .text(),
).toBe('donations.donate-now') ).toBe('donations.donate-now')
}) })

View File

@ -2,7 +2,7 @@
<div class="donation-info"> <div class="donation-info">
<progress-bar :title="title" :label="label" :goal="goal" :progress="progress" /> <progress-bar :title="title" :label="label" :goal="goal" :progress="progress" />
<a target="_blank" href="https://human-connection.org/spenden/"> <a target="_blank" href="https://human-connection.org/spenden/">
<ds-button primary>{{ $t('donations.donate-now') }}</ds-button> <base-button primary>{{ $t('donations.donate-now') }}</base-button>
</a> </a>
</div> </div>
</template> </template>

View File

@ -1,7 +1,7 @@
<template> <template>
<ds-button size="small" :ghost="!isActive" @click.prevent="onClick" :icon="icon"> <base-button size="small" circle :ghost="!isActive" @click="onClick" :icon="icon">
<span v-if="label">{{ label }}</span> <span v-if="label">{{ label }}</span>
</ds-button> </base-button>
</template> </template>
<script> <script>