Skip to content

Instantly share code, notes, and snippets.

View floatrx's full-sized avatar
:octocat:
Looking for a new project.

Andrew Floatrx floatrx

:octocat:
Looking for a new project.
View GitHub Profile
@floatrx
floatrx / utils.ts
Created May 28, 2024 18:04
Tailwind lib utils
import { type ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
// Tailwind CSS classnames utility
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
@floatrx
floatrx / react.global.d.ts
Last active October 15, 2024 11:53
Global type definitions
import React from 'react';
// .env
declare namespace NodeJS {
interface ProcessEnv {
NODE_ENV: 'development' | 'production' | 'test';
}
}
// Global type declarations for React components

Just test

@floatrx
floatrx / DeleteNoteButton.tsx
Created June 28, 2024 14:35
useServerAction with examples #hook #nextjs
'use client';
import type { TNote } from '@/types/note';
import { Button } from '@nextui-org/button';
import { Trash2 } from 'lucide-react';
import { deleteNote } from '@/features/note/actions/deleteNote';
import { useServerAction } from '@/hooks/useServerAction';
@floatrx
floatrx / debounce.ts
Created June 29, 2024 13:58
Debounce
import { DEFAULT_DEBOUNCE_DELAY } from '@/config/const';
/**
* Debounce function
* @param fn - function to debounce
* @param delay - delay in milliseconds
* @returns debounced function
*/
export const debounce = <T extends AnyFn>(
fn: T,