Skip to content

Instantly share code, notes, and snippets.

menus
nothing
prev -> personal-ui
init*
next -> avatar-block
avatar-block
avatar-block-init*
next -> avatar-block-fb-check?
# A traffic light
Powered
power failed -> Unpowered
Green*
tick -> Yellow
Yellow
tick -> Red
// this component freezes redux state for its children when `cold` is true
// after every render, it saves a snapshot of the last used redux state
// it also replacies the redux store with a 'proxy' store, which, when cold
// - no-ops all action dispatches
// - returns state from the snapshot
class Freeze extends Component<{ cold: boolean, children: Node }> {
context: {
store: Store,
};
static contextTypes = {
@threepointone
threepointone / 0 basics.md
Last active March 21, 2023 01:53
css-in-js

A series of posts on css-in-js

0. styles as objects

First, an exercise. Can we represent all of css with plain data? Let's try.

let redText = { color: 'red' };
@threepointone
threepointone / rn.js
Last active December 20, 2017 04:43
// rn.js
import {createElement} from 'react'
import {View, Text, Image} from 'react-native'
const map = { view: View, text: Text, image: Image }
export default function rn(type, props, ...children){
return createElement(map[type] || type, props, ...children)
}
@threepointone
threepointone / box.js
Last active September 20, 2017 09:38
react-motion + react-vr
/* @flow */
import React from 'react';
import { Motion, spring } from 'react-motion';
import {
AppRegistry,
Box,
View,
PointLight,
} from 'react-vr';
@threepointone
threepointone / rulesets.md
Last active September 14, 2017 18:54
rulegroup

Something about css-in-js libs I noticed, but no one really talks about. There exists an implicit idea of a grouped-ruleset, ie - a set of rulesets that apply either directly to an element, or are meant to be composed with other rulesets. an example with 2 libs -

// glamor

const button = css({
 color: 'red',
Configuring for host x86_64-apple-darwin16.6.0 ...
Configuring for target x86_64-apple-darwin16.6.0 ...
Using compiler gcc.
The C compiler is ANSI-compliant.
Checking the sizes of integers and pointers...
Wow! A 64 bit architecture!
This is a little-endian architecture.
Doubles can be word-aligned.
64-bit integers can be word-aligned.
Native division and modulus have round-towards-zero semantics, will use them.
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/8.1.0/bin/node',
1 verbose cli '/usr/local/bin/npmc',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'git://github.com/reasonml/reason-cli.git#beta-v-1.13.5' ]
2 info using [email protected]
3 info using [email protected]
4 notice CANARY npmc is experimental software. If you find an issue, please file it in the main npm repository, and call out that you were using npmc.
5 verbose npm-session 68f8ecdcf533092a
@threepointone
threepointone / glam-for-css-folks.md
Last active September 4, 2022 07:43
why css purists will love glam

I made a little styling lib called glam

(some features are in development)

one

let's start off with the simplest use case. we'll make an 'index.html' page, and assume we've setup our js bundler to output bundle.js