-
Notifications
You must be signed in to change notification settings - Fork 798
feat(Rating): new component #4253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3
Are you sure you want to change the base?
Conversation
@benjamincanac I'm wondering if this component shouldn't be implemented in RekaUI first as it needs a11y support and I'm not sure we want to manage it ourselves in NuxtUI, what are your thoughts? |
Yes I agree, this is why I was holding back on this π¬ |
Alright, I will bring it upstream: unovue/reka-ui#1966 could you please add the reka-ui label to the issue? |
Here is some code I am using currently to do this. There is possibly no need to build it into reka as the RadioGroup component seems to do the job. @J-Michalek <script setup lang=ts>
import type { ButtonGroupProps } from '@nuxt/ui/components/ButtonGroup.vue'
withDefaults(defineProps<{ length?: number, readonly?: boolean, size?: ButtonGroupProps['size'] }>(), { length: 5 })
const model = defineModel<number>({ default: undefined })
const hoverIndex = ref<number>()
</script>
<template>
<radio-group-root v-model="model" :disabled="readonly" as-child @mouseleave="hoverIndex = undefined">
<u-button-group :size>
<radio-group-item v-for="i in length" :key="i" :value="i" as-child @mouseenter="hoverIndex = i">
<u-button :disabled="readonly" variant="ghost" class="p-[0.25em] transform-origin-c transition-all transition-ease-in-out hover:scale-120" :icon="(hoverIndex === undefined ? (i <= model) : (!readonly && i <= hoverIndex)) ? 'material-symbols:star-rounded' : 'material-symbols:star-outline-rounded'" :color="(i <= model) || (hoverIndex && !readonly && i <= hoverIndex) ? 'primary' : 'neutral'" />
</radio-group-item>
</u-button-group>
</radio-group-root>
</template>
|
I kinda like the idea, but I still think that we should bring it upstream. There will be some specific logic such as the precision of the rating i.e. 1.5, 2.5, 4.75, which I think we don't really want to mantain in NuxtUI, also bringing it upstream will make it accessible to more developers as it won't be locked in NuxtUI. So far I was implementing it from scratch but using the radio group component seems like a good idea as all the a11y is already handled. |
π Linked issue
Resolves: #505
β Type of change
π Description
I've added a new component for rating.
π Checklist