-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates theme to utilize newly created `Theme` component - https://unicorn-ui.netlify.app/theme - [x] Updates theme (migration from `app.css` --> `lib/palette.ts`) - [x] Adds functionality for theme toggle in upper right corner - [x] Changes default theme based on device settings
- Loading branch information
Showing
6 changed files
with
120 additions
and
19 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
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
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,24 @@ | ||
<!-- | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2021-Present The Zarf Authors | ||
--> | ||
<script lang="ts"> | ||
import { themeStore } from '$lib/store'; | ||
import { IconButton } from '@ui'; | ||
const toggle = () => { | ||
themeStore.update((theme) => { | ||
return theme === 'dark' ? 'light' : 'dark'; | ||
}); | ||
}; | ||
</script> | ||
|
||
<IconButton | ||
on:click={toggle} | ||
iconContent="dark_mode" | ||
toggledIconContent="light_mode" | ||
toggleable | ||
toggled={$themeStore === 'dark'} | ||
iconClass="material-symbols-outlined" | ||
toggledIconClass="material-symbols-outlined" | ||
/> |
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,69 @@ | ||
import type { Palettes } from '@ui'; | ||
|
||
// Current default from @ui | ||
export const ZarfPalettes: Palettes = { | ||
shared: { | ||
primary: '#68c4ff', | ||
secondary: '#787ff6', | ||
surface: '#244a8f', | ||
success: '#2e7d32', | ||
warning: '#ed6c02', | ||
info: '#0288d1', | ||
error: '#b00020', | ||
on: { | ||
primary: 'black', | ||
secondary: 'white', | ||
surface: 'white', | ||
success: 'white', | ||
warning: 'white', | ||
info: 'white', | ||
error: 'white' | ||
}, | ||
text: { | ||
primary: { | ||
onDark: 'white', | ||
onLight: 'rgb(0, 0, 0, 0.87)', | ||
onBackground: 'rgb(255, 255, 255, 0.87)' | ||
}, | ||
secondary: { | ||
onLight: 'rgb(0, 0, 0, 0.6)', | ||
onDark: 'rgba(255, 255, 255, 0.7)', | ||
onBackground: 'rgba(255, 255, 255, 0.7)' | ||
}, | ||
hint: { | ||
onLight: 'rgba(0, 0, 0, 0.38)', | ||
onDark: 'rgba(255, 255, 255, 0.5)', | ||
onBackground: 'rgba(255, 255, 255, 0.5)' | ||
}, | ||
disabled: { | ||
onLight: 'rgba(0, 0, 0, 0.38)', | ||
onDark: 'rgba(255, 255, 255, 0.5)', | ||
onBackground: 'rgba(255, 255, 255, 0.5)' | ||
}, | ||
icon: { | ||
onLight: 'rgba(0, 0, 0, 0.38)', | ||
onDark: 'rgba(255, 255, 255, 0.5)', | ||
onBackground: 'rgba(255, 255, 255, 0.5)' | ||
} | ||
} | ||
}, | ||
// custom dark + light palettes | ||
dark: { | ||
background: '#0a0e2e', | ||
onBackground: '#ffffff', | ||
primary: '#00acac' | ||
}, | ||
// source: figma | ||
light: { | ||
primary: '#4adede', | ||
secondary: '#787ff6', | ||
background: '#f5f5f5', | ||
surface: 'white', | ||
on: { | ||
background: 'black', | ||
surface: 'black', | ||
secondary: 'white', | ||
primary: '#171717' | ||
} | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,11 +1,19 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2021-Present The Zarf Authors | ||
|
||
import { getPreferredTheme } from '@defense-unicorns/unicorn-ui'; | ||
import { writable } from 'svelte/store'; | ||
import type { APIZarfPackage, ClusterSummary } from './api-types'; | ||
|
||
const clusterStore = writable<ClusterSummary>(); | ||
const pkgStore = writable<APIZarfPackage>(); | ||
const pkgComponentDeployStore = writable<number[]>([]); | ||
// check localstorage for theme, if not found, use the preferred theme, otherwise default to light | ||
const storedTheme = localStorage.theme ?? getPreferredTheme(window) ?? 'light'; | ||
const themeStore = writable<'dark' | 'light'>(storedTheme); | ||
// update localstorage when theme changes | ||
themeStore.subscribe((theme) => { | ||
localStorage.theme = theme; | ||
}); | ||
|
||
export { clusterStore, pkgStore, pkgComponentDeployStore }; | ||
export { clusterStore, pkgStore, pkgComponentDeployStore, themeStore }; |
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