Skip to content

Commit

Permalink
Refactor buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
silllli committed Jun 5, 2024
1 parent b93de00 commit a3e0bc6
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/lib/Banner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -108,6 +109,11 @@
return result
}, {})
$: allCookieChoices = choicesArr.reduce((result, item) => {
result[item.id] = true
return result
}, {})
export function show () {
shown = visible
}
Expand Down Expand Up @@ -179,6 +185,11 @@
setCookie(cookieChoices)
execute(cookieChoices)
}
function accept () {
setCookie(allCookieChoices)
execute(allCookieChoices)
}
</script>

{#if showEditIcon}
Expand Down Expand Up @@ -230,6 +241,15 @@
on:click={() => { settingsShown = true } }>
{settingsLabel}
</button>
<button
type="submit"
class="cookieConsent__Button"
part="button"
on:click={choose}
aria-label={saveLabel}
>
{saveLabel}
</button>
{#if canRejectCookies}
<button
type="submit"
Expand All @@ -245,7 +265,7 @@
type="submit"
class="cookieConsent__Button"
part="button"
on:click={choose}
on:click={accept}
aria-label={acceptLabel}
>
{acceptLabel}
Expand Down

0 comments on commit a3e0bc6

Please sign in to comment.