Skip to content

Commit 884d31d

Browse files
authored
Merge pull request #728 from VividLemon/master
chore: update pnpm feat: BPlaceholder finalizations
2 parents 7110ec9 + ad9fe6a commit 884d31d

File tree

13 files changed

+1721
-483
lines changed

13 files changed

+1721
-483
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
"npm": ">=7.0.0",
2727
"node": ">=14.0.0"
2828
},
29-
"packageManager": "pnpm@7.12.2"
29+
"packageManager": "pnpm@7.13.0"
3030
}

packages/bootstrap-vue-3/src/components/BCard/BCard.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<template>
22
<component :is="tag" class="card" :class="classes">
3-
<b-card-img v-if="imgSrc && !imgBottomBoolean" v-bind="imgAttr" />
3+
<slot v-if="!imgBottomBoolean" name="img">
4+
<b-card-img v-if="imgSrc" v-bind="imgAttr" />
5+
</slot>
46
<b-card-header
57
v-if="header || $slots.header || headerHtml"
68
v-bind="headerAttrs"
@@ -27,7 +29,9 @@
2729
{{ footer }}
2830
</slot>
2931
</b-card-footer>
30-
<b-card-img v-if="imgSrc && imgBottomBoolean" v-bind="imgAttr" />
32+
<slot v-if="imgBottomBoolean" name="img">
33+
<b-card-img v-if="imgSrc" v-bind="imgAttr" />
34+
</slot>
3135
</component>
3236
</template>
3337

