Skip to content

Commit c055ffa

Browse files
committed
refactor: minor refactors in components
1 parent 53e10f6 commit c055ffa

24 files changed

+113
-105
lines changed

src/components/Breadcrumb/CBreadcrumb.vue

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export default {
1212
addLastItemClasses: [String, Array]
1313
},
1414
render (h, { props, data }) {
15-
if(!Array.isArray(props.items)){ return }
16-
let childNodes = props.items.map((item, index, items) => {
17-
if(typeof item !== 'object'){ return }
15+
if (!Array.isArray(props.items)) { return }
16+
const childNodes = props.items.map((item, index, items) => {
17+
if (typeof item !== 'object') { return }
1818
1919
const isLast = items.length === index + 1
2020
const tag = isLast ? 'span' : CLink
@@ -28,13 +28,15 @@ export default {
2828
props: item
2929
}
3030
const itemProps = isLast ? lastItemProps : linkItemProps
31-
return h('li',
32-
{
33-
staticClass: 'c-breadcrumb-item',
34-
class: { 'c-active': isLast },
35-
attrs: { role: 'presentation' }
36-
},
37-
[h(tag, itemProps)])
31+
return h(
32+
'li',
33+
{
34+
staticClass: 'c-breadcrumb-item',
35+
class: { 'c-active': isLast },
36+
attrs: { role: 'presentation' }
37+
},
38+
[h(tag, itemProps)]
39+
)
3840
})
3941
return h('ol', mergeData(data, { staticClass: 'c-breadcrumb' }), childNodes)
4042
}

src/components/Button/CButtonGroup.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ export default {
55
name: 'CButtonGroup',
66
props: {
77
vertical: Boolean,
8-
size: String,
8+
size: {
9+
type: String,
10+
validator: size => ['', 'sm', 'lg'].includes(size)
11+
}
912
},
1013
render (h, { props, data, children }) {
1114
return h(

src/components/Button/CButtonToolbar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
mergeData(data, {
1313
class: [
1414
'c-btn-toolbar',
15-
props.justify ? 'c-justify-content-between' : ''
15+
{ 'c-justify-content-between': props.justify }
1616
],
1717
attrs: {
1818
role: 'toolbar'

src/components/Callout/CCallout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
export default {
99
name: 'CCallout',
1010
props: {
11-
variant: String,
11+
variant: String
1212
}
1313
}
1414
</script>

src/components/Card/CCard.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import CCardBody from './CCardBody'
66
import CCardFooter from './CCardFooter'
77
88
const props = Object.assign(
9-
sharedCardProps.props,
9+
sharedCardProps,
1010
{
1111
headerHtml: String,
1212
bodyHtml: String,
@@ -23,17 +23,19 @@ export default {
2323
let body = slots().default
2424
let footer = h(false)
2525
26-
if (props.headerHtml)
26+
if (props.headerHtml) {
2727
header = h(CCardHeader, { domProps: { innerHTML: props.headerHtml }})
28+
}
2829
29-
if (body === undefined && props.bodyHtml)
30+
if (body === undefined && props.bodyHtml) {
3031
body = h(CCardBody, { domProps: { innerHTML: props.bodyHtml }})
31-
else if (props.bodyWrapper)
32+
} else if (props.bodyWrapper) {
3233
body = h(CCardBody, body)
34+
}
3335
34-
35-
if (props.footerHtml)
36+
if (props.footerHtml) {
3637
footer = h(CCardFooter, { domProps: { innerHTML: props.footerHtml }})
38+
}
3739
3840
return h(
3941
props.tag || 'div',

src/components/Card/CCardBody.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mergeData } from 'vue-functional-data-merge'
33
import sharedCardProps from './sharedCardProps'
44
55
export const props = Object.assign(
6-
sharedCardProps.props,
6+
sharedCardProps,
77
{
88
titleHtml: String,
99
titleTag: {
@@ -45,7 +45,7 @@ export default {
4545
4646
if (props.bodyHtml && cardContent === undefined) {
4747
cardContent = h(
48-
'div',
48+
props.tag || 'div',
4949
{ domProps: { innerHTML: props.bodyHtml}}
5050
)
5151
}

src/components/Card/CCardFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mergeData } from 'vue-functional-data-merge'
33
import sharedCardProps from './sharedCardProps'
44
55
export const props = Object.assign(
6-
sharedCardProps.props,
6+
sharedCardProps,
77
{
88
footerHtml: String,
99
}

src/components/Card/CCardHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mergeData } from 'vue-functional-data-merge'
33
import sharedCardProps from './sharedCardProps'
44
55
export const props = Object.assign(
6-
sharedCardProps.props,
6+
sharedCardProps,
77
{
88
headerHtml: String
99
}
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
export default {
2-
props: {
3-
tag: String,
4-
variant: String,
5-
borderVariant: String,
6-
textVariant: String,
7-
align: {
8-
type: String,
9-
validator: val => ['left', 'center', 'right'].includes(val)
10-
}
2+
tag: String,
3+
variant: String,
4+
borderVariant: String,
5+
textVariant: String,
6+
align: {
7+
type: String,
8+
validator: val => ['left', 'center', 'right'].includes(val)
119
}
1210
}

src/components/Carousel/CCarousel.vue

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
<slot></slot>
1313
</div>
1414
<template v-if="arrows">
15-
<slot name="arrows">
16-
<a class="c-carousel-control-prev" @click="previousItem">
17-
<span class="c-carousel-control-prev-icon"></span>
18-
<span class="sr-only">Previous</span>
19-
</a>
20-
<a class="c-carousel-control-next" @click="nextItem">
21-
<span class="c-carousel-control-next-icon"></span>
22-
<span class="sr-only">Next</span>
23-
</a>
24-
</slot>
15+
<a class="c-carousel-control-prev" @click="previousItem">
16+
<span class="c-carousel-control-prev-icon"></span>
17+
<span class="sr-only">Previous</span>
18+
</a>
19+
<a class="c-carousel-control-next" @click="nextItem">
20+
<span class="c-carousel-control-next-icon"></span>
21+
<span class="sr-only">Next</span>
22+
</a>
2523
</template>
24+
<slot name="navigation"></slot>
2625
</div>
2726
</template>
2827

0 commit comments

Comments
 (0)