Skip to content

Instantly share code, notes, and snippets.

View renatorib's full-sized avatar

Renato Ribeiro renatorib

View GitHub Profile
@renatorib
renatorib / modal.jsx
Last active April 3, 2018 22:29
different ways to use two render props in one component
// passing object to render with two fns (opener & content, for example)
<Modal>
{{
opener: ({ open }) => <button onClick={open}>Open Modal</button>,
content: {{ close }) => <div><h2>Hi modal</h2> <button onClick={close}>Close me</button></div>
}}
</Modal>
// passing as children array
// https://stackblitz.com/edit/react-array-render-props
@renatorib
renatorib / drafts.md
Last active January 9, 2018 19:23
1.0 Powerplug drafts

Drafts


Mouse

or MousePos, or MouseTrack, idk what is best name yet

Mouse is binded in a element, and your ratio values are relative to this element.

IDEAL API
@renatorib
renatorib / mini-ramda.js
Last active April 22, 2020 05:04
mini-ramda
export const uncurry = (fn) => (...args) => {
let result = fn
for(i in args){
result = typeof result === 'function'
? result(args[i])
: result
}
return result
}
class ToggleOpened extends Component {
state = { opened: false }
toggle = () =>
this.setState(state => ({ opened: !state.opened }))
render() {
return this.props.render({
opened: this.state.opened,
toggle: this.toggle,
<WhatIsTheMeaningOfLife
context={someInput}
render={meaningOfLife => (
<MyBeautifulUI>
{meaningOfLife}
</MyBeautifulUI>
)}
/>
@renatorib
renatorib / react-bps-example.jsx
Last active September 25, 2017 22:17
React BPS Example
const breakpoints = {
900: { name: 'Tablet' },
600: { name: 'Mobile' },
}
render(
<Hello name="Desktop" bps={breakpoints} />,
document.getElementById('root')
)
@renatorib
renatorib / links.md
Last active July 19, 2017 05:17
React Router 4
@renatorib
renatorib / repos.md
Last active May 3, 2017 16:20
React Animation & Transition

Labels

  • I.D: Implementation Difficulty: 0 to 10 where 0 is super easy and 10 is super hard.
Name Stars I.D. Links Type
react-motion 8,738 ⭐ 8 Github Generic
react-flip-move 1,341 ⭐ 0 Github - Example List
@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
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) => {