This file contains hidden or 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
function t(strings, ...values) { | |
const string = strings.reduce((s, next, i) => `${s}%{${i}}${next}`); | |
return new IntlMessageFormat(string, 'en-us').format(values); | |
} | |
const person = 'Mike'; | |
const age = 28; | |
console.log(t`${person} is age ${age}`); |
This file contains hidden or 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 walk = require('babylon-walk'); | |
const babylon = require('babylon'); | |
const glob = require('glob'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const zip = (a, b, fn) => a.forEach((el, i) => fn(el, b[i], i)); | |
const promisify = fn => new Promise((res, rej) => { | |
const done = (err, val) => (err ? rej(err) : res(val)); |
This file contains hidden or 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
declare var __DEV__: boolean; | |
declare module 'react-native' { | |
declare type Color = string | number; | |
declare type Transform = | |
{ perspective: number } | | |
{ scale: number } | | |
{ scaleX: number } | |
This file contains hidden or 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
/* eslint no-restricted-syntax:0 */ | |
const hasOwnProperty = Object.prototype.hasOwnProperty; | |
function shallowDifferences(a, b) { | |
const result = []; | |
if (a === b) { | |
return result; | |
} |
This file contains hidden or 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
@Composable | |
fun App(appData: AppData) { | |
val derivedData = compute(appData) | |
Header() | |
if (appData.isOwner) { | |
EditButton() | |
} | |
Body { | |
for (item in derivedData.items) { | |
Item(item) |
This file contains hidden or 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
fun updateCount(count: Int) { | |
if (count > 0 && !hasBadge()) { | |
addBadge() | |
} else if (count == 0 && hasBadge()) { | |
removeBadge() | |
} | |
if (count > 99 && !hasFire()) { | |
addFire() | |
setBadgeText("99+") | |
} else if (count <= 99 && hasFire()) { |
This file contains hidden or 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
@Composable | |
fun BadgedEnvelope(count: Int) { | |
Envelope(fire=count > 99, paper=count > 0) { | |
if (count > 0) { | |
Badge(text="$count") | |
} | |
} | |
} |
This file contains hidden or 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
class Input : View() { /* ... */ } | |
class ValidatedInput : Input() { /* ... */ } | |
class DateInput : ValidatedInput() { /* ... */ } | |
class DateRangeInput : ??? { /* ... */ } |
This file contains hidden or 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
@Composable | |
fun <T> Input(value: T, onChange: (T) -> Unit) { | |
/* ... */ | |
} |
This file contains hidden or 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
@Composable | |
fun ValidatedInput(value: T, onChange: (T) -> Unit, isValid: Boolean) { | |
InputDecoration(color=if(isValid) blue else red) { | |
Input(value, onChange) | |
} | |
} |