UNPKG

vuestic-ui

Version:
1 lines 2.35 kB
{"version":3,"file":"useVaRatingColors.mjs","sources":["../../../../../../src/components/va-rating/hooks/useVaRatingColors.ts"],"sourcesContent":["import { computed, ExtractPropTypes } from 'vue'\n\nimport { useColors } from '../../../composables'\nimport { RatingValue } from '../types'\n\nexport const useVaRatingColorsProps = {\n unselectedColor: { type: String },\n color: { type: String, default: 'primary' },\n modelValue: { type: Number },\n}\n\nexport const useVaRatingColors = (props: ExtractPropTypes<typeof useVaRatingColorsProps>) => {\n const { getColor, getFocusColor, getTextColor } = useColors()\n\n const computedColor = computed(() => getColor(props.color))\n\n const backgroundColor = computed(() => {\n if (props.unselectedColor) { return getColor(props.unselectedColor) }\n\n return getFocusColor(getColor(props.color))\n })\n\n const backgroundComputed = computed(() => {\n if (props.modelValue === RatingValue.HALF) {\n return `linear-gradient(90deg, ${computedColor.value} 50%, ${backgroundColor.value} 50%`\n }\n\n if (props.modelValue === RatingValue.EMPTY) {\n return backgroundColor.value\n }\n\n return computedColor.value\n })\n\n const textColorComputed = computed(() => {\n if (props.modelValue === RatingValue.FULL) {\n return getColor(getTextColor(computedColor.value))\n }\n\n return getColor(getTextColor(backgroundColor.value))\n })\n\n return {\n computedColor,\n backgroundComputed,\n textColorComputed,\n }\n}\n"],"names":[],"mappings":";;;AAKO,MAAM,yBAAyB;AAAA,EACpC,iBAAiB,EAAE,MAAM,OAAO;AAAA,EAChC,OAAO,EAAE,MAAM,QAAQ,SAAS,UAAU;AAAA,EAC1C,YAAY,EAAE,MAAM,OAAO;AAC7B;AAEa,MAAA,oBAAoB,CAAC,UAA2D;AAC3F,QAAM,EAAE,UAAU,eAAe,iBAAiB,UAAU;AAE5D,QAAM,gBAAgB,SAAS,MAAM,SAAS,MAAM,KAAK,CAAC;AAEpD,QAAA,kBAAkB,SAAS,MAAM;AACrC,QAAI,MAAM,iBAAiB;AAAS,aAAA,SAAS,MAAM,eAAe;AAAA,IAAE;AAEpE,WAAO,cAAc,SAAS,MAAM,KAAK,CAAC;AAAA,EAAA,CAC3C;AAEK,QAAA,qBAAqB,SAAS,MAAM;AACpC,QAAA,MAAM,eAAe,YAAY,MAAM;AACzC,aAAO,0BAA0B,cAAc,KAAK,SAAS,gBAAgB,KAAK;AAAA,IACpF;AAEI,QAAA,MAAM,eAAe,YAAY,OAAO;AAC1C,aAAO,gBAAgB;AAAA,IACzB;AAEA,WAAO,cAAc;AAAA,EAAA,CACtB;AAEK,QAAA,oBAAoB,SAAS,MAAM;AACnC,QAAA,MAAM,eAAe,YAAY,MAAM;AACzC,aAAO,SAAS,aAAa,cAAc,KAAK,CAAC;AAAA,IACnD;AAEA,WAAO,SAAS,aAAa,gBAAgB,KAAK,CAAC;AAAA,EAAA,CACpD;AAEM,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}