packages/bootstrap-vue-3/src/components/BCard/BCardImg.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ import {computed, toRef} from 'vue'
1111
1212
interface BCardImgProps {
1313
alt?: string
14+
blank?: Booleanish
15+
blankColor?: string
1416
bottom?: Booleanish
15-
end?: Booleanish
17+
lazy?: Booleanish
1618
height?: number | string
1719
left?: Booleanish
20+
start?: Booleanish
1821
right?: Booleanish
22+
end?: Booleanish
23+
sizes?: string | Array<string>
1924
src?: string
20-
lazy?: Booleanish
21-
start?: Booleanish
25+
srcset?: string | Array<string>
2226
top?: Booleanish
2327
width?: number | string
24-
blank?: Booleanish
25-
blankColor?: string
26-
sizes?: string | Array<string>
27-
srcset?: string | Array<string>
2828
}
2929
3030
const props = withDefaults(defineProps<BCardImgProps>(), {

packages/bootstrap-vue-3/src/components/BCard/card.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,37 @@ describe('card', () => {
9898
expect(wrapper.classes()).not.toContain('flex-row-reverse')
9999
})
100100

101+
it('renders img slot', () => {
102+
const wrapper = mount(BCard, {
103+
slots: {img: 'foobar'},
104+
})
105+
expect(wrapper.text()).toBe('foobar')
106+
})
107+
108+
it('renders img in correct order when not prop imgBottom', () => {
109+
const wrapper = mount(BCard, {
110+
props: {header: 'header', bodyText: 'bodyText', footer: 'footer', imgBottom: false},
111+
slots: {img: 'img'},
112+
})
113+
expect(wrapper.text()).toBe('imgheaderbodyTextfooter')
114+
})
115+
116+
it('does not render b-card-img when slot img', () => {
117+
const wrapper = mount(BCard, {
118+
slots: {img: 'img'},
119+
})
120+
const $cardimg = wrapper.findComponent(BCardImg)
121+
expect($cardimg.exists()).toBe(false)
122+
})
123+
124+
it('renders img in correct order when prop imgBottom', () => {
125+
const wrapper = mount(BCard, {
126+
props: {header: 'header', bodyText: 'bodyText', footer: 'footer', imgBottom: true},
127+
slots: {img: 'img'},
128+
})
129+
expect(wrapper.text()).toBe('headerbodyTextfooterimg')
130+
})
131+
101132
it('does not have child BCardImg by default', () => {
102133
const wrapper = mount(BCard)
103134
const $img = wrapper.findComponent(BCardImg)

packages/bootstrap-vue-3/src/components/BPlaceholder/BPlaceholder.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
<script setup lang="ts">
66
import {computed, StyleValue} from 'vue'
7-
import {ColorVariant} from '../../types'
7+
import {ColorVariant, PlaceholderAnimation, PlaceholderSize} from '../../types'
88
99
interface Props {
1010
tag?: string
1111
width?: string | number
1212
cols?: string | number
1313
variant?: ColorVariant
14-
size?: 'xs' | 'sm' | 'lg'
15-
animation?: 'glow' | 'wave'
14+
size?: PlaceholderSize
15+
animation?: PlaceholderAnimation
1616
}
1717
1818
const props = withDefaults(defineProps<Props>(), {

packages/bootstrap-vue-3/src/components/BPlaceholder/BPlaceholderCard.vue

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<template>
2-
<b-card>
3-
<!-- TODO add possible blank Img? -->
4-
<!-- Problem is BCard doesn't have an option for blank imgs -->
2+
<b-card :img-bottom="imgBottomBoolean">
3+
<template v-if="!noImgBoolean" #img>
4+
<slot name="img">
5+
<b-card-img v-bind="imgAttrs" />
6+
</slot>
7+
</template>
8+
59
<template v-if="!noHeaderBoolean" #header>
610
<slot name="header">
711
<b-placeholder v-bind="headerAttrs" />
812
</slot>
913
</template>
1014
<slot>
11-
<div>
12-
<b-placeholder cols="7" />
13-
<b-placeholder cols="4" />
14-
<b-placeholder cols="4" />
15-
<b-placeholder cols="6" />
16-
<b-placeholder cols="8" />
17-
</div>
15+
<b-placeholder cols="7" />
16+
<b-placeholder cols="4" />
17+
<b-placeholder cols="4" />
18+
<b-placeholder cols="6" />
19+
<b-placeholder cols="8" />
1820
</slot>
1921
<template v-if="!noFooterBoolean" #footer>
2022
<slot name="footer">
@@ -26,28 +28,32 @@
2628

2729
<script setup lang="ts">
2830
import BCard from '../BCard/BCard.vue'
31+
import BCardImg from '../BCard/BCardImg.vue'
2932
import BPlaceholder from './BPlaceholder.vue'
30-
import {Booleanish, ColorVariant} from '../../types'
33+
import {Booleanish, ColorVariant, PlaceholderAnimation, PlaceholderSize} from '../../types'
3134
import {computed, toRef} from 'vue'
3235
import {useBooleanish} from '../../composables'
3336
3437
interface Props {
3538
noHeader?: Booleanish
3639
headerWidth?: string | number
3740
headerVariant?: ColorVariant
38-
headerAnimation?: 'glow' | 'wave'
39-
headerSize?: 'xs' | 'sm' | 'lg'
40-
41+
headerAnimation?: PlaceholderAnimation
42+
headerSize?: PlaceholderSize
4143
noFooter?: Booleanish
4244
footerWidth?: string | number
4345
footerVariant?: ColorVariant
44-
footerAnimation?: 'glow' | 'wave'
45-
footerSize?: 'xs' | 'sm' | 'lg'
46-
47-
animation?: 'glow' | 'wave'
48-
size?: 'xs' | 'sm' | 'lg'
46+
footerAnimation?: PlaceholderAnimation
47+
footerSize?: PlaceholderSize
48+
animation?: PlaceholderAnimation
49+
size?: PlaceholderSize
4950
variant?: ColorVariant
5051
noButton?: Booleanish
52+
imgBottom?: Booleanish
53+
imgSrc?: string
54+
imgBlankColor?: string
55+
imgHeight?: string | number
56+
noImg?: Booleanish
5157
}
5258
5359
const props = withDefaults(defineProps<Props>(), {
@@ -56,11 +62,17 @@ const props = withDefaults(defineProps<Props>(), {
5662
footerWidth: 100,
5763
noHeader: false,
5864
noFooter: false,
65+
imgBlankColor: '#868e96',
66+
imgHeight: 100,
67+
imgBottom: false,
68+
noImg: false,
5969
})
6070
6171
const noButtonBoolean = useBooleanish(toRef(props, 'noButton'))
6272
const noHeaderBoolean = useBooleanish(toRef(props, 'noHeader'))
6373
const noFooterBoolean = useBooleanish(toRef(props, 'noFooter'))
74+
const noImgBoolean = useBooleanish(toRef(props, 'noImg'))
75+
const imgBottomBoolean = useBooleanish(toRef(props, 'imgBottom'))
6476
6577
const headerAttrs = computed(() => ({
6678
width: props.headerWidth,
@@ -83,4 +95,13 @@ const footerAttrs = computed(() => ({
8395
size: props.footerSize,
8496
variant: props.footerVariant,
8597
}))
98+
99+
const imgAttrs = computed(() => ({
100+
blank: !props.imgSrc ? true : false,
101+
blankColor: props.imgBlankColor,
102+
height: !props.imgSrc ? props.imgHeight : undefined,
103+
src: props.imgSrc,
104+
top: !imgBottomBoolean.value,
105+
bottom: imgBottomBoolean.value,
106+
}))
86107
</script>

packages/bootstrap-vue-3/src/components/BPlaceholder/BPlaceholderTable.vue

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,93 @@
11
<template>
2-
<b-table-simple v-bind="tableProps">
3-
<thead v-if="!hideHeaderBoolean">
4-
<tr>
5-
<th v-for="(_, i) in headerColumns ?? columns" :key="i">
6-
<b-placeholder v-bind="placeholderAttrs" :width="headerWidth" />
7-
</th>
8-
</tr>
9-
</thead>
10-
<tbody>
11-
<tr v-for="(_, j) in rows" :key="j">
12-
<td v-for="(__, k) in columns" :key="k">
13-
<b-placeholder v-bind="placeholderAttrs" :width="cellWidth" />
14-
</td>
15-
</tr>
16-
</tbody>
17-
<tfoot v-if="showFooterBoolean">
18-
<tr>
19-
<th v-for="(_, l) in footerColumns ?? columns" :key="l">
20-
<b-placeholder v-bind="placeholderAttrs" :width="footerWidth" />
21-
</th>
22-
</tr>
23-
</tfoot>
2+
<b-table-simple>
3+
<slot name="thead">
4+
<thead v-if="!hideHeaderBoolean">
5+
<tr>
6+
<th v-for="(_, i) in headerColumns ?? columns" :key="i">
7+
<b-placeholder v-bind="headerAttrs" />
8+
</th>
9+
</tr>
10+
</thead>
11+
</slot>
12+
<slot>
13+
<tbody>
14+
<tr v-for="(_, j) in rows" :key="j">
15+
<td v-for="(__, k) in columns" :key="k">
16+
<b-placeholder v-bind="placeholderAttrs" />
17+
</td>
18+
</tr>
19+
</tbody>
20+
</slot>
21+
<slot name="tfoot">
22+
<tfoot v-if="showFooterBoolean">
23+
<tr>
24+
<th v-for="(_, l) in footerColumns ?? columns" :key="l">
25+
<b-placeholder v-bind="footerAttrs" />
26+
</th>
27+
</tr>
28+
</tfoot>
29+
</slot>
2430
</b-table-simple>
2531
</template>
2632

2733
<script setup lang="ts">
2834
// import type {BSkeletonTableProps} from '../../types/components'
2935
import {computed, toRef} from 'vue'
30-
import type {Booleanish, ColorVariant} from '../../types'
36+
import type {Booleanish, ColorVariant, PlaceholderAnimation, PlaceholderSize} from '../../types'
3137
import {useBooleanish} from '../../composables'
3238
import BTableSimple from '../BTable/BTableSimple.vue'
3339
import BPlaceholder from './BPlaceholder.vue'
3440
3541
interface BSkeletonTableProps {
36-
animation?: 'wave' | 'glow'
37-
columns?: number
38-
hideHeader?: Booleanish
3942
rows?: number
40-
showFooter?: Booleanish
41-
variant?: ColorVariant
42-
size?: 'xs' | 'sm' | 'lg'
43-
tableProps?: Record<string, unknown>
44-
footerWidth?: string | number
45-
headerWidth?: string | number
43+
columns?: number
4644
cellWidth?: string | number
45+
size?: PlaceholderSize
46+
animation?: PlaceholderAnimation
47+
variant?: ColorVariant
4748
headerColumns?: number
49+
hideHeader?: Booleanish
50+
headerCellWidth?: string | number
51+
headerSize?: PlaceholderSize
52+
headerAnimation?: PlaceholderAnimation
53+
headerVariant?: ColorVariant
4854
footerColumns?: number
55+
showFooter?: Booleanish
56+
footerCellWidth?: string | number
57+
footerSize?: PlaceholderSize
58+
footerAnimation?: PlaceholderAnimation
59+
footerVariant?: ColorVariant
4960
}
5061
5162
const props = withDefaults(defineProps<BSkeletonTableProps>(), {
5263
columns: 5,
53-
hideHeader: false,
5464
rows: 3,
55-
showFooter: false,
5665
cellWidth: 100,
57-
footerWidth: 100,
58-
headerWidth: 100,
66+
showFooter: false,
67+
footerCellWidth: 100,
68+
hideHeader: false,
69+
headerCellWidth: 100,
5970
})
6071
6172
const placeholderAttrs = computed(() => ({
6273
size: props.size,
6374
variant: props.variant,
6475
animation: props.animation,
76+
width: props.cellWidth,
77+
}))
78+
79+
const headerAttrs = computed(() => ({
80+
size: props.headerSize,
81+
variant: props.headerVariant,
82+
animation: props.headerAnimation,
83+
width: props.headerCellWidth,
84+
}))
85+
86+
const footerAttrs = computed(() => ({
87+
size: props.footerSize,
88+
variant: props.footerVariant,
89+
animation: props.footerAnimation,
90+
width: props.footerCellWidth,
6591
}))
6692
6793
const hideHeaderBoolean = useBooleanish(toRef(props, 'hideHeader'))

0 commit comments

Comments
 (0)