-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the side navigation resizeable and remember it (#517)
* Make the side navigation resizeable and remember it * Add docs, fix bug in query params not removing args * Typo * Fix reversed styles
- Loading branch information
Showing
12 changed files
with
302 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ladle/react": minor | ||
--- | ||
|
||
Make the side navigation resizeable and remember it |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export type Settings = { | ||
appId?: string; | ||
sidebarWidth?: number; | ||
}; | ||
|
||
// @ts-ignore | ||
const APP_ID = import.meta.env.VITE_LADLE_APP_ID; | ||
const storageKey = `ladle-settings-${APP_ID}`; | ||
const defaultValue = { appId: APP_ID }; | ||
|
||
export const updateSettings = (settings: Settings) => { | ||
const storageValue = localStorage.getItem(storageKey); | ||
let storageSettings = defaultValue; | ||
try { | ||
if (storageValue) storageSettings = JSON.parse(storageValue); | ||
} catch (e) {} | ||
localStorage.setItem( | ||
storageKey, | ||
JSON.stringify({ ...storageSettings, ...settings }), | ||
); | ||
}; | ||
|
||
export const getSettings = (): Settings => { | ||
const storageValue = localStorage.getItem(storageKey); | ||
let storageSettings = defaultValue; | ||
try { | ||
if (storageValue) storageSettings = JSON.parse(storageValue); | ||
} catch (e) {} | ||
return storageSettings as Settings; | ||
}; |
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
Oops, something went wrong.