Skip to content

Commit f7674eb

Browse files
committed
refactor: booleanish resolver name change
1 parent 83785cc commit f7674eb

File tree

6 files changed

+53
-48
lines changed

6 files changed

+53
-48
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ const props = withDefaults(defineProps<BAccordionProps>(), {
2525
})
2626
2727
const computedId = useId(props.id, 'accordion')
28-
const booleanFlush = computed(() => resolveBooleanish(props.flush))
29-
const booleanFree = computed(() => resolveBooleanish(props.free))
28+
29+
const flushBoolean = computed(() => resolveBooleanish(props.flush))
30+
const freeBoolean = computed(() => resolveBooleanish(props.free))
3031
3132
const classes = computed(() => ({
32-
'accordion-flush': booleanFlush.value,
33+
'accordion-flush': flushBoolean.value,
3334
}))
3435
35-
if (!booleanFree.value) {
36+
if (!freeBoolean.value) {
3637
provide(injectionKey, computedId.value.toString())
3738
}
3839
</script>

packages/bootstrap-vue-3/src/components/BAccordion/BAccordionItem.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<button
55
v-b-toggle:[computedId]
66
class="accordion-button"
7-
:class="{collapsed: !visible}"
7+
:class="{collapsed: !visibleBoolean}"
88
type="button"
9-
:aria-expanded="visible ? 'true' : 'false'"
9+
:aria-expanded="visibleBoolean ? 'true' : 'false'"
1010
:aria-controls="computedId"
1111
>
1212
<slot name="title">
@@ -17,7 +17,7 @@
1717
<b-collapse
1818
:id="computedId"
1919
class="accordion-collapse"
20-
:visible="booleanVisible"
20+
:visible="visibleBoolean"
2121
:accordion="parent"
2222
:aria-labelledby="`heading${computedId}`"
2323
>
@@ -46,7 +46,7 @@ interface BAccordionItemProps {
4646
4747
const props = withDefaults(defineProps<BAccordionItemProps>(), {visible: false})
4848
49-
const booleanVisible = computed(() => resolveBooleanish(props.visible))
49+
const visibleBoolean = computed(() => resolveBooleanish(props.visible))
5050
5151
const computedId = useId(props.id, 'accordion_item')
5252
const parent = inject(injectionKey, '')

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ const props = withDefaults(defineProps<BAvatarProps>(), {
6969
variant: 'secondary',
7070
})
7171
72-
const booleanBadgeLeft = computed(() => resolveBooleanish(props.badgeLeft))
73-
const booleanBadgeTop = computed(() => resolveBooleanish(props.badgeTop))
74-
const booleanButton = computed(() => resolveBooleanish(props.button))
75-
const booleanDisabled = computed(() => resolveBooleanish(props.disabled))
76-
const booleanSquare = computed(() => resolveBooleanish(props.square))
72+
const badgeLeftBoolean = computed(() => resolveBooleanish(props.badgeLeft))
73+
const badgeTopBoolean = computed(() => resolveBooleanish(props.badgeTop))
74+
const buttonBoolean = computed(() => resolveBooleanish(props.button))
75+
const disabledBoolean = computed(() => resolveBooleanish(props.disabled))
76+
const squareBoolean = computed(() => resolveBooleanish(props.square))
7777
7878
interface BAvatarEmits {
7979
(e: 'click', value: MouseEvent): void
@@ -118,7 +118,7 @@ const computedRounded = computed<string | boolean>(() =>
118118
119119
const attrs = computed(() => ({
120120
'aria-label': props.ariaLabel || null,
121-
'disabled': booleanDisabled.value || null,
121+
'disabled': disabledBoolean.value || null,
122122
}))
123123
124124
const badgeClasses = computed(() => ({
@@ -134,18 +134,18 @@ const badgeTextClasses = computed<string>(() => {
134134
const classes = computed(() => ({
135135
[`b-avatar-${props.size}`]: props.size && SIZES.indexOf(computeSize(props.size)) !== -1,
136136
[`bg-${computedVariant.value}`]: computedVariant.value,
137-
[`badge`]: !booleanButton.value && computedVariant.value && hasDefaultSlot.value,
137+
[`badge`]: !buttonBoolean.value && computedVariant.value && hasDefaultSlot.value,
138138
rounded: computedRounded.value === '' || computedRounded.value === true,
139-
[`rounded-circle`]: !booleanSquare.value && computedRounded.value === 'circle',
140-
[`rounded-0`]: booleanSquare.value || computedRounded.value === '0',
141-
[`rounded-1`]: !booleanSquare.value && computedRounded.value === 'sm',
142-
[`rounded-3`]: !booleanSquare.value && computedRounded.value === 'lg',
143-
[`rounded-top`]: !booleanSquare.value && computedRounded.value === 'top',
144-
[`rounded-bottom`]: !booleanSquare.value && computedRounded.value === 'bottom',
145-
[`rounded-start`]: !booleanSquare.value && computedRounded.value === 'left',
146-
[`rounded-end`]: !booleanSquare.value && computedRounded.value === 'right',
147-
btn: booleanButton.value,
148-
[`btn-${computedVariant.value}`]: booleanButton.value ? computedVariant.value : null,
139+
[`rounded-circle`]: !squareBoolean.value && computedRounded.value === 'circle',
140+
[`rounded-0`]: squareBoolean.value || computedRounded.value === '0',
141+
[`rounded-1`]: !squareBoolean.value && computedRounded.value === 'sm',
142+
[`rounded-3`]: !squareBoolean.value && computedRounded.value === 'lg',
143+
[`rounded-top`]: !squareBoolean.value && computedRounded.value === 'top',
144+
[`rounded-bottom`]: !squareBoolean.value && computedRounded.value === 'bottom',
145+
[`rounded-start`]: !squareBoolean.value && computedRounded.value === 'left',
146+
[`rounded-end`]: !squareBoolean.value && computedRounded.value === 'right',
147+
btn: buttonBoolean.value,
148+
[`btn-${computedVariant.value}`]: buttonBoolean.value ? computedVariant.value : null,
149149
}))
150150
151151
const textClasses = computed<string>(() => {
@@ -161,10 +161,10 @@ const badgeStyle = computed<StyleValue>(() => {
161161
: ''
162162
return {
163163
fontSize: fontSize || '',
164-
top: booleanBadgeTop.value ? offset : '',
165-
bottom: booleanBadgeTop.value ? '' : offset,
166-
left: booleanBadgeLeft.value ? offset : '',
167-
right: booleanBadgeLeft.value ? '' : offset,
164+
top: badgeTopBoolean.value ? offset : '',
165+
bottom: badgeTopBoolean.value ? '' : offset,
166+
left: badgeLeftBoolean.value ? offset : '',
167+
right: badgeLeftBoolean.value ? '' : offset,
168168
}
169169
})
170170
@@ -184,15 +184,15 @@ const marginStyle = computed(() => {
184184
return value ? {marginLeft: value, marginRight: value} : {}
185185
})
186186
187-
const tag = computed<string>(() => (booleanButton.value ? props.buttonType : 'span'))
187+
const tag = computed<string>(() => (buttonBoolean.value ? props.buttonType : 'span'))
188188
const tagStyle = computed(() => ({
189189
...marginStyle.value,
190190
width: computedSize.value,
191191
height: computedSize.value,
192192
}))
193193
194194
const clicked = (e: MouseEvent): void => {
195-
if (!booleanDisabled.value && booleanButton.value) emit('click', e)
195+
if (!disabledBoolean.value && buttonBoolean.value) emit('click', e)
196196
}
197197
const onImgError = (e: Event): void => emit('img-error', e)
198198
</script>

packages/bootstrap-vue-3/src/components/BAvatar/BAvatarGroup.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const props = withDefaults(defineProps<BAvatarGroupProps>(), {
3131
tag: 'div',
3232
})
3333
34-
const booleanSquare = computed(() => resolveBooleanish(props.square))
34+
const squareBoolean = computed(() => resolveBooleanish(props.square))
3535
3636
const computedSize = computed<string | null>(() => computeSize(props.size))
3737
@@ -51,7 +51,7 @@ const paddingStyle = computed<StyleValue>(() => {
5151
provide<BAvatarGroupParentData>(injectionKey, {
5252
overlapScale,
5353
size: props.size,
54-
square: booleanSquare.value,
54+
square: squareBoolean.value,
5555
rounded: props.rounded,
5656
variant: props.variant,
5757
})

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ export default defineComponent({
2525
const link = computed<boolean>(() => isLink(props))
2626
const computedTag = computed<string>(() => (link.value ? 'b-link' : props.tag))
2727
28-
const booleanPill = computed(() => resolveBooleanish(props.pill))
29-
const booleanTextIndicator = computed(() => resolveBooleanish(props.textIndicator))
30-
const booleanDotIndicator = computed(() => resolveBooleanish(props.dotIndicator))
28+
const pillBoolean = computed(() => resolveBooleanish(props.pill))
29+
const textIndicatorBoolean = computed(() => resolveBooleanish(props.textIndicator))
30+
const dotIndicatorBoolean = computed(() => resolveBooleanish(props.dotIndicator))
3131
3232
const classes = computed(() => ({
3333
[`bg-${props.variant}`]: props.variant,
3434
'active': props.active,
3535
'disabled': props.disabled,
3636
'text-dark': ['warning', 'info', 'light'].includes(props.variant),
37-
'rounded-pill': booleanPill.value,
37+
'rounded-pill': pillBoolean.value,
3838
'position-absolute top-0 start-100 translate-middle':
39-
booleanTextIndicator.value || booleanDotIndicator.value,
40-
'p-2 border border-light rounded-circle': booleanDotIndicator.value,
39+
textIndicatorBoolean.value || dotIndicatorBoolean.value,
40+
'p-2 border border-light rounded-circle': dotIndicatorBoolean.value,
4141
'text-decoration-none': link.value,
4242
}))
4343

packages/bootstrap-vue-3/src/components/BBreadcrumb/BBreadcrumbItem.vue

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,47 @@
66
v-bind="$props"
77
@click="clicked"
88
>
9-
<slot></slot>
9+
<slot />
1010
</component>
1111
</li>
1212
</template>
1313

1414
<script lang="ts">
15-
import {omit} from '../../utils'
16-
import {computed, defineComponent} from 'vue'
15+
import {omit, resolveBooleanish} from '../../utils'
16+
import {computed, defineComponent, PropType} from 'vue'
1717
import {BLINK_PROPS} from '../BLink/BLink.vue'
18+
import type {Booleanish} from '../../types'
1819
1920
export default defineComponent({
2021
props: {
2122
...omit(BLINK_PROPS, ['event', 'routerTag']),
22-
active: {type: Boolean, default: false},
23+
active: {type: Boolean as PropType<Booleanish>, default: false},
2324
ariaCurrent: {type: String, default: 'location'},
24-
disabled: {type: Boolean, default: false},
25+
disabled: {type: Boolean as PropType<Booleanish>, default: false},
2526
text: {type: String, required: false},
2627
},
2728
emits: ['click'],
2829
setup(props, {emit}) {
30+
const activeBoolean = computed(() => resolveBooleanish(props.active))
31+
const disabledBoolean = computed(() => resolveBooleanish(props.disabled))
32+
2933
const liClasses = computed(() => ({
3034
active: props.active,
3135
}))
3236
33-
const computedTag = computed<'span' | 'b-link'>(() => (props.active ? 'span' : 'b-link'))
37+
const computedTag = computed<'span' | 'b-link'>(() => (activeBoolean.value ? 'span' : 'b-link'))
3438
3539
const computedAriaCurrent = computed(() => ({
36-
'aria-current': props.active ? props.ariaCurrent : undefined,
40+
'aria-current': activeBoolean.value ? props.ariaCurrent : undefined,
3741
}))
3842
3943
const clicked = (e: MouseEvent): void => {
40-
if (props.disabled || props.active) {
44+
if (disabledBoolean.value || activeBoolean.value) {
4145
e.preventDefault()
4246
e.stopImmediatePropagation()
4347
return
4448
}
45-
if (!props.disabled) emit('click', e)
49+
if (!disabledBoolean.value) emit('click', e)
4650
}
4751
4852
return {

0 commit comments

Comments
 (0)