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
@shuvo-me
shuvo-me / useNetwork.ts
Last active February 17, 2024 05:07 — forked from KristofferEriksson/useNetwork.ts
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;
}
@shuvo-me
shuvo-me / useTextSelection.ts
Created February 12, 2024 15:23 — forked from KristofferEriksson/useTextSelection.ts
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[] => {
<textarea name="" id="mentionInput" cols="60" rows="2"></textarea>
<div id="mention-list">
</div>