-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
URL params hydration slider + textInput
- Loading branch information
Showing
7 changed files
with
148 additions
and
21 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,31 @@ | ||
export let displayedStoryURL = window.location.href; // The string that updates | ||
|
||
const updateURL = () => { | ||
const newURL = window.location.href; | ||
if (newURL !== displayedStoryURL) { | ||
displayedStoryURL = newURL; // Update the variable | ||
|
||
// Try forcing Storybook to recognize the change | ||
const iframe = document.querySelector('iframe'); | ||
if (iframe) { | ||
iframe.src = iframe.src; // Force reload | ||
} | ||
} | ||
}; | ||
|
||
export const initStorybookURLWatcher = () => { | ||
const pushState = history.pushState; | ||
const replaceState = history.replaceState; | ||
|
||
history.pushState = function () { | ||
pushState.apply(history, arguments); | ||
updateURL(); | ||
}; | ||
|
||
history.replaceState = function () { | ||
replaceState.apply(history, arguments); | ||
updateURL(); | ||
}; | ||
|
||
window.addEventListener('popstate', updateURL); | ||
}; |
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