Hard refresh after changing modes to see the image change from light mode to dark mode:
Image is hosted at this gist.
| import React, { useEffect } from 'react'; | |
| import { useSpring, animated } from 'react-spring'; | |
| const trans = (x, y, s) => `perspective(600px) rotateX(${x}deg) rotateY(${y}deg) scale(${s})`; | |
| export default function Floater({ children }) { | |
| const ref = React.createRef(); | |
| let height = 1; | |
| let width = 1; | |
| let xOffset = 1; |
| import React, { useState, useEffect } from 'react' | |
| import { render } from 'react-dom' | |
| import { useTrail, animated } from 'react-spring' | |
| import './styles.css' | |
| const config = { mass: 5, tension: 2000, friction: 200 } | |
| function Message({ items, next: Next }) { | |
| const [toggle, set] = useState(false); | |
| const [showNext, setShowNext] = useState(false); |
| import { ImageBackground, SafeAreaView, View } from "react-native"; | |
| import React from "react"; | |
| // the pièce de résistance | |
| const OptionalParent = ({ children, Parent, cond }) => | |
| Parent != null && cond | |
| ? React.cloneElement(Parent, null, children) | |
| : children; |
| <div class="bird"> | |
| <div class="head"></div> | |
| <div class="body"> | |
| <div class="wing"></div> | |
| </div> | |
| <div class="dams"> | |
| <div class="dam dam-1"></div> | |
| <div class="dam dam-2"></div> | |
| <div class="dam dam-3"></div> | |
| <div class="dam dam-4"></div> |
| import { createElement } from "react"; | |
| export function Box({ children, as = "div", ...props }) { | |
| return createElement(as, props, [...children]); | |
| } | |
| /* | |
| // example |
| function extendDeep(target) { | |
| // Run through rest parameters | |
| Array.prototype.slice.call(arguments, 1).forEach(function (source) { | |
| if (typeof target === "object") { | |
| if (typeof source === "object") { | |
| // If source is an array, only copy enumerable properties | |
| var keys = (Array.isArray(source) ? Object.keys(source) : Object.getOwnPropertyNames(source)); | |
| // Iterate over keys | |
| keys.forEach(function (key) { |
| import React from "react"; | |
| // prettier-ignore | |
| export interface BasicHtmlTableProps { head?: React.ReactNode[][]; body?: React.ReactNode[][]; foot?: React.ReactNode[][]; tStyle?: React.CSSProperties; p?(cell: React.ReactNode): Record<string, any>; } | |
| // prettier-ignore | |
| export const BasicHtmlTable = ({ head, body, foot, tStyle = { border: "1px solid black" }, p = (cell: any) => ({ key: Math.random(), children: cell, style: tStyle }) }: BasicHtmlTableProps) => { | |
| const headJsx = head?.map((r) => <tr {...p(r.map((c, i) => <th {...p(c)} />))}/>); // prettier-ignore | |
| const bodyJsx = body?.map((r) => <tr {...p(r.map((c, i) => <td {...p(c)} />))}/>); // prettier-ignore | |
| const footJsx = foot?.map((r) => <tr {...p(r.map((c, i) => <td {...p(c)} />))}/>); // prettier-ignore | |
| return ( | |
| <table style={tStyle}> |
Hard refresh after changing modes to see the image change from light mode to dark mode:
Image is hosted at this gist.