Skip to content

Commit afecb0e

Browse files
committed
refactor: CButton, CBadge: turn shape props to one 'shape' prop
1 parent 654f0b6 commit afecb0e

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

src/components/badge/CBadge.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ const props = Object.assign(linkProps, {
88
default: 'span'
99
},
1010
color: String,
11-
pill: Boolean
11+
shape: {
12+
type: String,
13+
validator: shape => ['', 'pill'].includes(shape)
14+
}
1215
})
1316
1417
export default {
@@ -21,7 +24,7 @@ export default {
2124
staticClass: 'badge',
2225
class: {
2326
[`badge-${props.color}`]: props.color,
24-
'badge-pill': props.pill,
27+
'badge-pill': props.shape === 'pill',
2528
'active': props.active,
2629
'disabled': props.disabled
2730
},

src/components/badge/tests/CBadge.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const customWrapper = mount(Component, {
77
propsData: {
88
color: 'success',
99
active: true,
10-
pill: true,
10+
shape: 'pill',
1111
disabled: true,
1212
href: 'someLink'
1313
},

src/components/button/CButton.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import CLink, { propsFactory as linkPropsFactory } from '../link/CLink'
55
66
const btnProps = {
77
block: Boolean,
8-
pill: Boolean,
9-
square: Boolean,
8+
shape: {
9+
type: String,
10+
validator: shape => ['','pill', 'square'].includes(shape)
11+
},
1012
variant: {
1113
type: String,
1214
validator: val => ['', 'ghost', 'outline'].includes(val)
@@ -42,8 +44,8 @@ function computeClasses (props) {
4244
[`btn-${props.size}`]: Boolean(props.size),
4345
[`btn-ghost-${props.color}`]: props.variant === 'ghost',
4446
'btn-block': props.block,
45-
'btn-pill': props.pill,
46-
'btn-square': props.square && !props.pill,
47+
'btn-pill': props.shape === 'pill',
48+
'btn-square': props.shape === 'square',
4749
'disabled': props.disabled,
4850
'active': props.pressed
4951
}

src/components/button/tests/CButton.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const toggleWrapper = mount(Component, {
1414
color: 'info',
1515
variant: 'outline',
1616
block: true,
17-
square: true
17+
shape: 'square'
1818
}
1919
},
2020
listeners: {
@@ -32,7 +32,7 @@ const routerLinkWrapper = mount(Component, {
3232
size: 'sm',
3333
color: 'success',
3434
variant: 'ghost',
35-
pill: true
35+
shape: 'pill'
3636
}
3737
},
3838
listeners: {

src/components/index.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export declare class CAlert extends Vue {
99
export declare class CBadge extends CLink {
1010
tag: string
1111
color: string
12-
pill: boolean
12+
shape: string
1313
}
1414

1515
export declare class CBreadcrumb extends Vue {
@@ -27,8 +27,7 @@ export declare class CBreadcrumbRouter extends Vue {
2727

2828
export declare class CButton extends CLink {
2929
block: boolean
30-
pill: boolean
31-
square: boolean
30+
shape: string
3231
variant: string
3332
size: string
3433
color: string

0 commit comments

Comments
 (0)