Skip to content

Instantly share code, notes, and snippets.

View itelo's full-sized avatar
🎯
Focusing

itelo itelo

🎯
Focusing
View GitHub Profile
import React from 'react';
import {storiesOf} from '@storybook/react-native';
import Button from './Button';
storiesOf('Button', module)
.add('default button', () => <Button>Hello Storybook</Button>)
.add('button with prop color = red', () => (
<Button color="red">Hello Storybook</Button>
));
import React from 'react';
import {
StyleSheet,
TouchableOpacity,
Text,
TouchableOpacityProps,
} from 'react-native';
const styles = StyleSheet.create({
button: {
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
'@mycooluilib/assets': './src/assets',
'@mycooluilib/components': './src/components',
'@mycooluilib/utils': './src/utils',
@itelo
itelo / machine.js
Created April 11, 2020 23:43
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@itelo
itelo / machine.js
Created April 4, 2020 22:10
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'authentication',
initial: 'unauthorized',
context: {
user: null,
error: null,
},
states: {
unauthorized: {
on: {
@itelo
itelo / init.ts
Last active April 22, 2020 17:04
async function starting() {
print.info(`creating a react project`)
}
module.exports = {
name: 'init',
alias: ['init'],
run: async (toolbox: GluegunToolbox) => {
/**
* initing global/local variables
function copyTemplateToAppDirectory(tmpDir: string, appDirectory: string) {
return async (
chainData: ExtractPromiseGeneric<ReturnType<typeof getNpmPackageUrl>>
) => {
print.info(`copying template to ${appDirectory}`);
await fse.copy(`${tmpDir}/template`, appDirectory, {
overwrite: false,
errorOnExist: true
});
import * as hyperquest from 'hyperquest'
import { unpack } from 'tar-pack'
function extractStream(stream, dest) {
return new Promise((resolve, reject) => {
stream.pipe(
unpack(dest, err => {
if (err) {
reject(err)
} else {
import { execSync } from 'child_process'
async function getNpmPackageUrl(
npmTemplatePackageName: ExtractPromiseGeneric<
ReturnType<ReturnType<typeof getNpmTemplatePackageName>>
>
) {
return {
npmTemplatePackageName,
urlNpmPackage: execSync(`npm v ${npmTemplatePackageName} dist.tarball`)
function getNpmTemplatePackageName(templateName: string) {
return async () => {
if (templateName) {
return `cra-clone-${templateName}-template`;
}
return 'cra-clone-template';
}
}