Skip to content

Instantly share code, notes, and snippets.

View netgfx's full-sized avatar
💻
Working...

Michael Dobekidis netgfx

💻
Working...
View GitHub Profile
@netgfx
netgfx / ScrambleText.tsx
Created November 28, 2022 16:56
Framer Scramble text
import React from "react"
import { useInterval } from "usehooks-ts"
export const ScrambleText = (props) => {
const { children, size } = props
if (typeof children !== "string")
throw new Error("Children of scramble text must be a single string")
const [scrambledText, setScrambledText] = React.useState(
scrambleText(children.slice(0, size))
@netgfx
netgfx / Main.tsx
Created August 19, 2022 10:22
Framer + Airtable calculate total
export function getTotal(Component): ComponentType {
return (props) => {
const [store, setStore] = globalStore()
useEffect(() => {
var total = 0
var selectedData = []
_.forEach(store.selectedProducts, (item) => {
var filteredArray = _.filter(
@netgfx
netgfx / Main.tsx
Created August 19, 2022 10:13
Framer + Airtable add product smart components
export function addProducts(Component): ComponentType {
return (props) => {
const [store, setStore] = globalStore()
function toggleProduct(title) {
var products = _.cloneDeep(store.selectedProducts)
var index = store.selectedProducts.indexOf(title)
if (index != -1) {
products.splice(index, 1)
setStore({ selectedProducts: products })
@netgfx
netgfx / Chart.tsx
Last active August 19, 2022 08:40
Framer + Airtable Chart code component
import React from "react"
import { addPropertyControls, ControlType } from "framer"
import { useEffect, useRef, useState } from "react"
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
PointElement,
LineElement,
@netgfx
netgfx / Main.tsx
Last active August 19, 2022 08:22
Framer + Airtable Main overrides
import type { ComponentType } from "react"
import { useState, useEffect } from "react"
import { createStore } from "https://framer.com/m/framer/store.js@^1.0.0"
import { randomColor } from "https://framer.com/m/framer/utils.js@^0.9.0"
import { globalStore, callAPI, _data, sampleDataset } from "./globals.ts"
import _ from "lodash"
import Product from "../canvasComponent/haGPm0HUZ"
// Learn more: https://www.framer.com/docs/guides/overrides/
@netgfx
netgfx / globals.ts
Created August 19, 2022 07:51
Airtable+Framer Medium globals.ts
import { useEffect, useState } from "react"
import { createStore } from "https://framer.com/m/framer/store.js@^1.0.0"
// This will hold our state, this is where our data will be stored
export const globalStore = createStore({
total: 0,
selectedProducts: [],
productLabels: [],
chartData: {
labels: [],
@netgfx
netgfx / globals.ts
Created July 21, 2022 11:54
Framer zustand persist
import create from "zustand"
import { combine, persist } from "zustand/middleware"
export const globalStore = create(
persist(
combine(
{
myData: {},
isLoading: false,
},
@netgfx
netgfx / WrappedComponent.tsx
Created July 2, 2022 22:59
WrappedComponent MUI ShadowDom
import { ThemeProvider } from "@mui/styles";
import React, { PropsWithChildren, useEffect, useState } from "react";
import createCache from "@emotion/cache";
import { CacheProvider } from "@emotion/react";
import createTheme from "@mui/material/styles/createTheme";
export type Props = PropsWithChildren<{}>;
const WrappedComponent = (props: Props) => {
const container = document.getElementById("custom-root");
@netgfx
netgfx / ARScene.tsx
Created June 28, 2022 11:36
Framer ARScene
// Welcome to Code in Framer
// Get Started: https://www.framer.com/docs/guides/
import { forwardRef, Suspense, useEffect, useRef } from "react"
import { ARCanvas, DefaultXRControllers } from "@react-three/xr"
import { useLoader } from "@react-three/fiber"
import { Object3D } from "three"
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader"
import throttle from "lodash.throttle"
@netgfx
netgfx / kruskals.rb
Created June 27, 2022 14:49 — forked from jamis/kruskals.rb
An implementation of Kruskal's algorithm for generating mazes.
# --------------------------------------------------------------------
# An implementation of Kruskal's algorithm for generating mazes.
# Fairly expensive, memory-wise, as it requires memory proportional
# to the size of the entire maze, and it's not the fastest of the
# algorithms (what with all the set and edge management is has to
# do). Also, the mazes it generates tend to have a lot of very short
# dead-ends, giving the maze a kind of "spiky" look.
# --------------------------------------------------------------------
# NOTE: the display routine used in this script requires a terminal
# that supports ANSI escape sequences. Windows users, sorry. :(