From 59f37da2467d11e09d148a22debfde7911c88b1f Mon Sep 17 00:00:00 2001 From: Jesper Orb Date: Wed, 27 Mar 2024 19:40:02 +0100 Subject: [PATCH] feat: add settings and code dark mode --- src/lib/components/pages/PageLayout.svelte | 6 +- .../pages/Playground/Playground.svelte | 2 +- .../pages/Playground/PlaygroundOptions.svelte | 1 - src/lib/components/ui/CodeBlock.svelte | 5 +- src/lib/components/ui/DarkModeToggle.svelte | 17 ++-- src/lib/components/ui/Dialog.svelte | 79 ++++++++++--------- src/lib/components/ui/Fieldset.svelte | 8 +- src/lib/components/ui/Highlight/Token.svelte | 18 ++--- src/lib/components/ui/Navigation.svelte | 33 ++++++-- src/lib/components/ui/OptionSection.svelte | 1 - src/lib/components/ui/Radio.svelte | 4 +- src/lib/components/ui/SettingsDialog.svelte | 60 ++++++++++++++ src/lib/store/settings.ts | 70 ++++++++++++++++ src/lib/utils/directives.ts | 20 +++++ src/lib/utils/format-utils.ts | 6 ++ src/routes/+layout.svelte | 45 ++++++++--- src/routes/Playground/+page.svelte | 11 ++- 17 files changed, 295 insertions(+), 91 deletions(-) create mode 100644 src/lib/components/ui/SettingsDialog.svelte create mode 100644 src/lib/store/settings.ts create mode 100644 src/lib/utils/directives.ts diff --git a/src/lib/components/pages/PageLayout.svelte b/src/lib/components/pages/PageLayout.svelte index db6fd2b..7c14356 100644 --- a/src/lib/components/pages/PageLayout.svelte +++ b/src/lib/components/pages/PageLayout.svelte @@ -12,7 +12,7 @@

Input


- +

Alternative use

+ - + - {/if} diff --git a/src/lib/components/pages/Playground/Playground.svelte b/src/lib/components/pages/Playground/Playground.svelte index b1f8396..7d4f95c 100644 --- a/src/lib/components/pages/Playground/Playground.svelte +++ b/src/lib/components/pages/Playground/Playground.svelte @@ -149,7 +149,7 @@ } .output { padding: var(--spacing-4); - padding-top: var(--spacing-6); + padding-top: var(--spacing-5); border-top-left-radius: 4px; } .output-inner { diff --git a/src/lib/components/pages/Playground/PlaygroundOptions.svelte b/src/lib/components/pages/Playground/PlaygroundOptions.svelte index 2e661f4..94e1367 100644 --- a/src/lib/components/pages/Playground/PlaygroundOptions.svelte +++ b/src/lib/components/pages/Playground/PlaygroundOptions.svelte @@ -10,7 +10,6 @@ import OptionCard from '$lib/components/ui/OptionCard.svelte'; import Details from '$lib/components/ui/details/Details.svelte'; import BrowserSupportGrid from '$lib/components/ui/BrowserSupport/BrowserSupportGrid.svelte'; - import Fieldset from '$lib/components/ui/Fieldset.svelte'; import Radio from '$lib/components/ui/Radio.svelte'; import { optionIsActive } from '$lib/playground/validate'; diff --git a/src/lib/components/ui/CodeBlock.svelte b/src/lib/components/ui/CodeBlock.svelte index ba5078e..78a2253 100644 --- a/src/lib/components/ui/CodeBlock.svelte +++ b/src/lib/components/ui/CodeBlock.svelte @@ -10,11 +10,12 @@ tab-size: 2; display: block; padding: var(--spacing-4); - background-color: #1b2b34; + background-color: var(--code-block-background); font-size: 0.85rem; - border-radius: 0.5rem; + border-radius: 4px; overflow-x: auto; color: var(--code-text-color); font-family: var(--font-family); + border: 1px solid var(--border-color); } diff --git a/src/lib/components/ui/DarkModeToggle.svelte b/src/lib/components/ui/DarkModeToggle.svelte index 4d0a0c1..4343039 100644 --- a/src/lib/components/ui/DarkModeToggle.svelte +++ b/src/lib/components/ui/DarkModeToggle.svelte @@ -1,27 +1,22 @@ diff --git a/src/lib/components/ui/Dialog.svelte b/src/lib/components/ui/Dialog.svelte index b47d382..0e1da57 100644 --- a/src/lib/components/ui/Dialog.svelte +++ b/src/lib/components/ui/Dialog.svelte @@ -1,56 +1,47 @@ - - - (show = false)} on:click|self={() => dialog.close()}> - + + (show = false)} + on:click|self={() => dialog.close()} +>
- {#if showCloseButton} - - - - {/if} - + +

{header}

+ +
diff --git a/src/lib/components/ui/Fieldset.svelte b/src/lib/components/ui/Fieldset.svelte index 3631def..28d305a 100644 --- a/src/lib/components/ui/Fieldset.svelte +++ b/src/lib/components/ui/Fieldset.svelte @@ -1,13 +1,12 @@
- {legend} + {legend}
@@ -23,4 +22,7 @@ legend { margin-bottom: var(--spacing-2); } + .capitalize { + text-transform: capitalize; + } \ No newline at end of file diff --git a/src/lib/components/ui/Highlight/Token.svelte b/src/lib/components/ui/Highlight/Token.svelte index bafb939..5631088 100644 --- a/src/lib/components/ui/Highlight/Token.svelte +++ b/src/lib/components/ui/Highlight/Token.svelte @@ -19,37 +19,37 @@ white-space: nowrap; } .token.comment { - color: var(--gray); + color: var(--comment); } .token.punctuation { - color: var(--purple); + color: var(--punctuation); } .token.operator { - color: var(--teal); + color: var(--operator); } .token.key { - color: var(--white); + color: var(--key); } .token.function { - color: var(--light-blue); + color: var(--function); } .token.boolean { - color: var(--red); + color: var(--boolean); } .token.number { - color: var(--orange); + color: var(--number); } .token.string { - color: var(--green); + color: var(--string); } .token.class { - color: #fac863; + color: var(--class); } diff --git a/src/lib/components/ui/Navigation.svelte b/src/lib/components/ui/Navigation.svelte index eb61e8b..64c44b7 100644 --- a/src/lib/components/ui/Navigation.svelte +++ b/src/lib/components/ui/Navigation.svelte @@ -9,13 +9,15 @@ import { selectedLocale } from '$lib/store/selected-locale'; import { testIds } from '$lib/utils/dom-utils'; import OpenInNewTab from '$lib/components/ui/icons/OpenInNewTab.svelte'; - import DarkModeToggle from './DarkModeToggle.svelte'; import Spacing from './Spacing.svelte'; + import Settings from './icons/Settings.svelte'; + import SettingsDialog from './SettingsDialog.svelte'; const locale = browser ? $selectedLocale : getLocaleForSSR($page); let path: string; let open = false; + let showSettings = false; let closeButton: HTMLButtonElement; let openButton: HTMLButtonElement; let lastItem: HTMLAnchorElement; @@ -71,6 +73,8 @@ } + +