aboutsummaryrefslogtreecommitdiffstats
path: root/apps/kit/src/lib/components/alert.svelte
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-09-25 12:01:37 +0200
committerivarlovlie <git@ivarlovlie.no>2022-09-25 12:01:37 +0200
commit2a9e668dceda855f8302e2ca9f81ebd6f0e7b5c1 (patch)
tree13f7a597c2e31210e722388de8aabf0d43ba5326 /apps/kit/src/lib/components/alert.svelte
parent9f65b9e65ead6cc6b8ce5cfcf650b49fe134cd91 (diff)
downloadgreatoffice-2a9e668dceda855f8302e2ca9f81ebd6f0e7b5c1.tar.xz
greatoffice-2a9e668dceda855f8302e2ca9f81ebd6f0e7b5c1.zip
feat: Safelist all classes needed for alerts
Diffstat (limited to 'apps/kit/src/lib/components/alert.svelte')
-rw-r--r--apps/kit/src/lib/components/alert.svelte16
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/kit/src/lib/components/alert.svelte b/apps/kit/src/lib/components/alert.svelte
index 87962cf..53aa783 100644
--- a/apps/kit/src/lib/components/alert.svelte
+++ b/apps/kit/src/lib/components/alert.svelte
@@ -25,12 +25,11 @@
export let actions: Array<{ id: string; text: string; color?: string }> =
[];
// This value is set on a plain anchor tag without any svelte routing,
- // listen to the right-link-click if you want to intercept the click without navigating
+ // listen to the rightLinkClick if you want to intercept the click without navigating
export let rightLinkHref = "javascript:void(0)";
export let visible = true;
const dispatch = createEventDispatcher();
-
const cooldownStorageKey = "lastseen--" + id;
let iconComponent: any;
@@ -79,6 +78,14 @@
}
}
+ function rightLinkClicked() {
+ dispatch("rightLinkCliked");
+ }
+
+ function actionClicked(name: string) {
+ dispatch("act-" + name);
+ }
+
// Manages the state of the alert if cooldown is enabled
function run_cooldown() {
if (!cooldownEnabled) {
@@ -160,8 +167,7 @@
<p class="mt-3 text-sm md:mt-0 md:ml-6">
<a
href={rightLinkHref}
- on:click={() =>
- dispatch("right-link-click")}
+ on:click={() => rightLinkClicked()}
class="whitespace-nowrap font-medium text-{colorClassPart}-700 hover:text-{colorClassPart}-600"
>
{rightLinkText}
@@ -187,7 +193,7 @@
{@const color = action?.color ?? colorClassPart}
<button
type="button"
- on:click={() => dispatch("act-" + action.id)}
+ on:click={() => actionClicked(action.id)}
class="rounded-md
bg-{color}-50
px-2 py-1.5 text-sm font-medium