Reach UI is an accessible foundation for React applications and design systems.
The three equally important goals are to be:
- Accessible
- Composable
- Stylable
| function CopyButton({ value }) { | |
| let [copied, setCopied] = React.useState(); | |
| let hydrated = usePageIsHydrated(); | |
| React.useEffect(() => { | |
| let id = setTimeout(() => setCopied(false), 2000); | |
| return () => clearTimeout(id); | |
| }, [copied]); | |
| return ( | |
| <button |
| const cache = {} | |
| export default function useGlobalMemo (key, fn, deps) { | |
| if (!cache[key]) { | |
| cache[key] = { | |
| subs: 0, | |
| deps, | |
| value: fn(), | |
| } |
| //////////////////////////////////////////////////////////////////////////////// | |
| // Create a directory called "pages" next to | |
| // this file, put markdown files in there, and | |
| // then run: | |
| // | |
| // ``` | |
| // $ node build.mjs | |
| // ``` | |
| // | |
| // Then deploy the "build" directory somewhere. |
| ruby '2.7.1' | |
| gem 'rails', github: 'rails/rails' | |
| gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data | |
| # Action Text | |
| gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra' | |
| gem 'okra', github: 'basecamp/okra' | |
| # Drivers |
| // | |
| // See: https://kentcdodds.com/blog/profile-a-react-app-for-performance#build-and-measure-the-production-app | |
| // See: https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config | |
| const TerserPlugin = require('next/dist/compiled/terser-webpack-plugin'); | |
| module.exports = { | |
| webpack: (config, options) => { | |
| // | |
| // Use profiler-enabled React builds |
| import { | |
| React, | |
| } from "https://unpkg.com/es-react"; | |
| declare global { | |
| namespace JSX { | |
| interface IntrinsicElements { | |
| h1: any; | |
| div: any; | |
| h2: any; |
| // Example usage: | |
| // | |
| // void async function() { | |
| // let [clicks, onclick] = iterator() | |
| // document.querySelector('button').addEventListener('click', onclick) | |
| // for await (let click of clicks) console.log(click) | |
| // }() | |
| export default function iterator() { | |
| let done = false |
| /** | |
| * React-Native cross-platform elevations. | |
| * Based on https://ethercreative.github.io/react-native-shadow-generator/ | |
| * | |
| * Usage: | |
| * 1. Import "elevations" from this file | |
| * import { elevations } from "config/elevations"; | |
| * 2. Use it. Assuming you need an elevation of 2 (based on the Android | |
| * elevation standard), doing the following will cast the same shadow | |
| * on both platforms: |
| import { useState, useRef, useCallback } from 'react'; | |
| export const useSubmit = (fun: Function) => { | |
| const [isPending, setIsPending] = useState<boolean>(false); | |
| const pendingRef = useRef(null); | |
| const submit = useCallback((...args) => { | |
| if (pendingRef.current) { | |
| return; | |
| } |