Skip to content

Commit

Permalink
0.0.14 - new feature: customizable button class
Browse files Browse the repository at this point in the history
 - test(customized button class): add new test in favor of a customized button class
 - doc: append documentation about 'buttonClass' prop
  • Loading branch information
Ricardo Falasca committed Aug 3, 2018
1 parent 57925be commit c684ffe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ new Vue({
<vue-ladda>Confirm</vue-ladda>
```

- Use `buttonClass` prop to specify your own CSS classes: (Default is "ladda-class")
ie. you can use Bootstrap button classes

```html
<vue-ladda button-class="btn btn-primary">Yes!</vue-ladda>
```

- Use `data-style` prop to specify animation:

```html
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-ladda",
"version": "0.0.13",
"version": "0.0.14",
"description": "A vue component wrapper of Ladda button.",
"homepage": "https://github.com/zcfan/vue-ladda",
"main": "dist/vue-ladda.js",
Expand Down
16 changes: 8 additions & 8 deletions src/vue-ladda.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<button class="ladda-button" ref="ladda" :data-style="dataStyle" @click="handleClick">
<span class="ladda-label"><slot>Submit</slot></span>
<button :class="buttonClass" ref="ladda" :data-style="dataStyle" @click="handleClick">
<slot><span class="ladda-label">Submit</span></slot>
</button>
</template>

Expand All @@ -11,8 +11,13 @@
name: 'VueLadda',
props: {
// customizable button's class attribute - you can use your own CSS class
'buttonClass': {
type: String,
default: 'ladda-class'
},
// use vue props validation to make sure "data-style" is given. (ladda need it)
"dataStyle": {
'dataStyle': {
type: String,
default: 'expand-left'
},
Expand Down Expand Up @@ -56,8 +61,3 @@
}
};
</script>

<style lang="scss">
// TODO: make themed a option?
@import '~ladda/css/ladda-themed.scss';
</style>
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ describe('VueLadda', () => {

it('sets the correct default data', () => {
const vm = new Ctor().$mount();
expect(vm.buttonClass).toBe('ladda-class');
expect(vm.dataStyle).toBe('expand-left');
expect(vm.progress).toBe(0);
});

it('test custom button class', () => {
let bsClasses = 'btn btn-primary'
const vm = new Ctor({propsData: {buttonClass: bsClasses}}).$mount();
expect(vm.buttonClass).toBe(bsClasses)
});
});

0 comments on commit c684ffe

Please sign in to comment.