Skip to content

Instantly share code, notes, and snippets.

View shuvo-me's full-sized avatar
🚀
crafting web with JavaScript

Naim Ahmed Shuvo shuvo-me

🚀
crafting web with JavaScript
View GitHub Profile
@KristofferEriksson
KristofferEriksson / useNetwork.ts
Created February 13, 2024 22:04
A React Typescript hook to get real-time network insights
import { useEffect, useState } from "react";
interface NetworkInformation extends EventTarget {
downlink?: number;
effectiveType?: "slow-2g" | "2g" | "3g" | "4g";
rtt?: number;
saveData?: boolean;
onchange?: EventListener;
}
@KristofferEriksson
KristofferEriksson / useLocation.ts
Created February 11, 2024 16:44
A React Typescript hook that provides real-time geolocation data, complete with heading and speed metrics
import { useEffect, useState } from "react";
interface LocationOptions {
enableHighAccuracy?: boolean;
timeout?: number;
maximumAge?: number;
}
interface LocationState {
coords: {
@KristofferEriksson
KristofferEriksson / useTextSelection.ts
Last active February 24, 2024 22:22
A React Typescript hook that tracks user text selections & their screen positions
import { useEffect, useState } from "react";
type UseTextSelectionReturn = {
text: string;
rects: DOMRect[];
ranges: Range[];
selection: Selection | null;
};
const getRangesFromSelection = (selection: Selection): Range[] => {
@KristofferEriksson
KristofferEriksson / useShare.ts
Created February 7, 2024 22:19
A React Typescript hook that let users share your content directly via native share dialogs
import { useCallback, useEffect, useState } from "react";
// Types for the useShare hook parameters
interface UseShareParams {
onShare?: (content: ShareParams) => void;
onSuccess?: (content: ShareParams) => void;
onError?: (error: any) => void;
fallback?: () => void;
successTimeout?: number;
}
@yorkfx
yorkfx / _media-queries.scss
Created December 14, 2013 23:51
media queries scss
// ---------------------------------------------------------------------------------------------------------------------
//
// Author: Rafal Bromirski
// www: http://paranoida.com/
// twitter: http://twitter.com/paranoida
// dribbble: http://dribbble.com/paranoida
//
// Licensed under a MIT License
//
// ---------------------------------------------------------------------------------------------------------------------