Skip to content

Instantly share code, notes, and snippets.

View mmintel's full-sized avatar
👋
Looking for awesome opportunities

Marc Mintel mmintel

👋
Looking for awesome opportunities
View GitHub Profile
@mmintel
mmintel / ScrollReveal.js
Created March 1, 2023 07:35
React scroll based reveal
import { motion, useInView, useScroll, useTransform } from "framer-motion";
import { useElementViewportPosition } from "hooks/use-element-viewport-position";
import { useRef, useEffect, useState } from "react";
export const ScrollReveal = ({ offset = 0, once = true, children }) => {
const [initiallyVisible, setInitiallyVisible] = useState(false);
const [ended, setEnded] = useState(false);
const ref = useRef(null);
const isInView = useInView(ref);
const { position } = useElementViewportPosition(ref, offset);
@mmintel
mmintel / HttpService.ts
Last active June 14, 2021 09:55
Typescript HttpService Interface
export interface HttpService {
get<T = any>(url: string, options?: HttpOptions): Promise<T>;
post<T = any>(url: string, data?: {}, options?: HttpOptions): Promise<T>;
patch<T = any>(url: string, data?: {}, options?: HttpOptions): Promise<T>;
put<T = any>(url: string, data?: {}, options?: HttpOptions): Promise<T>;
delete<T = any>(url: string, options?: HttpOptions): Promise<T>;
}
export interface HttpOptions {
params?: HttpParams;
@mmintel
mmintel / condition.js
Created March 27, 2020 06:25
TinaCMS condition field
import React from 'react';
import styled from 'styled-components'
import { FieldsBuilder } from '@tinacms/form-builder'
const Condition = ({ input, field, form }) => {
const nestedFields = field.fields(input.value);
const conditionalFields = nestedFields.map(f => {
const fieldPath = field.name.split('.').slice(0, -1)
const name = fieldPath.concat(f.name).join('.')
@mmintel
mmintel / relation.js
Last active March 27, 2020 05:01
TinaCMS relation field
import React from "react"
import styled, { css } from "styled-components"
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"
import { AddIcon, DragIcon, ReorderIcon, TrashIcon } from "@tinacms/icons"
import {
padding,
color,
radius,
font,
IconButton,
@mmintel
mmintel / form.vue
Created September 12, 2018 07:45
Form submission with vue
<template lang="html">
<div>
<form @submit="handleSubmit">
<input
v-model="contactForm.name"
name="name"
type="text"
>
<input
v-model="contactForm.email"
@mmintel
mmintel / mail.js
Last active April 19, 2021 03:41
Netlify function to submit emails
const postmark = require("postmark"); // require mail service, postmark in this case
const client = new postmark.Client("XXXXXXXXXXXXXXXXXXXXXXXXXXXX"); // your postmark api key
const headers = {
"Access-Control-Allow-Origin" : "*", // better change this for production
"Access-Control-Allow-Methods": "POST",
"Access-Control-Allow-Headers": "Content-Type"
};
import Headroom from '../lib/headroom';
export default function init(app) {
const headroom = new Headroom({
nodes: document.queryAll('[data-headroom]'),
}).init();
const header = headroom.find('page-header');
if (header) {
header.onToggle((instance) => {
import View from './view';
import Model from './model';
import Controller from './controller';
export default class Tooltip {
constructor(options) {
this.model = new Model();
this.controller = new Controller(this.model);
this.view = new View(this.controller, options);
}
import Controller from '../shared/controller';
export default class ClipboardController extends Controller {
copy = () => {
this.model.isCopied = true;
if (this.onCopy && typeof this.onCopy === 'function') {
this.onCopy();
}
}
import View from './view';
import Model from './model';
import Controller from './controller';
export default class Clipboard {
constructor(options) {
this.model = new Model();
this.controller = new Controller(this.model);
this.view = new View(this.controller, options);
}