Skip to content

Instantly share code, notes, and snippets.

View alanjohnson's full-sized avatar
💭
Doing the things!

Alan Johnson alanjohnson

💭
Doing the things!
View GitHub Profile
@alanjohnson
alanjohnson / Favorite.jsx
Created January 17, 2025 23:13
Animated Favorites Icon
import React from 'react';
import { motion } from "framer-motion";
function Favorite ({
isActive = false,
size = null,
style = {},
startColor = "#ffba00",
endColor = "#818181"
}) {
@alanjohnson
alanjohnson / Sidebar.jsx
Last active January 17, 2025 23:11
Sidebar Component Example
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components';
import Button from '../components/Button';
import { icons } from '../images/_icons';
const SidebarOverlay = styled.div`
width: ${props => props.$isOpen ? `100%` : `0px`};
height: 100vh;
position: fixed;
@alanjohnson
alanjohnson / memoize
Created April 22, 2019 01:02
memoize function
function memoize(fn) {
const cache = {};
return function(...args) {
if ( cache[args] ) {
return cache[args];
};
const result = fn.apply(this, args);
cache[args] = result;
return result;
}