Skip to content

Instantly share code, notes, and snippets.

View itsMapleLeaf's full-sized avatar

Darius itsMapleLeaf

View GitHub Profile
import * as React from 'react'
interface Props {
onSubmit: (account: string, password: string) => any
}
interface State {
account: string
password: string
}
@itsMapleLeaf
itsMapleLeaf / persist.js
Last active October 2, 2017 21:23
Simple persistence mixin creator for Vue
function persist(instanceProperty, storageKey) {
return {
created() {
const name = this.$options.name || 'Persistence'
storageKey = storageKey || `__persist__${name}__${instanceProperty}`
this.$watch(instanceProperty, {
deep: true,
handler(value) {
localStorage.setItem(storageKey, JSON.stringify(value))
router.get(':/category', async (req, res) => {
try {
const category = await Category.findOne({ /* ... */ })
const posts = await Post.findAll({ /* ... */ })
res.render(/* ... */)
} catch (err) {
console.error(err)
}
})
import React from 'react'
import { render } from 'react-dom'
import styled, { css } from 'styled-components'
const centerContent = css`
display: flex;
align-items: center;
justify-content: center;
`
import React from 'react'
import Yup from 'yup'
import { withFormik, FormikProps, FormikErrors } from 'formik'
interface FormValues {
email: string
password: string
}
const InnerForm = (props: FormikProps<FormValues>) => (
@itsMapleLeaf
itsMapleLeaf / styled-components-override-style.jsx
Last active December 25, 2017 09:45
My preferred way of doing style overrides in styled-components
const Button = styled.button`
border: 1px solid black;
${props => props.primary && primaryStyle};
${props => props.danger && dangerStyle};
${props => props.warning && warningStyle};
`
const primaryStyle = css`
color: white;
background: blue;
import * as React from 'react'
class Fetcher extends React.Component {
constructor() {
this.state = {
loading: true,
data: {},
}
}
"use strict";
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
import React from 'react'
class ScriptLoader extends React.Component {
state = {
loaded: false
}
componentDidMount() {
const script = document.createElement('script')
@itsMapleLeaf
itsMapleLeaf / App.js
Last active February 4, 2018 18:55 — forked from anonymous/App.js
Weather App
import React, { Component } from 'react';
import Aux from './hoc/Aux';
import './App.css';
import First from './Container/First';
class App extends Component {
constructor()
{
super();
this.state={