From bf93db1ad5334f922d0f0d7f7841808837600537 Mon Sep 17 00:00:00 2001 From: Ernane Ferreira Date: Sat, 29 Jul 2023 11:51:59 -0300 Subject: [PATCH 1/2] feature: add possibility to format fill percentage --- node_modules/.package-lock.json | 6 +++--- package-lock.json | 12 ++++++------ src/Stars.svelte | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 17403d0..b7f1d93 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,7 +1,7 @@ { - "name": "svelte-custom-button", - "version": "1.0.0", - "lockfileVersion": 2, + "name": "@ernane/svelte-star-rating", + "version": "1.1.0", + "lockfileVersion": 3, "requires": true, "packages": { "node_modules/@types/node": { diff --git a/package-lock.json b/package-lock.json index 0055736..166cab5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { - "name": "svelte-custom-button", - "version": "1.0.0", + "name": "@ernane/svelte-star-rating", + "version": "1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "svelte-custom-button", - "version": "1.0.0", + "name": "@ernane/svelte-star-rating", + "version": "1.1.0", "license": "MIT", "devDependencies": { - "rollup": "^2.70.1", + "rollup": "^2.39.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-svelte": "^7.1.0", - "svelte": "^3.47.0" + "svelte": "^3.32.3" } }, "node_modules/@types/node": { diff --git a/src/Stars.svelte b/src/Stars.svelte index 3056619..0dfd6b0 100644 --- a/src/Stars.svelte +++ b/src/Stars.svelte @@ -22,18 +22,24 @@ {#each Array(config.countStars) as star, id} {#if parseInt(config.score) == id} + {:else if parseInt(config.score) > id} + {:else} - {#if parseInt(config.score) > id} - - {:else} - - {/if} + {/if} {/each} - {#if config.showScore}({parseFloat((config.score/config.countStars)*100).toFixed(2)}%){/if} + {#if config.showScore} + + {#if config.scoreFormat} + {config.scoreFormat()} + {:else} + ({parseFloat((config.score/config.countStars)*100).toFixed(2)}%) + {/if} + + {/if}