mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-13 19:51:07 +00:00
feat: implement dark/light theme switching
- Add ui-settings resolution for v3.16.9 - Add CSS variables for dark/light themes in GlobalStyle - Set default data-theme attribute on html element - Simplify theme creation in Root.tsx - Disable webpack error overlay for cleaner dev experience
This commit is contained in:
@@ -110,6 +110,7 @@
|
|||||||
"@pezkuwi/types-create": "^16.5.6",
|
"@pezkuwi/types-create": "^16.5.6",
|
||||||
"@pezkuwi/types-known": "^16.5.8",
|
"@pezkuwi/types-known": "^16.5.8",
|
||||||
"@pezkuwi/types-support": "^16.5.6",
|
"@pezkuwi/types-support": "^16.5.6",
|
||||||
|
"@pezkuwi/ui-settings": "^3.16.9",
|
||||||
"@pezkuwi/util": "^14.0.7",
|
"@pezkuwi/util": "^14.0.7",
|
||||||
"@pezkuwi/util-crypto": "^14.0.7",
|
"@pezkuwi/util-crypto": "^14.0.7",
|
||||||
"@pezkuwi/wasm-crypto": "^7.5.4",
|
"@pezkuwi/wasm-crypto": "^7.5.4",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en" data-theme="light">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="theme-color" content="#000000">
|
<meta name="theme-color" content="#000000">
|
||||||
|
|||||||
@@ -20,10 +20,9 @@ interface Props {
|
|||||||
store?: KeyringStore;
|
store?: KeyringStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTheme ({ uiTheme }: { uiTheme: string }): ThemeDef {
|
function createTheme (settings: { uiTheme?: string }): ThemeDef {
|
||||||
const theme = uiTheme === 'dark'
|
const uiTheme = settings?.uiTheme || 'light';
|
||||||
? 'dark'
|
const theme = uiTheme === 'dark' ? 'dark' : 'light';
|
||||||
: 'light';
|
|
||||||
|
|
||||||
document?.documentElement?.setAttribute('data-theme', theme);
|
document?.documentElement?.setAttribute('data-theme', theme);
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ function Root ({ isElectron, store }: Props): React.ReactElement<Props> {
|
|||||||
const [theme, setTheme] = useState(() => createTheme(settings));
|
const [theme, setTheme] = useState(() => createTheme(settings));
|
||||||
|
|
||||||
useEffect((): void => {
|
useEffect((): void => {
|
||||||
settings.on('change', (settings) => setTheme(createTheme(settings)));
|
settings.on('change', (newSettings) => setTheme(createTheme(newSettings)));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// The ordering here is critical. It defines the hierarchy of dependencies,
|
// The ordering here is critical. It defines the hierarchy of dependencies,
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ module.exports = merge(
|
|||||||
baseConfig(__dirname, 'development'),
|
baseConfig(__dirname, 'development'),
|
||||||
{
|
{
|
||||||
devServer: {
|
devServer: {
|
||||||
|
client: {
|
||||||
|
overlay: false // Disable error overlay
|
||||||
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Security-Policy': "frame-ancestors 'none'",
|
'Content-Security-Policy': "frame-ancestors 'none'",
|
||||||
'X-Frame-Options': 'DENY'
|
'X-Frame-Options': 'DENY'
|
||||||
|
|||||||
@@ -61,6 +61,32 @@ function hexToRGB (hex: string, alpha?: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default createGlobalStyle<Props>(({ uiHighlight }: Props) => `
|
export default createGlobalStyle<Props>(({ uiHighlight }: Props) => `
|
||||||
|
/* Dark theme CSS variables */
|
||||||
|
html[data-theme="dark"],
|
||||||
|
[data-theme="dark"] {
|
||||||
|
--bg-page: #26272c !important;
|
||||||
|
--bg-table: #3b3d3f !important;
|
||||||
|
--bg-input: #38393f !important;
|
||||||
|
--bg-menu: #26272c !important;
|
||||||
|
--bg-tabs: #38393f !important;
|
||||||
|
--bg-sidebar: #1a1b20 !important;
|
||||||
|
--color-text: rgba(244, 242, 240, 0.8) !important;
|
||||||
|
--border-table: #343536 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Light theme CSS variables */
|
||||||
|
html[data-theme="light"],
|
||||||
|
[data-theme="light"] {
|
||||||
|
--bg-page: #f5f3f1 !important;
|
||||||
|
--bg-table: #ffffff !important;
|
||||||
|
--bg-input: #ffffff !important;
|
||||||
|
--bg-menu: #ffffff !important;
|
||||||
|
--bg-tabs: #ffffff !important;
|
||||||
|
--bg-sidebar: #fafafa !important;
|
||||||
|
--color-text: rgba(78, 78, 78, 0.8) !important;
|
||||||
|
--border-table: #efedeb !important;
|
||||||
|
}
|
||||||
|
|
||||||
.highlight--all {
|
.highlight--all {
|
||||||
background: ${getHighlight(uiHighlight)} !important;
|
background: ${getHighlight(uiHighlight)} !important;
|
||||||
border-color: ${getHighlight(uiHighlight)} !important;
|
border-color: ${getHighlight(uiHighlight)} !important;
|
||||||
|
|||||||
@@ -3076,9 +3076,9 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@pezkuwi/ui-settings@npm:3.16.6":
|
"@pezkuwi/ui-settings@npm:^3.16.9":
|
||||||
version: 3.16.6
|
version: 3.16.9
|
||||||
resolution: "@pezkuwi/ui-settings@npm:3.16.6"
|
resolution: "@pezkuwi/ui-settings@npm:3.16.9"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@pezkuwi/networks": "npm:^14.0.5"
|
"@pezkuwi/networks": "npm:^14.0.5"
|
||||||
"@pezkuwi/util": "npm:^14.0.5"
|
"@pezkuwi/util": "npm:^14.0.5"
|
||||||
@@ -3088,23 +3088,7 @@ __metadata:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
"@pezkuwi/networks": "*"
|
"@pezkuwi/networks": "*"
|
||||||
"@pezkuwi/util": "*"
|
"@pezkuwi/util": "*"
|
||||||
checksum: 10/a5dc5249828922b367a624b065ce1ba898c0fed64414abed1b1ed1c3f0a04eee1fd972969b9e2010381a266fbb3effb282ba504fc1174765bc55bb52144d89ab
|
checksum: 10/73c0c3eefc06d98352f4bfc5fbf432a9313673236fa00069fdeb0100ae9a9cc5560074895514ba6598b6de85e8fb4e7d04b15af599603d739f34b2bb758a1fd3
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"@pezkuwi/ui-settings@npm:^3.16.3":
|
|
||||||
version: 3.16.8
|
|
||||||
resolution: "@pezkuwi/ui-settings@npm:3.16.8"
|
|
||||||
dependencies:
|
|
||||||
"@pezkuwi/networks": "npm:^14.0.5"
|
|
||||||
"@pezkuwi/util": "npm:^14.0.5"
|
|
||||||
eventemitter3: "npm:^5.0.1"
|
|
||||||
store: "npm:^2.0.12"
|
|
||||||
tslib: "npm:^2.8.1"
|
|
||||||
peerDependencies:
|
|
||||||
"@pezkuwi/networks": "*"
|
|
||||||
"@pezkuwi/util": "*"
|
|
||||||
checksum: 10/caa14d98d337db9ab1498473bde271026dee063b3d762b1023af40c534ec957e2b34b27ad9e91f5c14635537782184479446679b2be00eb0be479eb274123aac
|
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user