-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ed Johnson-Williams
committed
May 21, 2024
1 parent
47128ca
commit c59eab0
Showing
5 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<script lang="ts"> | ||
import { get } from "svelte/store"; | ||
import { bannerShownSessionStore, bannerHiddenCountStore } from "../data/bannerStore"; | ||
import { onMount } from "svelte"; | ||
let banner: HTMLDivElement; | ||
onMount(() => { | ||
let bannerHiddenCount: number = Number(get(bannerHiddenCountStore)); | ||
if (bannerHiddenCount > 3) { | ||
bannerShownSessionStore.set("no"); | ||
} | ||
if (get(bannerShownSessionStore) === "yes") { | ||
banner.classList.remove("hidden"); | ||
banner.classList.add("flex"); | ||
} | ||
}); | ||
function hideBanner() { | ||
banner.classList.remove("flex"); | ||
banner.classList.add("hidden"); | ||
bannerShownSessionStore.set("no"); | ||
let bannerHiddenCount: number = Number(get(bannerHiddenCountStore)); | ||
bannerHiddenCount += 1; | ||
$bannerHiddenCountStore = String(bannerHiddenCount); | ||
} | ||
</script> | ||
|
||
<div | ||
bind:this={banner} | ||
class="flex-row items-center justify-between hidden px-8 py-4 mb-4 border gap-x-8 group" | ||
> | ||
<div class="flex flex-col justify-start sm:items-center sm:flex-row gap-x-6 gap-y-4"> | ||
<p class="pl-2 mt-0"> | ||
<em>Nearest Color</em> is an upcoming paid desktop app with | ||
<span class="font-medium">more accurate color matching</span> and | ||
<span class="font-medium">more color input formats</span>. | ||
</p> | ||
<p class="flex-shrink-0 mt-0"> | ||
<a | ||
href="https://nearest-color.com/why-nearest-color-better-than-find-nearest-tailwind-colour?banner" | ||
class="px-2 py-2 font-medium no-underline transition-all duration-300 rounded-md outline-dashed outline-transparent hover:bg-cyan-700 hover:text-gray-50 group-hover:outline-gray-900" | ||
>Find out why it's better</a | ||
> | ||
</p> | ||
</div> | ||
<button type="button" on:click={hideBanner} | ||
><svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
stroke-width="1.5" | ||
stroke="currentColor" | ||
class="transition-colors rounded-full size-8 outline outline-transparent hover:outline-cyan-500 outline-2" | ||
> | ||
<path | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" | ||
/> | ||
</svg> | ||
</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { persisted } from "svelte-persisted-store"; | ||
|
||
// Save if the banner is hidden to sessionstorage | ||
export const bannerShownSessionStore = persisted("bannerShown", "yes", { | ||
storage: "session" | ||
}); | ||
|
||
// Save a count of how many times the banner has been hidden to local storage | ||
export const bannerHiddenCountStore = persisted("bannerHiddenCount", "0"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters