Skip to content

Instantly share code, notes, and snippets.

View Grsmto's full-sized avatar

Adrien Denat Grsmto

View GitHub Profile
@Grsmto
Grsmto / react-table.d.ts
Created March 6, 2019 12:59
React Table v7 TS typings definition
// Type definitions for react-table 7
// Project: https://github.com/tannerlinsley/react-table#readme
// Definitions by: Grsmto <https://github.com/grsmto>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
declare module 'react-table' {
export type Cell = {
render: (type: string) => any;
getCellProps: () => any;
column: Column;
@Grsmto
Grsmto / useIsDragged.js
Last active December 14, 2021 17:58
React Hook to define if a mouse event is a drag or not
import React from "react"
export default function useIsDragged(ref, offset = 5) {
const isDragged = React.useRef(false)
const isDown = React.useRef(false)
const distance = React.useRef(0)
const mousePos = React.useRef({
x: 0,
y: 0,
})
@Grsmto
Grsmto / sanity-cheatsheet.md
Last active July 13, 2020 20:12
Sanity cheatsheet

Sanity.io CheatSheet

Copy content of document in clipboard

> sanity documents get document-id | pbcopy

Edit document from CLI

First make sure to define your editor using EDITOR=code (for vscode).

&gt; sanity documents create --id documentId --watch --replace

@Grsmto
Grsmto / CustomArrayFunctions.js
Last active June 23, 2021 16:54
Sanity custom ArrayFunctions component to limit length of Arrays
// Simple implementation of https://github.com/sanity-io/sanity/blob/21af6baffe88d57db32d0a05e048ef7d3d671523/packages/%40sanity/form-builder/src/inputs/ArrayInput/ArrayFunctions.tsx
import React from "react";
import DropDownButton from "part:@sanity/components/buttons/dropdown";
import Button from "part:@sanity/components/buttons/default";
import ButtonGrid from "part:@sanity/components/buttons/button-grid";
import styles from "./styles/ArrayInput.css";
export default class ArrayFunctions extends React.Component {
handleDropDownAction = (menuItem) => {