Skip to content

Instantly share code, notes, and snippets.

View SebastianHGonzalez's full-sized avatar

Sebastian Gonzalez SebastianHGonzalez

View GitHub Profile
@SebastianHGonzalez
SebastianHGonzalez / ReactGrid.jsx
Last active May 26, 2019 00:07
ReactGrid using css grid and styled components
import React from "react";
import styled from "styled-components";
/**
* Copyright 2019 Sebastian Gonzalez
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
@SebastianHGonzalez
SebastianHGonzalez / transducers.js
Last active June 19, 2019 14:20
JS Transducers
const arrayReducer = (arr, elemnt) => arr.concat(elemnt)
arrayReducer.baseCase = []
const stringReducer = (string, string2) => string + string2
stringReducer.baseCase = ""
const functionReducer = (value, f) => f(value)
const mapTransducer = (f) => (reducer) => (acc, curr) => reducer(acc, f(curr))
const filterTransducer = (f) => (reducer) => (acc, curr) => f(curr) ? reducer(acc, curr) : acc
import React, { useState, useCallback } from "react";
import { func } from "prop-types";
import { connect } from "react-redux";
import useHistory from "./useHistory";
import FirstStep from "./FirstStep";
import SecondStep from "./SecondStep";
import ThirdStep from "./ThirdStep";
import FlowTransition from "./FlowTransition";
import React, { useMemo } from "react";
import { Spring, animated } from "react-spring/renderprops";
import { interpolate } from "flubber";
import { string, arrayOf, number } from "prop-types";
export default function MorphPath({ paths, currentPath, id, fill, transform, scale }) {
const interpolators = useMemo(
// https://reactjs.org/docs/hooks-reference.html#usememo
() =>
paths.map((path, index, array) =>
@SebastianHGonzalez
SebastianHGonzalez / Toggle.jsx
Created August 23, 2019 20:29
Toggle Switch Component
import React from "react";
import { string, bool, func } from "prop-types";
import styled from "styled-components";
const Input = styled.input`
display: none;
`;
const Slider = styled.span`
position: absolute;
@SebastianHGonzalez
SebastianHGonzalez / Button.jsx
Last active September 19, 2019 13:03
Styled Components Button for React
import React from "react";
import { string } from "prop-types";
import styled from "styled-components";
const Button = styled.button`
cursor: pointer;
font-weight: 600;
border-radius: 4px;
font-style: normal;
font-stretch: normal;
import React from "react";
import { string, bool } from "prop-types";
import styled from "styled-components";
import { Collapse } from "react-collapse";
const Legend = styled.legend`
display: flex;
width: 100%;
justify-content: space-between;
`;
@SebastianHGonzalez
SebastianHGonzalez / Table.jsx
Created August 23, 2019 20:37
Styled Components Table
import React from "react";
import styled from "styled-components";
import font from "styled/font";
export const Table = styled.table`
border-collapse: collapse;
background: ${({ theme }) => theme.table.head.background};
`;
import styled from "styled-components";
import Modal from "react-modal";
import { desktop, mobile } from "styled/media";
const StyledModal = styled(Modal)`
${mobile`
position: absolute;
top: 0;
left: 0;
right: 0;