···11<script lang="ts">
22 import { settingsOpen } from '../lib/data'
33- import Modal from '../lib/Modal.svelte'
33+ import Modal from 'modal-svelte'
44 import Button from '../lib/Button.svelte'
55 import Link from '../lib/Link.svelte'
6677- export let visible = false
88-99- function keydown(e: KeyboardEvent) {
1010- if (e.key === 'Escape' || (e.key === 'Enter' && e.target)) {
1111- visible = false
1212- e.preventDefault()
1313- }
1414- }
77+ export let visible = true
158</script>
1691717-<Modal bind:visible on:keydown={keydown}>
1818- <main>
1919- <h3>Get Started</h3>
2020- <p>You can add a channel on the Channels page.</p>
2121- <p>
2222- Consider opening the
2323- <Link href="/" on:click={() => ($settingsOpen = true)}>settings</Link>
2424- to see how to get your own API key. Kadium has a default one, but it's vulnerable to abuse and
2525- could run out of quota.
2626- </p>
2727- <div class="buttons">
2828- <Button type="submit" on:click={() => (visible = false)}>Whatever</Button>
2929- </div>
3030- </main>
3131-</Modal>
1010+{#if visible}
1111+ <Modal onCancel={() => (visible = false)} form={() => (visible = false)} noCloseIcon>
1212+ <main>
1313+ <h3>Get Started</h3>
1414+ <p>You can add a channel on the Channels page.</p>
1515+ <p>
1616+ Consider opening the
1717+ <Link href="/" on:click={() => ($settingsOpen = true)}>settings</Link>
1818+ to see how to get your own API key. Kadium has a default one, but it's vulnerable to abuse and
1919+ could run out of quota.
2020+ </p>
2121+ <div class="buttons">
2222+ <Button type="submit" on:click={() => (visible = false)}>Whatever</Button>
2323+ </div>
2424+ </main>
2525+ </Modal>
2626+{/if}
32273328<style lang="sass">
3429 main
3530 max-width: 400px
3131+ h3
3232+ margin-top: 0px
3633 p
3734 font-size: 14px
3835 margin-top: 5px
+87-85
src/modals/Settings.svelte
···11<script lang="ts">
22 import Button from '../lib/Button.svelte'
33 import { loadSettings } from '../lib/data'
44- import Modal from '../lib/Modal.svelte'
44+ import Modal from 'modal-svelte'
55 import Link from '../lib/Link.svelte'
66 import Switch from '../lib/Switch.svelte'
77 import commands from '../lib/commands'
···1111 export let checkInBackground: boolean
12121313 export let visible = false
1414+ let keyGuideVisible = false
14151516 async function setGeneralSettings() {
1617 await commands.setGeneralSettings(apiKey, maxConcurrentRequests, checkInBackground)
1718 await loadSettings()
1819 visible = false
1920 }
2020-2121- function keydown(e: KeyboardEvent) {
2222- if (e.key === 'Escape' && e.target) {
2323- visible = false
2424- e.preventDefault()
2525- }
2626- }
2727-2828- let keyGuideVisible = false
2929- function keyGuideKeydown(e: KeyboardEvent) {
3030- if (e.key === 'Escape') {
3131- keyGuideVisible = false
3232- e.preventDefault()
3333- }
3434- }
3521</script>
36223737-<Modal bind:visible on:keydown={keydown}>
3838- <form class="page" on:submit|preventDefault={setGeneralSettings}>
3939- <h3>Settings</h3>
4040- <p>API Key</p>
4141- <p class="sub">
4242- Kadium has a default API key, but it's vulnerable to abuse and could run out of quota.
4343- <Link on:click={() => (keyGuideVisible = true)}>
4444- <div>Get your own key</div>
4545- </Link>
4646- </p>
4747- <input class="textbox" type="text" bind:value={apiKey} placeholder="AIzaSyNq5Y9knL..." />
4848- <div class="toggle-row">
4949- <label for="check-in-background">
5050- <p>Check for new videos automatically</p>
5151- </label>
5252- <Switch id="check-in-background" bind:checked={checkInBackground} />
5353- </div>
5454- <div class="buttons">
5555- <Button secondary on:click={() => (visible = false)}>Cancel</Button>
5656- <div class="spacer" />
5757- <Button type="submit">Save</Button>
5858- </div>
5959- </form>
6060-</Modal>
2323+{#if visible}
2424+ <Modal
2525+ onCancel={() => {
2626+ visible = false
2727+ }}
2828+ let:focus
2929+ noCloseIcon
3030+ >
3131+ <form class="page" on:submit|preventDefault={setGeneralSettings}>
3232+ <h3>Settings</h3>
3333+ <p>API Key</p>
3434+ <p class="sub">
3535+ Kadium has a default API key, but it's vulnerable to abuse and could run out of quota.
3636+ <Link on:click={() => (keyGuideVisible = true)}>
3737+ <div>Get your own key</div>
3838+ </Link>
3939+ </p>
4040+ <input
4141+ class="textbox"
4242+ type="text"
4343+ bind:value={apiKey}
4444+ placeholder="AIzaSyNq5Y9knL..."
4545+ use:focus
4646+ />
4747+ <div class="toggle-row">
4848+ <label for="check-in-background">
4949+ <p>Check for new videos automatically</p>
5050+ </label>
5151+ <Switch id="check-in-background" bind:checked={checkInBackground} />
5252+ </div>
5353+ <div class="buttons">
5454+ <Button secondary on:click={() => (visible = false)}>Cancel</Button>
5555+ <div class="spacer" />
5656+ <Button type="submit">Save</Button>
5757+ </div>
5858+ </form>
5959+ </Modal>
6060+{/if}
61616262-<Modal bind:visible={keyGuideVisible} on:keydown={keyGuideKeydown}>
6363- <form class="guide-page" on:submit|preventDefault={() => (keyGuideVisible = false)}>
6464- <h3>Create an API key</h3>
6565- <ol>
6666- <li>
6767- Go to the <Link href="https://console.cloud.google.com/apis/dashboard"
6868- >Google APIs & Services
6969- </Link> website.
7070- </li>
7171- <li>
7272- <Link href="https://console.cloud.google.com/projectcreate">Create a new project</Link>. Set
7373- the project name to <b>my-kadium</b> and click <b>CREATE</b>.
7474- </li>
7575- <li>
7676- Make sure you have the <b>my-kadium</b> project selected in the top-left project dropdown menu.
7777- </li>
7878- <li>
7979- Go to the <Link
8080- href="https://console.cloud.google.com/apis/library/youtube.googleapis.com?project=mykadium"
8181- >YouTube Data API v3</Link
8282- >
8383- page and click <b>ENABLE</b>.
8484- </li>
8585- <li>
8686- On the <Link href="https://console.cloud.google.com/apis/credentials?project=mykadium"
8787- >Credentials</Link
8888- >
8989- page, click <b>CREATE CREDENTIALS</b>, then <b>API key</b>.
9090- </li>
9191- <li>You should see your API key!</li>
9292- <li>Optionally restrict the API key to the YouTube API:</li>
9393- <ul>
6262+{#if keyGuideVisible}
6363+ <Modal onCancel={() => (keyGuideVisible = false)} noCloseIcon>
6464+ <form class="guide-page" on:submit|preventDefault={() => (keyGuideVisible = false)}>
6565+ <h3>Create an API key</h3>
6666+ <ol>
6767+ <li>
6868+ Go to the <Link href="https://console.cloud.google.com/apis/dashboard"
6969+ >Google APIs & Services
7070+ </Link> website.
7171+ </li>
7272+ <li>
7373+ <Link href="https://console.cloud.google.com/projectcreate">Create a new project</Link>.
7474+ Set the project name to <b>my-kadium</b> and click <b>CREATE</b>.
7575+ </li>
9476 <li>
9595- Open your API key from the
9696- <Link href="https://console.cloud.google.com/apis/credentials?project=mykadium"
7777+ Make sure you have the <b>my-kadium</b> project selected in the top-left project dropdown menu.
7878+ </li>
7979+ <li>
8080+ Go to the <Link
8181+ href="https://console.cloud.google.com/apis/library/youtube.googleapis.com?project=mykadium"
8282+ >YouTube Data API v3</Link
8383+ >
8484+ page and click <b>ENABLE</b>.
8585+ </li>
8686+ <li>
8787+ On the <Link href="https://console.cloud.google.com/apis/credentials?project=mykadium"
9788 >Credentials</Link
9898- > page.
8989+ >
9090+ page, click <b>CREATE CREDENTIALS</b>, then <b>API key</b>.
9991 </li>
100100- <li>Under <b>API restrictions</b>, select <b>Restrict key</b>.</li>
101101- <li>In the dropdown, select <b>YouTube Data API v3</b>.</li>
102102- <li>Press <b>SAVE</b>.</li>
103103- </ul>
104104- </ol>
105105- <div class="right">
106106- <Button type="submit">Oh okay</Button>
107107- </div>
108108- </form>
109109-</Modal>
9292+ <li>You should see your API key!</li>
9393+ <li>Optionally restrict the API key to the YouTube API:</li>
9494+ <ul>
9595+ <li>
9696+ Open your API key from the
9797+ <Link href="https://console.cloud.google.com/apis/credentials?project=mykadium"
9898+ >Credentials</Link
9999+ > page.
100100+ </li>
101101+ <li>Under <b>API restrictions</b>, select <b>Restrict key</b>.</li>
102102+ <li>In the dropdown, select <b>YouTube Data API v3</b>.</li>
103103+ <li>Press <b>SAVE</b>.</li>
104104+ </ul>
105105+ </ol>
106106+ <div class="right">
107107+ <Button type="submit">Oh okay</Button>
108108+ </div>
109109+ </form>
110110+ </Modal>
111111+{/if}
110112111113<style lang="sass">
112114 .guide-page