This file contains hidden or 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
const storage = type => ({ | |
/** | |
* Asserts that sessionStorage or localStorage is available. | |
* | |
* Returns true even on quota exceeded error, so we won't silently ignore when we're using too much | |
* space, unless we haven't stored anything yet which will happen when the browser has set a very | |
* strict size limit (i.e. Safari Private Browsing sets quota to 0). | |
* | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API | |
*/ |
This file contains hidden or 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
function shallowEqual(objA, objB): boolean { | |
if (Object.is(objA, objB)) { | |
return true; | |
} | |
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { | |
console.log('not object'); | |
return false; | |
} |
This file contains hidden or 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
export default { | |
title: 'Basics/Button', | |
loaders: [() => import('./Button')], | |
}; | |
const Template = (args, { loaded }) => { | |
const { default: Button } = loaded; | |
return <Button {...args} />; | |
}; |
This file contains hidden or 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
window.addEventListener("message", (message) => { | |
try { | |
const data = JSON.parse(message.data) | |
if (!data || data.context !== "iframe.resize") return | |
const url = new URL(data.src) | |
for (const key of [...url.searchParams.keys()]) { | |
if (!["path", "id", "args"].includes(key)) url.searchParams.delete(key) | |
} | |
for (const el of document.querySelectorAll(`iframe[src^="${url.href}"]`)) { | |
el.style.height = `${data.height}px` |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Storybook embed example</title> | |
<script> | |
window.addEventListener("message", (message) => { | |
try { | |
const data = JSON.parse(message.data) | |
if (!data || data.context !== "iframe.resize") return | |
const url = new URL(data.src) |
OlderNewer