Skip to content

Instantly share code, notes, and snippets.

View nicolaslopezj's full-sized avatar
🎯
Focusing

Nicolás López Jullian nicolaslopezj

🎯
Focusing
View GitHub Profile
@nicolaslopezj
nicolaslopezj / en.js
Created June 1, 2015 19:04
Orion English Lang
i18n.map('en', {
global: {
save: 'Save',
create: 'Create',
logout: 'Logout',
back: 'Back',
cancel: 'Cancel',
delete: 'Delete',
confirm: 'Confirm',
choose: 'Choose',
@nicolaslopezj
nicolaslopezj / updater.js
Last active August 29, 2015 14:22
File Attribute -> Image Attribute
var info = function(image) {
var colorInfo = Colibri.extractImageColors(image, 'hex');
var width = image.naturalWidth;
var height = image.naturalHeight;
console.log(colorInfo);
return {
width: width,
height: height,
@nicolaslopezj
nicolaslopezj / delay.js
Last active October 22, 2016 05:32
Delay all meteor publications in localhost
const lag = true;
const waitingTime = 400;
Meteor.startup(function() {
if (!lag) return;
const rootUrl = process.env.ROOT_URL;
if (rootUrl !== 'http://localhost:3000/') {
return;
} else {
class Component extends React.Component {
render () {
if (this.props.isLoading) return <span/>
return (
<div>
{this.props.item.name}
</div>
)
}
}
import {Meteor} from 'meteor/meteor'
import {withData} from 'meteor/orionsoft:react-meteor-data'
import MyCollection from './my-collection'
@withData(({itemId}) => {
const handler = Meteor.subscribe('myPublication', itemId)
const isLoading = !handler.ready()
const item = MyCollection.findOne(itemId)
return {isLoading, item}
})
// with-post.js
import {withData} from 'meteor/orionsoft:react-meteor-data'
import {Meteor} from 'meteor/meteor'
import Posts from './posts'
export default withData(({postId}) => {
Meteor.subscribe('post', postId)
const post = Posts.findOne(postId)
return {post}
})
@nicolaslopezj
nicolaslopezj / Component.js
Created September 13, 2016 15:07
React component boilerplate
import React from 'react'
export default class Component extends React.Component {
static propTypes = {
}
render () {
return (
@nicolaslopezj
nicolaslopezj / calling.js
Last active October 12, 2016 23:41
Apollo React Post
/* Before */
export default graphql(query, {
options: ({ avatarSize }) => ({ variables: { avatarSize } })
})(Component)
/* After */
export default withGraphQL(query)(Component)
/* Before */
@withMutation(gql`mutation save ($title: String, $description: String) {
saveData (title: $title, description: $description) {
title
description
}
}`)
class Save extends React.Component {
async save () {
/* Before */
class Profile extends React.Component {
render () {
return <div>{this.props.data.currentUser.login}</div>
}
}
/* After */
class Profile extends React.Component {
render () {