Skip to content

Instantly share code, notes, and snippets.

View guzmonne's full-sized avatar

Guzman Monne guzmonne

  • Uruguay
  • Montevideo, Uruguay
View GitHub Profile
@guzmonne
guzmonne / LoginForm.js
Created June 24, 2017 22:01
cognito-auth.LoginForm.js
(function(EventEmitter, tmpl){
/* LoginForm */
var $root = document.getElementById('root'),
$container = document.createElement('div');
EventEmitter.on('LoginForm:mount', function() {
$container.innerHTML = tmpl('LoginForm', {})
$root.appendChild($container)
})
@guzmonne
guzmonne / LoginForm.template.html
Created June 24, 2017 21:59
cognito-auth.LoginForm.template.js
<script type="text/html" id="LoginForm">
<div class="LoginForm">
<div class="LoginForm__title">Login</div>
<form class="LoginForm__form">
<div class="Control">
<label class="Control__label" for="user">User</label>
<input class="Control__input" name="user" type="text" placeholder="User" />
</div>
<div>
<label class="Control__label" for="password">Password</label>
@guzmonne
guzmonne / utils.js
Created June 24, 2017 21:56
cognito-auth.utils.js
(function(win){
// Simple JavaScript Templating
// John Resig - https://johnresig.com/ - MIT Licensed
// https://johnresig.com/blog/javascript-micro-templating/
//
// There are some minor modification done by me.
var cache = {};
function tmpl(str, data){
var fn;
@guzmonne
guzmonne / EventEmmiter.js
Created June 24, 2017 21:55
cognito-auth.EventEmitter.js
(function(win){
var events = {};
function on(event, listener) {
if (typeof events[event] !== 'object') {
events[event] = [];
}
events[event].push(listener);
}
@guzmonne
guzmonne / EventEmmiter.js
Created June 24, 2017 21:54
cognito-auth.EventEmitter.js
EventEmitter
@guzmonne
guzmonne / LoginForm.html
Created June 24, 2017 15:51
cognito-auth.LoginForm.html
<div class="LoginForm">
<div class="LoginForm__title">Login</div>
<form class="LoginForm__form">
<div class="Control">
<label class="Control__label" for="user">User</label>
<input class="Control__input" name="user" type="text" placeholder="User" />
</div>
<div>
<label class="Control__label" for="password">Password</label>
<input class="Control__input" name="password" type="password" placeholder="Password" />
@guzmonne
guzmonne / index.html
Created June 24, 2017 14:12
cognito-auth.index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>AWS Cognito authentication example</title>
</head>
<body>
<h1>The web server is working fine</h1>
@guzmonne
guzmonne / SubjectBarsChart.js
Created April 15, 2017 02:57
Chart element example
import React from 'react'
import T from 'prop-types'
import Chart from './Chart.js'
import Background from './Background.js'
import Axis from './Axis.js'
import Bars from './Bars.js'
const SubjectBarsChart = ({data}) => (
<Chart
data={data}
import React from 'react'
import T from 'prop-types'
import Chart from './Chart.js'
import D3Background from './D3Background.js'
import D3XAxis from './D3XAxis.js'
import D3YAxis from './D3YAxis.js'
import D3Bars from './D3Bars.js'
const D3SubjectBarsChart = ({data}) => (
<Chart
@guzmonne
guzmonne / Chart.js
Created April 15, 2017 02:53
Chart.js
import React from 'react'
import T from 'prop-types'
import uniqueId from 'lodash/uniqueId'
import isArray from 'lodash/isArray'
import {IMargin, IScale, IAxisOptions} from './propTypes.js'
const d3 = Object.assign({},
require('d3-selection'),
require('d3-scale'),
require('d3-array')