Skip to content

Instantly share code, notes, and snippets.

View kitze's full-sized avatar
🚀
Solving problems

kitze 🚀 kitze

🚀
Solving problems
View GitHub Profile
@kitze
kitze / castSelf.ts
Created February 12, 2020 09:26
Cast Self for mobx-state-tree
import { Instance, cast } from 'mobx-state-tree';
export function castSelf<IStoreInstance, IParentModel>(
store: IStoreInstance,
model: IParentModel
) {
return cast<Instance<IParentModel>>(store as Instance<IParentModel>);
}
@kitze
kitze / use-resizer.ts
Created December 17, 2019 12:13
A hook that gives you resize logic that you can attach to an element
import { useLocalStore } from 'mobx-react-lite';
import { clamp } from 'lodash';
type Props = {
height: number;
maxHeight?: number;
minWidth: number;
minHeight: number;
measureWidth?: boolean;
measureHeight?: boolean;
@kitze
kitze / AnimatedTitle.tsx
Created October 1, 2019 16:05
AnimatedTitle
import React from 'react';
import { Reveal } from 'styles/reveal';
import * as T from 'styles/shared-components/text';
//styles
import * as S from './styles';
import * as A from 'styles/shared-components';
import * as L from 'layout-styled-components';
const AnimatedTitle: React.FC<{ size?: number }> = ({ children='', size = 50 }) => {
@kitze
kitze / reveal-animations.ts
Created October 1, 2019 16:02
reveal-animations
import { createGlobalStyle, keyframes } from 'styled-components';
import fadeIn from 'react-animations/lib/fade-in';
import slideInLeft from 'react-animations/lib/slide-in-left';
import slideInRight from 'react-animations/lib/slide-in-right';
export const reveals = {
fadeInUp: 'fade-in-up',
fadeIn: 'fade-in',
slideInLeft: 'slide-in-left',
@kitze
kitze / reveal.tsx
Created October 1, 2019 16:02
Revealhttps://github.com/kitze/tortilla/blob/master/src/styles/reveal.tsx
import { VisibilityProperty } from 'csstype';
import React, { useEffect, useState } from 'react';
import { useInView } from 'react-intersection-observer';
import { reveals } from 'styles/reveal-animations';
import { CSSObject } from 'styled-components';
export enum RevealMode {
Clone,
Wrap
}
@kitze
kitze / react-advanced-hooks.js
Last active March 3, 2020 09:35
React Advanced Hooks
import React, {useEffect, useState} from "react";
import { useEffect, useState } from "react";
export const useTimer = (initialValue = 0, duration = 1000, step = 1) => {
const [timer, setTimer] = useState(initialValue);
useEffect(() => {
const interval = setInterval(() => {
setTimer(timer => timer + step);
@kitze
kitze / app-styles.css
Created May 28, 2019 17:52
app styles
.App {
font-family: sans-serif;
}
body {
background-color: rgb(36, 36, 36);
color: white;
}
.article {
@kitze
kitze / fake-data-graphql.js
Last active May 27, 2019 18:02
Fake data for reactacademy.io GraphQL workshop
const data = {
users: [
{
id: "c91ec707-215c-473d-8187-a0bb06f12b8f",
name: "Lilian Keebler",
email: "[email protected]",
password: "software",
age: 41,
isEmployed: true
},
@kitze
kitze / data.json
Created April 7, 2019 13:03
data.json
{
"articles": [
{
"id": 1,
"title": "Hello world",
"body": "The content of the article"
},
{
"id": 2,
"title": "Hello there",
@kitze
kitze / speaking.mdx
Last active February 1, 2023 08:44
Speaking