From a3e0bc64096f04600528553b6ad39f2731176ddf Mon Sep 17 00:00:00 2001
From: silllli <9334305+silllli@users.noreply.github.com>
Date: Thu, 6 Jun 2024 00:06:27 +0200
Subject: [PATCH] Refactor buttons
---
src/lib/Banner.svelte | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/lib/Banner.svelte b/src/lib/Banner.svelte
index cf0575b..d02afcd 100644
--- a/src/lib/Banner.svelte
+++ b/src/lib/Banner.svelte
@@ -37,11 +37,12 @@
/**
* @type {string|undefined|null}
*/
- export let acceptLabel = 'Accept cookies'
- export let rejectLabel = 'Reject cookies'
+ export let acceptLabel = 'Accept all'
+ export let rejectLabel = 'Reject all'
export let settingsLabel = 'Cookie settings'
export let closeLabel = 'Close settings'
export let editLabel = 'Edit cookie settings'
+ export let saveLabel = 'Accept selected'
/**
* Whether to show the cookie banner if the user has not yet accepted or rejected your choices.
@@ -108,6 +109,11 @@
return result
}, {})
+ $: allCookieChoices = choicesArr.reduce((result, item) => {
+ result[item.id] = true
+ return result
+ }, {})
+
export function show () {
shown = visible
}
@@ -179,6 +185,11 @@
setCookie(cookieChoices)
execute(cookieChoices)
}
+
+ function accept () {
+ setCookie(allCookieChoices)
+ execute(allCookieChoices)
+ }
{#if showEditIcon}
@@ -230,6 +241,15 @@
on:click={() => { settingsShown = true } }>
{settingsLabel}
+
{#if canRejectCookies}