Skip to content

Commit

Permalink
rework indicator: use bs classes; make size a prop
Browse files Browse the repository at this point in the history
  • Loading branch information
v1r0x authored Nov 25, 2024
1 parent b771fe4 commit c1d8a08
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions resources/js/components/forms/indicators/DirtyStateIndicator.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div
class="dity-state-indicator"
:style="style"
:class="styling.classes"
:style="styling.style"
/>
</template>

Expand All @@ -14,31 +14,42 @@
type: Object,
required: true,
},
}, setup(props) {
const isDirty = computed(() => {
size: {
type: Number,
required: false,
default: 10,
},
},
setup(props) {
const isDirty = computed(_ => {
return props?.value?.meta?.dirty;
});
const isUnset = computed(() => {
const isUnset = computed(_ => {
return props?.value?.meta?.dirty == null;
});
const size = 10;
const style = computed(() => {
const styling = computed(_ => {
const classes = ['rounded-circle'];
if(isUnset.value) {
classes.push('bg-danger');
} else if(isDirty.value) {
classes.push('bg-warning');
} else {
classes.push('bg-success');
}
return {
width: `${size}px`,
height: `${size}px`,
borderRadius: '50%',
backgroundColor: isUnset.value ? 'red' : isDirty.value ? 'orange' : 'green',
style: {
width: `${props.size}px`,
height: `${props.size}px`,
},
classes: classes,
};
});
return {
style
styling,
};
},
};
</script>
</script>

0 comments on commit c1d8a08

Please sign in to comment.