var x = 5;
const name = 'Homer';
let homer = {
first: name,
last: 'Simpson'
};
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
| find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \; |
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 * as React from "react" | |
| import { useState, useEffect } from "react" | |
| // Hook | |
| let cachedScripts = [] | |
| export function useScript(src) { | |
| // Keeping track of script loaded and error state | |
| const [state, setState] = useState({ | |
| loaded: 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
| // hydrate.js | |
| function autoHydrate(Component, name) { | |
| if (isClient) { | |
| return Component; | |
| } | |
| return props => html` | |
| <component-root name=${name} /> | |
| <${Component} ...${props} /> | |
| <script |
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 React from 'react'; | |
| import { FederatedProvider } from './federated-provider'; | |
| import { scopes } from './scopes'; | |
| // This is an example app on how you would setup your Nextjs app | |
| const App = ({ Component }) => { | |
| return ( | |
| <FederatedProvider scopes={scopes}> | |
| <Component /> |
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
| /* | |
| * Stripe WebGl Gradient Animation | |
| * All Credits to Stripe.com | |
| * ScrollObserver functionality to disable animation when not scrolled into view has been disabled and | |
| * commented out for now. | |
| * https://kevinhufnagl.com | |
| */ |
This middleware does a few interesting things:
- Ensures a
urlshape in the zustand store, where we'll store URL information. - Assumes we will be storing our
urlstate slice in the?statesearch parameter after it has been stringified and base 64 encoded. - On creation, decodes stores state from the
?statesearch parameter into theurlslice of our store. - After each state update, updates the
?statesearch parameter with the newurlstate slice. - Sets up an event listener that listens for
popstateand re-decodes the state from the URL into our store.
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
| "use client"; | |
| import { cache, unstable_postpone } from "react"; | |
| import { preload } from "react-dom"; | |
| const loadImage = cache((src: string) => { | |
| return new Promise<void>((resolve, reject) => { | |
| const img = new Image(); | |
| img.src = src; |