Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ VITE_FETCH_ALL_BLOCKS=false
# Limit for recent blocks and associated transactions displayed in the UI
VITE_RECENT_BLOCK_LIMIT=50

# Default color theme when the user has no saved preference (light or dark)
VITE_DEFAULT_THEME=dark

# URL for CoinGecko API or custom proxy
VITE_COINGECKO_URL=https://api.coingecko.com

Expand Down
1 change: 1 addition & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface ImportMetaEnv {
readonly VITE_GITHUB_API_URL?: string,
readonly VITE_PINGPUB_API_URL?: string,
readonly VITE_IBC_USE_GITHUB_API?: string,
readonly VITE_DEFAULT_THEME?: 'light' | 'dark',
}

interface ImportMeta {
Expand Down
9 changes: 8 additions & 1 deletion src/stores/useBaseStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ import { fromBase64 } from '@cosmjs/encoding';
// `"false"` is a truthy string, so compare explicitly.
const FETCH_ALL_BLOCKS = import.meta.env.VITE_FETCH_ALL_BLOCKS === 'true';
const RECENT_BLOCKS_LIMIT = Number(import.meta.env.VITE_RECENT_BLOCK_LIMIT) || 50;
type Theme = 'light' | 'dark';
const DEFAULT_THEME: Theme = import.meta.env.VITE_DEFAULT_THEME === 'light' ? 'light' : 'dark';

function initialTheme(): Theme {
const storedTheme = window.localStorage.getItem('theme');
return storedTheme === 'light' || storedTheme === 'dark' ? storedTheme : DEFAULT_THEME;
}

export const useBaseStore = defineStore('baseStore', {
state: () => {
return {
earliest: {} as Block,
latest: {} as Block,
recents: [] as Block[],
theme: (window.localStorage.getItem('theme') || 'dark') as 'light' | 'dark',
theme: initialTheme(),
connected: false,
};
},
Expand Down
Loading