diff --git a/docs/components/rating/examples/RatingCountExample.vue b/docs/components/rating/examples/RatingCountExample.vue new file mode 100644 index 0000000..91d051e --- /dev/null +++ b/docs/components/rating/examples/RatingCountExample.vue @@ -0,0 +1,18 @@ + + diff --git a/docs/components/rating/examples/RatingExample.vue b/docs/components/rating/examples/RatingExample.vue index 7da2976..7eab3d4 100644 --- a/docs/components/rating/examples/RatingExample.vue +++ b/docs/components/rating/examples/RatingExample.vue @@ -1,6 +1,6 @@ diff --git a/docs/components/rating/examples/RatingWithTextExample.vue b/docs/components/rating/examples/RatingWithTextExample.vue new file mode 100644 index 0000000..3636cbe --- /dev/null +++ b/docs/components/rating/examples/RatingWithTextExample.vue @@ -0,0 +1,12 @@ + + diff --git a/docs/components/rating/rating.md b/docs/components/rating/rating.md index 98b3a4c..12f83d4 100644 --- a/docs/components/rating/rating.md +++ b/docs/components/rating/rating.md @@ -1,15 +1,78 @@ # Vue Rating Component - Flowbite +## Default rating +Use this simple example of a star rating component for showing review results. ```vue ``` + +## Rating with text +If you also want to show a text near the stars you can use this example as a reference. +```vue + + +``` + + + +## Rating count +Aggregate more results by using this example to show the amount of reviews and the average score. +```vue + + +``` + + + +## Star sizes +Check out the different sizing options for the star review component from small, medium, and large. +```vue + + +``` + + diff --git a/src/components/Rating/Rating.vue b/src/components/Rating/Rating.vue index be45f18..c702f33 100644 --- a/src/components/Rating/Rating.vue +++ b/src/components/Rating/Rating.vue @@ -1,21 +1,70 @@ + diff --git a/src/components/Rating/composables/useRatingClasses.ts b/src/components/Rating/composables/useRatingClasses.ts new file mode 100644 index 0000000..c90bd28 --- /dev/null +++ b/src/components/Rating/composables/useRatingClasses.ts @@ -0,0 +1,31 @@ +import type { Ref } from 'vue' +import { computed } from 'vue' +import classNames from 'classnames' +import type { RatingSize } from '../types' + +const ratingSizeClasses: Record = { + sm: 'w-5 h-5', + md: 'w-7 h-7', + lg: 'w-10 h-10' +} + +export type UseRatingClassesProps = { + size: Ref +} + +export function useRatingClasses(props: UseRatingClassesProps):{ + sizeClasses: Ref +}{ + const sizeClasses = computed(() => { + let sizeClass = '' + sizeClass = ratingSizeClasses[props.size.value] + return classNames( + sizeClass + ) + }) + + + return { + sizeClasses + } +} \ No newline at end of file diff --git a/src/components/Rating/types.ts b/src/components/Rating/types.ts new file mode 100644 index 0000000..f6f279e --- /dev/null +++ b/src/components/Rating/types.ts @@ -0,0 +1 @@ +export type RatingSize = 'sm' | 'md' | 'lg' \ No newline at end of file