-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from alleslabs/feat/merge-navigation
feat: implement merge navigation
- Loading branch information
Showing
32 changed files
with
895 additions
and
1,007 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,5 +41,4 @@ export const DEFAULT_CHAIN_CONFIG: ChainConfig = { | |
validator: "", | ||
proposal: "", | ||
}, | ||
hasSubHeader: false, | ||
}; |
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
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
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
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 |
---|---|---|
@@ -1,71 +1,30 @@ | ||
/* eslint-disable no-console */ | ||
import type { Dispatch, SetStateAction } from "react"; | ||
import { useCallback, useState } from "react"; | ||
import { useEffect, useState } from "react"; | ||
|
||
// Reference: https://usehooks-ts.com/react-hook/use-local-storage | ||
|
||
// A wrapper for "JSON.parse()"" to support "undefined" value | ||
const parseJSON = <T>(value: string): T | undefined => { | ||
try { | ||
return value === "undefined" ? undefined : JSON.parse(value); | ||
} catch { | ||
return undefined; | ||
} | ||
}; | ||
|
||
type SetValue<T> = Dispatch<SetStateAction<T>>; | ||
type PersistedState<T> = [T, Dispatch<SetStateAction<T>>]; | ||
|
||
export const useLocalStorage = <T>( | ||
key: string, | ||
initialValue: T | ||
): [T, SetValue<T>] => { | ||
// Get from local storage then | ||
// parse stored json or return initialValue | ||
const readValue = useCallback((): T => { | ||
// Prevent build error "window is undefined" but keeps working | ||
if (typeof window === "undefined") { | ||
return initialValue; | ||
defaultValue: T | ||
): PersistedState<T> => { | ||
const [storedValue, setStoredValue] = useState<T>(() => { | ||
try { | ||
const value = window.localStorage.getItem(key); | ||
return value ? (JSON.parse(value) as T) : defaultValue; | ||
} catch (e) { | ||
console.warn(`Error reading localStorage key “${key}”:`, e); | ||
return defaultValue as T; | ||
} | ||
}); | ||
|
||
useEffect(() => { | ||
try { | ||
const item = window.localStorage.getItem(key); | ||
return item ? (parseJSON(item) as T) : initialValue; | ||
} catch (error) { | ||
console.warn(`Error reading localStorage key “${key}”:`, error); | ||
return initialValue; | ||
window.localStorage.setItem(key, JSON.stringify(storedValue)); | ||
} catch (e) { | ||
console.warn(`Error setting localStorage key “${key}”:`, e); | ||
} | ||
}, [initialValue, key]); | ||
|
||
// State to store our value | ||
// Pass initial state function to useState so logic is only executed once | ||
const [storedValue, setStoredValue] = useState<T>(readValue); | ||
|
||
// Return a wrapped version of useState's setter function that ... | ||
// ... persists the new value to localStorage. | ||
const setValue: SetValue<T> = useCallback( | ||
(value) => { | ||
// Prevent build error "window is undefined" but keeps working | ||
if (typeof window === "undefined") { | ||
console.warn( | ||
`Tried setting localStorage key “${key}” even though environment is not a client` | ||
); | ||
} | ||
|
||
try { | ||
// Allow value to be a function so we have the same API as useState | ||
const newValue = value instanceof Function ? value(storedValue) : value; | ||
|
||
// Save to local storage | ||
window.localStorage.setItem(key, JSON.stringify(newValue)); | ||
|
||
// Save state | ||
setStoredValue(newValue); | ||
} catch (error) { | ||
console.warn(`Error setting localStorage key “${key}”:`, error); | ||
} | ||
}, | ||
[key, storedValue] | ||
); | ||
}, [key, storedValue]); | ||
|
||
return [storedValue, setValue]; | ||
return [storedValue, setStoredValue]; | ||
}; |
Oops, something went wrong.
562111e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
celatone-frontend-staging – ./
celatone-frontend-staging-git-develop-alleslabs.vercel.app
celatone-frontend-staging-alleslabs.vercel.app
celatone-frontend-staging.vercel.app
562111e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
osmosis-celatone-frontend-staging – ./
osmosis-celatone-frontend-staging-alleslabs.vercel.app
osmosis-celatone-frontend-staging-git-develop-alleslabs.vercel.app
osmosis-staging.celat.one
osmosis-celatone-frontend-staging.vercel.app
staging.osmoscan.io
celatone-staging.osmosis.zone