Skip to content

Instantly share code, notes, and snippets.

View renatorib's full-sized avatar

Renato Ribeiro renatorib

View GitHub Profile
@renatorib
renatorib / toPairs.js
Created April 27, 2017 13:53
toPairs
const toPairs = obj => Object.keys(obj).reduce((acc, value) => [ ...acc, [value, obj[value]] ], []);
@renatorib
renatorib / Button.jsx
Last active March 27, 2017 20:40
Composable Button
import React from 'react';
type Props = {
type?: 'normal' | 'outline',
radius: 'square' | 'round' | 'circle',
size?: 'mini' | 'small' | 'normal' | 'large' | 'xlarge',
theme?: 'primary' | 'grey' | 'danger' | 'warning' | 'success' | 'info',
className?: string, // ever allow pass custom className
style?: string, // custom styles also
children: string,
@renatorib
renatorib / Button.jsx
Created March 10, 2017 04:16
Not composable component
import React from 'react';
type Props = {
isPrimary?: boolean,
isSecondary?: boolean,
isHeaderButton?: boolean,
children: string,
};
const Button = (props: Props) => {
@renatorib
renatorib / Button.jsx
Created March 10, 2017 04:12
Composable Button
import React from 'react';
import cn from 'classnames';
type Props = {
type?: 'normal' | 'outline',
radius: 'square' | 'round' | 'circle',
size?: 'mini' | 'small' | 'normal' | 'large' | 'xlarge',
theme?: 'action' | 'grey' | 'danger' | 'warning' | 'success' | 'info',
className?: string, // ever allow pass custom className
styles?: string, // custom styles also
@renatorib
renatorib / Button.jsx
Created March 10, 2017 03:48
A Button, better way
import React from 'react';
import cn from 'classnames';
type Props = {
type?: 'normal' | 'outline',
radius?: 'square' | 'round' | 'circle',
size?: 'mini' | 'small' | 'normal' | 'large' | 'xlarge',
theme?: 'action' | 'danger' | 'warning' | 'success' | 'info' | 'grey',
children: string,
};
@renatorib
renatorib / Button.jsx
Last active March 10, 2017 03:36
A Button, wrong way. 2.
import React from 'react';
import cn from 'classnames';
type Props = {
isSquare?: boolean,
isRound?: boolean,
isCircle?: boolean,
isOutline?: boolean,
color: string,
children: string,
@renatorib
renatorib / Button.jsx
Last active March 10, 2017 03:32
A Button, wrong way.
import React from 'react';
import cn from 'classnames';
type Props = {
type: 'square' | 'round' | 'circle' | 'outline',
color: 'red' | 'orange' | 'green' | 'lightgray',
children: string,
};
const Button = ({ children, type = 'square', color = 'red' }: Props) => {
@renatorib
renatorib / api.js
Last active February 23, 2016 17:28
api
var Api = {
request: function(method, url, data, hooks){
hooks = hooks || {};
fail = hooks.fail || function(){};
done = hooks.done || function(){};
always = hooks.always || function(){};
before = hooks.before || function(){};
spinner = hooks.spinner || false;
reloadOnSuccess = hooks.reloadOnSuccess || false;
@renatorib
renatorib / change.php
Last active August 29, 2015 14:25
Change a phrase and store in session ever X seconds
<?php
session_start();
$phrases = array(
'Schizophasia, a mental condition characterized by incoherent babbling (compulsive or intentional, but nonsensical)',
'Logorrhea, a mental condition characterized by excessive talking (incoherent and compulsive)',
'Clanging, a speech pattern that follows rhyming and other sound associations rather than meaning',
'Graphorrhea, a written version of word salad that is more rarely seen than logorrhea in people with schizophrenia.'
);
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
*
* Licensed under The MIT License
*
* Copyright (c) La Pâtisserie, Inc. (http://patisserie.keensoftware.com/)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('FormHelper', 'View/Helper');