vuestic-ui
Version:
Vue 3 UI Framework
44 lines (43 loc) • 1.4 kB
JavaScript
import { computed } from "vue";
import { R as RatingValue } from "../types.js";
import { u as useColors } from "../../../composables/useColors.js";
const useVaRatingColorsProps = {
unselectedColor: { type: String },
color: { type: String, default: "primary" },
modelValue: { type: Number }
};
const useVaRatingColors = (props) => {
const { getColor, getFocusColor, getTextColor } = useColors();
const computedColor = computed(() => getColor(props.color));
const backgroundColor = computed(() => {
if (props.unselectedColor) {
return getColor(props.unselectedColor);
}
return getFocusColor(getColor(props.color));
});
const backgroundComputed = computed(() => {
if (props.modelValue === RatingValue.HALF) {
return `linear-gradient(90deg, ${computedColor.value} 50%, ${backgroundColor.value} 50%`;
}
if (props.modelValue === RatingValue.EMPTY) {
return backgroundColor.value;
}
return computedColor.value;
});
const textColorComputed = computed(() => {
if (props.modelValue === RatingValue.FULL) {
return getColor(getTextColor(computedColor.value));
}
return getColor(getTextColor(backgroundColor.value));
});
return {
computedColor,
backgroundComputed,
textColorComputed
};
};
export {
useVaRatingColors as a,
useVaRatingColorsProps as u
};
//# sourceMappingURL=useVaRatingColors.js.map