odj-svelte-ui 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@
6
6
  const uniqueId = `${groupId}-${iconIndex}`;
7
7
  </script>
8
8
 
9
- <svg width={size} height={size} class={svgClass} {...restProps} aria-label={ariaLabel} viewBox="0 0 24 24" {role} stroke-width="1.5">
9
+ <svg width={size} height={size} class={svgClass} {...restProps} aria-label={ariaLabel} data-icon-index={iconIndex} viewBox="0 0 24 24" {role} stroke-width="1.5">
10
10
  <defs>
11
11
  <linearGradient id={uniqueId} x1="0%" y1="0%" x2="100%" y2="0%">
12
12
  {#if fillPercent !== 100}
@@ -6,7 +6,7 @@
6
6
  const uniqueId = `${groupId}-${iconIndex}`;
7
7
  </script>
8
8
 
9
- <svg width={size} height={size} class={svgClass} {...restProps} aria-label={ariaLabel} viewBox="0 0 24 24" {role} stroke-width="1.5" stroke="currentColor" fill="none">
9
+ <svg width={size} height={size} class={svgClass} {...restProps} aria-label={ariaLabel} data-icon-index={iconIndex} viewBox="0 0 24 24" {role} stroke-width="1.5" stroke="currentColor" fill="none">
10
10
  <defs>
11
11
  <linearGradient id={uniqueId}>
12
12
  {#if fillPercent !== 100}
@@ -2,32 +2,32 @@
2
2
  import Star from "./Star.svelte";
3
3
  import { type RatingProps as Props, rating as ratingVariants } from ".";
4
4
 
5
- let { children, text, divClass, size = 24, total = 5, rating = 4, Icon = Star, count = false, pClass }: Props = $props();
5
+ let { children, text, divClass, size = 24, total = 5, rating = 4, Icon = Star, count = false, pClass, iconProps }: Props = $props();
6
6
 
7
7
  const { base, p } = $derived(ratingVariants());
8
8
  const ratingGroupId = crypto.randomUUID();
9
- let fullStars: number = Math.floor(rating);
10
- let rateDiffence = rating - fullStars;
11
- let percentRating = Math.round(rateDiffence * 100);
12
- let grayStars: number = total - (fullStars + Math.ceil(rateDiffence));
9
+ let fullStars: number = $derived(Math.floor(rating));
10
+ let rateDiffence = $derived(rating - fullStars);
11
+ let percentRating = $derived(Math.round(rateDiffence * 100));
12
+ let grayStars: number = $derived(total - (fullStars + Math.ceil(rateDiffence)));
13
13
  </script>
14
14
 
15
15
  <div class={base({ class: divClass })}>
16
16
  {#if count && children}
17
- <Icon fillPercent={100} {size} iconIndex={0} groupId={ratingGroupId} />
17
+ <Icon fillPercent={100} {size} iconIndex={0} groupId={ratingGroupId} {...iconProps} />
18
18
  <p class={p({ class: pClass })}>{rating}</p>
19
19
  {@render children()}
20
20
  {:else}
21
21
  <!-- eslint-disable @typescript-eslint/no-unused-vars-->
22
22
  {#each Array(fullStars) as _, index}
23
- <Icon {size} fillPercent={100} iconIndex={index} groupId={`rating-${ratingGroupId}-full`} />
23
+ <Icon {size} fillPercent={100} iconIndex={index} groupId={`rating-${ratingGroupId}-full`} {...iconProps} />
24
24
  {/each}
25
25
  {#if percentRating}
26
- <Icon {size} fillPercent={percentRating} iconIndex={fullStars} groupId={`rating-${ratingGroupId}-partial`} />
26
+ <Icon {size} fillPercent={percentRating} iconIndex={fullStars} groupId={`rating-${ratingGroupId}-partial`} {...iconProps} />
27
27
  {/if}
28
28
  <!-- eslint-disable @typescript-eslint/no-unused-vars-->
29
29
  {#each Array(grayStars) as _, index}
30
- <Icon {size} fillPercent={0} iconIndex={index} groupId={`rating-${ratingGroupId}-empty`} />
30
+ <Icon {size} fillPercent={0} iconIndex={fullStars + index + 1 - +!percentRating} groupId={`rating-${ratingGroupId}-empty`} {...iconProps} />
31
31
  {/each}
32
32
  {#if text}
33
33
  {@render text()}
@@ -6,7 +6,7 @@
6
6
  const uniqueId = `${groupId}-${iconIndex}`;
7
7
  </script>
8
8
 
9
- <svg width={size} height={size} {...restProps} class={svgClass} aria-label={ariaLabel} viewBox="100 100 120 120" {role}>
9
+ <svg width={size} height={size} {...restProps} class={svgClass} data-icon-index={iconIndex} aria-label={ariaLabel} viewBox="100 100 120 120" {role}>
10
10
  <defs>
11
11
  <linearGradient id={uniqueId}>
12
12
  {#if fillPercent !== 100}
@@ -25,6 +25,7 @@ interface RatingProps {
25
25
  Icon?: Component;
26
26
  count?: boolean;
27
27
  pClass?: string;
28
+ iconProps?: RatingIconProps;
28
29
  }
29
30
  interface RatingCommentProps {
30
31
  children: Snippet;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "odj-svelte-ui",
3
3
  "author": "orbitadajogatina",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "description": "This is a fork from Flowbite Svelte 5 with Runes. I just made some changes that fits better my taste.",
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",