Library.v2
|
A searchable repository of reusable code primitives, utility hooks, and architectural patterns for design engineers.
useDebounce.ts
export function useDebounce<T>(value: T, delay: number) {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
, delay);
return () => clearTimeout(handler);
, [value, delay]);
return debouncedValue;
}REACTPERFORMANCE
Last updated: 3d agotailwind.config.js
// Custom theme tokens
module.exports = {
theme: {
extend: {
boxShadow: {
'glass': '0 8px 32px 0 rgba(31, 38, 135, 0.37)',
,
backdropBlur: {
'xs': '2px',
}
}
}CSSCONFIG
Last updated: 1w agoerror_handler.rs
use actix_web::{error, HttpResponse};
use derive_more::Display;
#[derive(Debug, Display)]
pub enum CustomError {
#[display(fmt = "Internal Server Error")]
InternalServerError,
}
impl error::ResponseError for CustomError {}RUSTBACKEND
Last updated: 5h agouseIntersection.ts
const useIntersection = (element: any, rootMargin: string) => {
const [isVisible, setState] = useState(false);
useEffect(() => {
const observer = new IntersectionObserver(([entry]) => {
setState(entry.isIntersecting);
, { rootMargin });
element.current && observer.observe(element.current);
, []);
return isVisible;
};TYPESCRIPTDOM
Last updated: 12h ago