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
| module.exports = function() { | |
| return { | |
| presets: ['@babel/preset-react'], | |
| env: { | |
| production: { | |
| plugins: [["inline-dotenv",{ | |
| path: '.env.production' | |
| }]] | |
| }, | |
| development: { |
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
| console.table((function listAllEventListeners() { | |
| const allElements = Array.prototype.slice.call(document.querySelectorAll('*')); | |
| allElements.push(document); // we also want document events | |
| const types = []; | |
| for (let ev in window) { | |
| if (/^on/.test(ev)) types[types.length] = ev; | |
| } | |
| let elements = []; | |
| for (let i = 0; i < allElements.length; i++) { | |
| const currentElement = allElements[i]; |
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
| let cacheNames = await caches.keys() | |
| let cachesStorage = {} | |
| let promises = cacheNames.map(async cacheName => { | |
| const cache = await caches.open(cacheName) | |
| const cachedResources = await cache.keys() | |
| let storage = 0 | |
| for (const request of cachedResources) { | |
| const response = await cache.match(request) | |
| const blob = await response.blob() | |
| storage += blob.size |
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
| document.documentElement.innerHTML = ''; | |
| for (const obj of [document, window]) { | |
| for (const event of Object.values(getEventListeners(obj))) { | |
| for (const {type, listener, useCapture} of event) { | |
| obj.removeEventListener(type, listener, useCapture) | |
| } | |
| } | |
| } |
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
| new PerformanceObserver((list) => list.getEntries().map(console.log)).observe({type: 'layout-shift', buffered: true}) |
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 function getPaddingFromAspectRatio (aspectRatio) { | |
| return aspectRatio > 1 | |
| ? `min(calc(${aspectRatio * 100}%, 600px)` | |
| : `${Math.min(aspectRatio * 100, 100)}%` | |
| } |
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 function getImageSizeFromRef (ref) { | |
| const dimensionsString = /(\d+)x(\d+)/g.exec(ref) | |
| const width = dimensionsString[1] | |
| const height = dimensionsString[2] | |
| const dimensions = dimensionsString[0] | |
| const aspectRatio = height / width | |
| return { | |
| dimensions, | |
| width, |
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
| /* <figure> styles */ | |
| .root { | |
| margin: 2rem 0; | |
| padding: 0; | |
| position: relative; | |
| width: 100%; | |
| /* <img> styles */ | |
| @nest & img { | |
| object-fit: contain; |
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
| import { | |
| buildImageObj, | |
| getImageSizeFromRef, | |
| getPaddingFromAspectRatio, | |
| imageUrlFor | |
| } from '../../lib/utils' | |
| import styles from './figure.module.css' | |
| function Figure (props) { | |
| const imageDimensions = getImageSizeFromRef(props.asset._ref) |