diff --git a/src/lib/Banner.svelte b/src/lib/Banner.svelte new file mode 100644 index 0000000..9389c69 --- /dev/null +++ b/src/lib/Banner.svelte @@ -0,0 +1,233 @@ + + + + +{#if open} +
+ {#if title || controls?.dismiss} +
+ {#if title} +

{title}

+ {/if} + + {#if controls?.dismiss} + controls.dismiss?.action?.(api)} + > + {#if controls.dismiss?.label} + {controls.dismiss.label} + {/if} + + + {/if} +
+ {/if} + + {@render children?.()} + + {#if controls !== null} +
+ + {#if controls.moreInfo} + {#if controls.moreInfo.type === 'link' && controls.moreInfo.href} + + {controls.moreInfo.label || 'More Info'} + + {:else if controls.moreInfo.type === 'framed'} + + {:else} + controls.moreInfo?.action?.(api)} + inverted={invertFrameless} + > + {controls.moreInfo.label || 'More Info'} + + {/if} + {/if} + +
+ + {@render buttonControl(controls.decline, handleDecline, false)} + + {@render buttonControl(controls.accept, handleAccept, true)} +
+
+ {/if} +
+{/if} + +{#snippet buttonControl( + button: BannerControlButton | undefined | null, + handleClick: (banner: BannerAPI) => void, + framedDefault: boolean +)} + {#if button} + {#if button.framed || framedDefault} + + {:else} + handleClick(api)} + inverted={invertFrameless} + > + {button.label || 'Button'} + + {/if} + {/if} +{/snippet} diff --git a/src/lib/index.ts b/src/lib/index.ts index 7b47f53..66adb29 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,5 +1,6 @@ // Reexport your entry components here export { default as ActionSelect, type ActionSelectOption } from './ActionSelect.svelte'; +export { default as Banner, type BannerControls, type BannerAPI } from './Banner.svelte'; export { default as Button } from './Button.svelte'; export { default as CenterBox } from './CenterBox.svelte'; export { default as Checkbox, type CheckboxState } from './Checkbox.svelte'; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ebdf331..fd0fa5c 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -79,6 +79,20 @@ sui + + console.log('Cookies accepted!')} + ondecline={() => console.log('Cookies declined!')} + open +> + We use cookies and similar technologies to enhance your experience, analyze site traffic, and + measure our ads. You can manage your preferences anytime. + +

sui — Opinionated Svelte 5 UI toolkit