Skip to content

Instantly share code, notes, and snippets.

View KirillTregubov's full-sized avatar
:shipit:
Working to improve every day!

Kirill Tregubov KirillTregubov

:shipit:
Working to improve every day!
View GitHub Profile
@KirillTregubov
KirillTregubov / touch-hitbox.css
Last active August 6, 2025 00:44
Tailwind utility for minimum WCAG AAA Target Size
/* More info: https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=If%20the%20target%20is%20the,44%20by%2044%20CSS%20pixels.&text=A%20footnote%20or%20an%20icon,from%20the%20minimum%20target%20size */
/* touch-hitbox or pointer-coarse:touch-hitbox (mobile-only) */
@utility touch-hitbox {
position: relative;
&:before {
content: "";
cursor: pointer;
position: absolute;
{
"arrowParens": "always",
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"plugins": [
"prettier-plugin-tailwindcss"
]
}
app.post<{
Body: {
userId: string
}
// More keys: https://fastify.dev/docs/latest/Reference/TypeScript/#using-generics (3rd step)
}>(
'/my-endpoint',
async ({ body }, reply) {
console.log(body) // <- is of correct type
}
import { createContext, useContext, useReducer } from 'react'
type State = {
isLoading: boolean
isSignout: boolean
userToken: string | null
}
type Action =
| { type: 'LOADED' }
@KirillTregubov
KirillTregubov / usePreserveScroll.tsx
Created July 16, 2022 15:21 — forked from Jak-Ch-ll/usePreserveScroll.tsx
Next.js - Preserve Scroll History
import { useRouter } from "next/router"
import { useEffect, useRef } from "react"
export const usePreserveScroll = () => {
const router = useRouter()
const scrollPositions = useRef<{ [url: string]: number }>({})
const isBack = useRef(false)
useEffect(() => {
@KirillTregubov
KirillTregubov / component.tsx
Last active July 12, 2022 21:00
Type-safe React functional component scaffolding
const Component: React.FC = () => {
return <></>
}