Skip to content

Instantly share code, notes, and snippets.

View ndimatteo's full-sized avatar
💀
Imposter Syndrome

Nick DiMatteo ndimatteo

💀
Imposter Syndrome
View GitHub Profile
@ndimatteo
ndimatteo / _Sanity - Async Conditional Fields.md
Last active June 22, 2021 13:33
Sanity Conditional Fields (async)

Async Conditional Fields for Sanity

✨ Asynchronous ✨ multiple fields ✨ Sanity UI ✨ Easy! ✨

Show multiple fields in an object field, based on a condition set through the "options" object. Simply return true/false from "condition" function, even asynchronously!

@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) => {
@celsowhite
celsowhite / section-checker.js
Created May 28, 2020 19:27
Check section visibility as a user scrolls.
/*-----------------------
Offset
---
Get the offset of an element on the page relative to the document.
-----------------------*/
function offset(el) {
const rect = el.getBoundingClientRect(),
scrollTop = window.pageYOffset || document.documentElement.scrollTop;
return { top: rect.top + scrollTop, bottom: rect.bottom + scrollTop };
@claus
claus / _app.js
Created May 14, 2020 05:35
Restore scroll position after navigating via browser back/forward buttons in Next.js
import useScrollRestoration from "utils/hooks/useScrollRestoration";
const App = ({ Component, pageProps, router }) => {
useScrollRestoration(router);
return <Component {...pageProps} />;
};
export default App;
@ollietreend
ollietreend / acf-php-to-json.php
Last active April 22, 2024 11:12
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
*/
namespace ConvertAcfPhpToJson;
/**
* Add submenu item under 'Custom Fields'
@willpatera
willpatera / Google-Sheet-Form-Post.md
Last active May 3, 2024 12:57
Post to google spreadsheet from html form

Overview

This collection of files serves as a simple static demonstration of how to post to a google spreadsheet from an external html <form> following the example by Martin Hawksey

Depreciation Warning: This code is not maintained, and should be seen as reference implementation only. If you're looking to add features or update, fork the code and update as needed.

Run example

You should be able to just open index.html in your browser and test locally.