Skip to content

Commit

Permalink
refactor: progress bar props exact
Browse files Browse the repository at this point in the history
  • Loading branch information
wxsms committed Dec 10, 2021
1 parent af5fd78 commit c7267b9
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 61 deletions.
4 changes: 2 additions & 2 deletions src/components/button/Btn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ const classes = computed(() => ({
active: props.inputType ? isInputActive.value : props.active,
disabled: props.disabled,
'btn-block': props.block,
[`btn-${props.type}`]: Boolean(props.type),
[`btn-${props.size}`]: Boolean(props.size),
[`btn-${props.type}`]: !!props.type,
[`btn-${props.size}`]: !!props.size,
}));
function onClick(e) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/messagebox/MessageBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const dirty = ref(false);
const modal = ref(null);
const closeOnBackdropClick = computed(() =>
isExist(props.backdrop) ? Boolean(props.backdrop) : props.type !== TYPES.ALERT
isExist(props.backdrop) ? !!props.backdrop : props.type !== TYPES.ALERT
);
const inputError = computed(() => props.validator(input.value));
const inputNotValid = computed(() => dirty.value && inputError.value);
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
computed: {
modalSizeClass() {
return {
[`modal-${this.size}`]: Boolean(this.size),
[`modal-${this.size}`]: !!this.size,
};
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/pagination/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ const emit = defineEmits(['update:modelValue', 'change']);
const sliceStart = ref(0);
const navClasses = computed(() => ({
[`text-${props.align}`]: Boolean(props.align),
[`text-${props.align}`]: !!props.align,
}));
const classes = computed(() => ({
[`pagination-${props.size}`]: Boolean(props.size),
[`pagination-${props.size}`]: !!props.size,
}));
const sliceArray = computed(() =>
range(props.totalPage).slice(
Expand Down
28 changes: 2 additions & 26 deletions src/components/progressbar/ProgressBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,9 @@
</template>

<script setup>
import ProgressBarStack from './ProgressBarStack.vue';
import { progressBarProps } from '../../props/progress-bar.props';
defineProps({
modelValue: {
type: Number,
validator(value) {
return value >= 0 && value <= 100;
},
default: 0,
},
labelText: { type: String, default: undefined },
type: { type: String, default: undefined },
label: {
type: Boolean,
default: false,
},
minWidth: {
type: Boolean,
default: false,
},
striped: {
type: Boolean,
default: false,
},
active: {
type: Boolean,
default: false,
},
...progressBarProps,
});
</script>
30 changes: 4 additions & 26 deletions src/components/progressbar/ProgressBarStack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'progress-bar': true,
'progress-bar-striped': striped,
active: striped && active,
[`progress-bar-${type}`]: Boolean(type),
[`progress-bar-${type}`]: !!type,
}"
:style="{
minWidth: minWidth ? '2em' : null,
Expand All @@ -20,31 +20,9 @@
</template>

<script setup>
import { progressBarProps } from '../../props/progress-bar.props';
defineProps({
modelValue: {
type: Number,
required: true,
validator(value) {
return value >= 0 && value <= 100;
},
},
labelText: { type: String, default: undefined },
type: { type: String, default: undefined },
label: {
type: Boolean,
default: false,
},
minWidth: {
type: Boolean,
default: false,
},
striped: {
type: Boolean,
default: false,
},
active: {
type: Boolean,
default: false,
},
...progressBarProps,
});
</script>
6 changes: 3 additions & 3 deletions src/components/typeahead/Typeahead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ function fetchItems(value, debounce) {
open.value = false;
} else if (props.data) {
prepareItems(props.data);
open.value = hasEmptySlot() || Boolean(items.value.length);
open.value = hasEmptySlot() || !!items.value.length;
} else if (props.asyncSrc) {
timeoutID = setTimeout(() => {
emit('loading');
request(props.asyncSrc + encodeURIComponent(value))
.then((data) => {
if (inputEl.value.matches(':focus')) {
prepareItems(props.asyncKey ? data[props.asyncKey] : data, true);
open.value = hasEmptySlot() || Boolean(items.value.length);
open.value = hasEmptySlot() || !!items.value.length;
}
emit('loaded');
})
Expand All @@ -233,7 +233,7 @@ function fetchItems(value, debounce) {
const cb = (data) => {
if (inputEl.value.matches(':focus')) {
prepareItems(data, true);
open.value = hasEmptySlot() || Boolean(items.value.length);
open.value = hasEmptySlot() || !!items.value.length;
}
emit('loaded');
};
Expand Down
15 changes: 15 additions & 0 deletions src/props/progress-bar.props.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const progressBarProps = {
modelValue: {
type: Number,
required: true,
validator(value) {
return value >= 0 && value <= 100;
},
},
labelText: { type: String, default: undefined },
type: { type: String, default: undefined },
label: { type: Boolean, default: false },
minWidth: { type: Boolean, default: false },
striped: { type: Boolean, default: false },
active: { type: Boolean, default: false },
};

0 comments on commit c7267b9

Please sign in to comment.