Skip to content

Instantly share code, notes, and snippets.

View markosmk's full-sized avatar
🏠
Working from home

Mark markosmk

🏠
Working from home
View GitHub Profile
@markosmk
markosmk / card-expandable.tsx
Created February 21, 2025 05:20
esto lo hice para poder expandir una seccion de forma animada en altura, tomando tambien el card y boton de shadcn, el hook esta separado del card-expandable, porque tambien se puede usar con otra seccion que no sea un card
import * as React from 'react';
import { Card } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { useExpandable } from '@/hooks/use-expandable';
interface CardExpandableProps {
minHeight: number;
children: React.ReactNode;
}
@markosmk
markosmk / fade-in-scroll.tsx
Created February 18, 2025 14:03
una alternativa a @tanstack/react-virtual u otras librerias similares (si lo que quieres hacer es basico), es usar la API IntersectionObserver de JavaScript para implementar lazy loading o renderizado virtual
import * as React from 'react';
import { useIntersectionObserver} from './use-intersection-observer';
export function FadeInOnScroll() {
const elementRef = React.useRef<HTMLDivElement | null>(null);
const entry = useIntersectionObserver(elementRef, { threshold: 0.5 });
return (
<div
ref={elementRef}
@markosmk
markosmk / helper.ts
Last active November 29, 2024 19:21
codigos postales de argentina (postal codes)
import postalCodes from './postal_codes.json'
export function getProvinceByPostalCode(postalCode: number): string | null {
for (const province of postalCodes) {
if (province.code.includes(postalCode)) {
return province.nameProvince
}
}
return null
}
@markosmk
markosmk / ApiRestLocalStorage.class.js
Last active December 8, 2022 11:11
Simple Class to use LocalStorage how ApiRest
'use strict';
import { v4 as uuidv4 } from 'uuid';
const NAME_DB = 'accounts';
export class RestApiLocalStorage {
currentItems = [];
constructor() {
this.getData();