Skip to content

Instantly share code, notes, and snippets.

View JamesGelok's full-sized avatar
:shipit:

James JamesGelok

:shipit:
View GitHub Profile
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;
@JamesGelok
JamesGelok / index.js
Created January 16, 2020 09:38
React Spring - Messages w/ Next
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);
@JamesGelok
JamesGelok / OptionalParentExample.js
Created May 5, 2020 21:20
Optional Parent Component that's wild & fun
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;
@JamesGelok
JamesGelok / index.html
Created October 19, 2020 13:58
Turkey 🦃
<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>
@JamesGelok
JamesGelok / Box.tsx
Created December 1, 2020 16:08
component for if you wanted to mix things up and select html by string... but still wanted it to look like React
import { createElement } from "react";
export function Box({ children, as = "div", ...props }) {
return createElement(as, props, [...children]);
}
/*
// example
@JamesGelok
JamesGelok / extendDeep.js
Created August 4, 2021 17:11 — forked from dalgard/extendDeep.js
Method for deep (recursive) extension of a given object with the properties of passed-in object(s) with support for standards-compliant getters and setters
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) {
@JamesGelok
JamesGelok / BasicHtmlTable.tsx
Last active August 4, 2021 18:29
intended for sandboxing
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}>
@JamesGelok
JamesGelok / tailwind.svg
Last active August 17, 2021 12:57
DarkMode Correct Tailwind SVG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JamesGelok
JamesGelok / GitHub-Light-Mode-Dark-Mode.svg
Last active August 16, 2021 23:27
GitHub Light Mode Dark Mode
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JamesGelok
JamesGelok / DARK-MODE-README.md
Last active August 16, 2021 23:32
Read me with light mode vs dark mode

Example

Hard refresh after changing modes to see the image change from light mode to dark mode:

Image is hosted at this gist.