From 4e8bc8ee98fe356f2217794093bdb252368af1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Fri, 12 Aug 2022 18:31:10 +0200 Subject: [PATCH] Add appearance settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rūdolfs Ošiņš --- Showcase.svelte | 42 ++++++++++++++++ Showcase/CodeFontSetting.svelte | 16 +++++++ Showcase/PrimaryColorSetting.svelte | 49 +++++++++++++++++++ Showcase/ThemeSetting.svelte | 16 +++++++ Showcase/UiFontSetting.svelte | 25 ++++++++++ Theme.svelte | 56 ++++++++++++++++++++++ lib/appearance.ts | 74 +++++++++++++++++++++++++++++ 7 files changed, 278 insertions(+) create mode 100644 Showcase/CodeFontSetting.svelte create mode 100644 Showcase/PrimaryColorSetting.svelte create mode 100644 Showcase/ThemeSetting.svelte create mode 100644 Showcase/UiFontSetting.svelte create mode 100644 Theme.svelte create mode 100644 lib/appearance.ts diff --git a/Showcase.svelte b/Showcase.svelte index 8c62dba..74ebadd 100644 --- a/Showcase.svelte +++ b/Showcase.svelte @@ -12,9 +12,17 @@ import CheckIcon from "./icons/Check.svelte"; import CrossIcon from "./icons/Cross.svelte"; import ForkIcon from "./icons/Fork.svelte"; + import LockIcon from "./icons/Lock.svelte"; import MinusIcon from "./icons/Minus.svelte"; import PlusIcon from "./icons/Plus.svelte"; + import Theme from "./Theme.svelte"; + + import ThemeSetting from "./Showcase/ThemeSetting.svelte"; + import PrimaryColorSetting from "./Showcase/PrimaryColorSetting.svelte"; + import CodeFontSetting from "./Showcase/CodeFontSetting.svelte"; + import UiFontSetting from "./Showcase/UiFontSetting.svelte"; + import Button from "./Button.svelte"; import Checkbox from "./Checkbox.svelte"; import Dropdown from "./Dropdown.svelte"; @@ -200,6 +208,8 @@ onClose(); } } + + let settingsHeaderPinned: boolean = false; + + {#if onClose !== undefined} @@ -295,6 +319,24 @@

Components

+ +
+ + + + + + + (settingsHeaderPinned = !settingsHeaderPinned)} + style={settingsHeaderPinned + ? "fill: var(--color-foreground)" + : "fill: var(--color-foreground-level-4)"} /> + +
+
diff --git a/Showcase/CodeFontSetting.svelte b/Showcase/CodeFontSetting.svelte new file mode 100644 index 0000000..dca82c4 --- /dev/null +++ b/Showcase/CodeFontSetting.svelte @@ -0,0 +1,16 @@ + + + + codeFont.set(ev.detail)} /> diff --git a/Showcase/PrimaryColorSetting.svelte b/Showcase/PrimaryColorSetting.svelte new file mode 100644 index 0000000..25c2146 --- /dev/null +++ b/Showcase/PrimaryColorSetting.svelte @@ -0,0 +1,49 @@ + + + + + + primaryColor.set(ev.detail)}> + {#if $primaryColor === "custom"} + + {/if} + diff --git a/Showcase/ThemeSetting.svelte b/Showcase/ThemeSetting.svelte new file mode 100644 index 0000000..8d1c3b6 --- /dev/null +++ b/Showcase/ThemeSetting.svelte @@ -0,0 +1,16 @@ + + + + theme.set(ev.detail)} /> diff --git a/Showcase/UiFontSetting.svelte b/Showcase/UiFontSetting.svelte new file mode 100644 index 0000000..03f5299 --- /dev/null +++ b/Showcase/UiFontSetting.svelte @@ -0,0 +1,25 @@ + + + + + + + uiFont.set(ev.detail)} /> diff --git a/Theme.svelte b/Theme.svelte new file mode 100644 index 0000000..364a0cb --- /dev/null +++ b/Theme.svelte @@ -0,0 +1,56 @@ + + diff --git a/lib/appearance.ts b/lib/appearance.ts new file mode 100644 index 0000000..0973abe --- /dev/null +++ b/lib/appearance.ts @@ -0,0 +1,74 @@ +// Copyright © 2022 The Radicle Design System Contributors +// +// This file is part of radicle-design-system, distributed under the GPLv3 +// with Radicle Linking Exception. For full terms see the included +// LICENSE file. + +import { writable } from "svelte/store"; + +interface Option { + value: T; + title: string; +} + +type Theme = "dark" | "light" | "h4x0r"; + +export const theme = writable("dark"); + +export const themeOptions: Option[] = [ + { + title: "Light", + value: "light", + }, + { + title: "Dark", + value: "dark", + }, + { + title: "H4x0r", + value: "h4x0r", + }, +]; + +type UiFont = "inter" | "system"; + +export const uiFont = writable("inter"); + +export const uiFontOptions: Option[] = [ + { + title: "Inter", + value: "inter", + }, + { + title: "System", + value: "system", + }, +]; + +type CodeFont = "sourceCode" | "system"; + +export const codeFont = writable("sourceCode"); + +export const codeFontOptions: Option[] = [ + { + title: "Source Code", + value: "sourceCode", + }, + { + title: "System", + value: "system", + }, +]; + +type PrimaryColor = "blue" | "pink" | "orange" | "custom"; + +export const primaryColor = writable("blue"); + +export const primaryColorOptions: Option[] = [ + { title: "Blue", value: "blue" }, + { title: "Pink", value: "pink" }, + { title: "Orange", value: "orange" }, + { title: "Custom", value: "custom" }, +]; + +export const primaryColorHex = writable("#5555FF");