/** * notion-enhancer * (c) 2023 dragonwocky (https://dragonwocky.me/) * (https://notion-enhancer.github.io/) under the MIT license */ import { Popup } from "../components/Popup.mjs"; import { Button } from "../components/Button.mjs"; import { Description } from "../components/Description.mjs"; import { useState } from "../state.mjs"; const updateGuide = "https://notion-enhancer.github.io/getting-started/updating/"; const rectToStyle = (rect) => ["width", "height", "top", "bottom", "left", "right"] .filter((prop) => rect[prop]) .map((prop) => `${prop}: ${rect[prop]};`) .join(""); function Star({ from, ...rect }) { const { html } = globalThis.__enhancerApi; return html``; } function Circle(rect) { const { html } = globalThis.__enhancerApi; return html`
`; } function Banner({ updateAvailable, isDevelopmentBuild }) { const { html, version, initDatabase } = globalThis.__enhancerApi, $version = html``, $popup = html`<${Popup} trigger=${$version}>

v${updateAvailable} is available! Update now.` : isDevelopmentBuild ? "This is a development build of the notion-enhancer. It may be unstable." : "You're up to date!"} /> `; $version.append($popup); if (updateAvailable) { useState(["focus", "view"], ([, view = "welcome"]) => { if (view !== "welcome") return; // delayed appearance = movement attracts eye setTimeout(() => $version.lastElementChild.show(), 400); }); } const $welcome = html`

<${Circle} width="128px" height="128px" bottom="-64px" left="-64px" /> <${Circle} width="144px" height="144px" top="-108px" left="80px" /> <${Circle} width="208px" height="208px" bottom="-64px" right="-16px" /> <${Circle} width="144px" height="144px" bottom="-72px" right="144px" /> <${Star} width="36px" height="36px" top="136px" left="190px" /> <${Star} width="48px" height="48px" top="32px" left="336px" /> <${Star} width="64px" height="64px" top="90px" left="448px" from="lg" />

Welcome to
the notion-enhancer

${$version}
`, $sponsorship = html`

Enjoying the notion-enhancer?
Support future development:

<${Button} icon="coffee" variant="brand" class="grow justify-center" href="https://www.buymeacoffee.com/dragonwocky" >Buy me a coffee <${Button} icon="calendar-heart" variant="brand" class="grow justify-center" href="https://github.com/sponsors/dragonwocky" >Sponsor me
<${Description} class="mt-[6px]"> Sponsors receive access to priority support channels, private developer previews, and role cosmetics on Discord. A one-time donation is equivalent to 1 month of sponsorship perks. To claim your Discord role, join the server here and follow the instructions in the #welcome channel.
`; initDatabase() .get("agreedToTerms") .then((agreedToTerms) => { // only show sponsorship if already agree to terms // and opening menu after having reloaded since agreeing $welcome.style.borderRadius = agreedToTerms === version ? "" : "4px"; $sponsorship.style.display = agreedToTerms === version ? "" : "none"; }); // todo: show popup if update available return html`
${$welcome}${$sponsorship}
`; } export { Banner };