This file contains 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
module.exports = new Set([ | |
'acid', | |
'acorn', | |
'alien-fire', | |
'all-for-one', | |
'alligator-clip', | |
'ammo-bag', | |
'anchor', | |
'angel-wings', | |
'ankh', |
This file contains 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
const isPropValid = require('@emotion/is-prop-valid').default | |
const pickBy = require('lodash.pickby') | |
module.exports = props => pickBy(props, (_, key) => isPropValid(key)) |
This file contains 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 { OrderedMap } from 'immutable' | |
import React, { useState, useEffect } from 'react' | |
import { LiveBlogStream } from './stream' // imaginary | |
import { LiveBlogPost } from '@financial-times/x-live-blog-post' | |
// e.g. <LiveBlogList initialPosts={dataFromCatchupRequest} eventUrl='https://next-live-event.ft.com/?eventid=the-world/liveblogs/2020-05-05-2/' /> | |
export function LiveBlogList({ serverConnection = false, initialPosts = [] }) { | |
const [posts, setPosts] = useState( | |
// using an OrderedMap means that new posts will be iterated |
This file contains 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
const gambit = require('@quarterto/gambit') | |
const scheme = { | |
carbon: {saturation: 15, hue: 75, lightness: 60}, | |
steel: {saturation: 20, hue: 220, lightness: 60}, | |
scarlet: {hue: 9}, | |
amber: {hue: 37, lightness: 70}, | |
lemon: {hue: 64, lightness: 80}, | |
lime: {hue: 100, lightness: 85}, | |
apple: {hue: 127, lightness: 80}, |
This file contains 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
const {hexToHsluv, hsluvToHex} = require('hsluv') | |
const interpolate = (a1, a2) => x => a1.map((c, i) => c + (a2[i] - c) * x) | |
const range = steps => Array.from({length: steps + 1}, (_, i) => i / steps) | |
const stopsToHsluv = (start, end) => { | |
const hStart = hexToHsluv(start) | |
const hEnd = hexToHsluv(end) | |
const throughZero = Math.abs(hStart[0] - hEnd[0]) > 180 |
This file contains 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
const {createElement: h} = require('react') | |
module.exports = (...styles) => styles.reduce( | |
(prev, component) => { | |
function Composed(props) { | |
return h(component, Object.assign({}, props, {as: prev})) | |
} | |
Composed.displayName = component.displayName || component.name | |
return Composed |
This file contains 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 { render, useState, html } from 'excise' | |
// props is attributes | |
const Counter = ({initialCount = 0}) => { | |
const [count, setCount] = useState(initialCount) | |
return html` | |
<button onClick=${() => setCount(count + 1)}>+</button> | |
${count} | |
` |
This file contains 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
#!/usr/bin/env node | |
const loadPackageJson = require('@financial-times/package-json') | |
const { execSync } = require('child_process') | |
const packageJson = loadPackageJson({ filepath: './package.json' }) | |
packageJson.requireDependency({ pkg: 'parcel-bundler', version: '^1.12.0', field: 'devDependencies' }) | |
packageJson.setField('scripts', { |
This file contains 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
module.exports = require('lodash.sortby') |
This file contains 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
const {diffChars} = require('diff') | |
const c = require('ansi-colors') | |
const Result = require('folktale/result') | |
module.exports = ({ expected, value }) => ( | |
expected === value | |
? Result.Ok() | |
: Result.Error( | |
c.red('- expected ') + c.green('+ actual\n') + | |
diffChars(expected, value) |