Skip to content

Instantly share code, notes, and snippets.

@didair
didair / animation.js
Created August 2, 2022 01:19
useAnimatedDigit React 18+ hook - animates a numeric value
import { useState, useTransition } from 'react';
/**
* @param {number} initialValue Initial value
* @param {number} duration Animation duration in ms
*/
export const useAnimatedDigit = (initialValue = 0, duration = 250) => {
const [value, setValue] = useState(initialValue);
const [isPending, startTransition] = useTransition();
@didair
didair / _mixins.scss
Created May 11, 2018 13:57
mixins for iphones
@mixin phone($phone) {
@if $phone == ipx {
@media only screen
and (device-width : 375px)
and (device-height : 812px)
and (-webkit-device-pixel-ratio : 3) { @content; }
}
@else if $phone == ip {
@media only screen
and (device-width : 375px)
@didair
didair / slack_message.js
Last active November 7, 2021 22:48
Send slack messages with Javascript using the hook provided by the Slack API
var http = new XMLHttpRequest();
var HOOK_URL = 'https://hooks.slack.com/services/*********';
var data = {"text": "Your message here",
"attachments": [
] };
http.open("POST", HOOK_URL, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.send('payload='+JSON.stringify(data));