{"id":25164373,"url":"https://github.com/conorluddy/crucai","last_synced_at":"2025-10-25T07:38:44.949Z","repository":{"id":276441596,"uuid":"929319790","full_name":"conorluddy/Crucai","owner":"conorluddy","description":"🪝 Crúcaí: Irish for hooks 🪝 Bare at the moment but I'll be building out a library of random, unusual, but sometimes useful, React Hooks","archived":false,"fork":false,"pushed_at":"2025-06-23T17:18:59.000Z","size":438,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-09T03:43:44.783Z","etag":null,"topics":["frontend","hooks","hooks-api-react","javascript","react","react-components","react-hooks","reactjs","tools","typescript","ui","utilities"],"latest_commit_sha":null,"homepage":"https://www.conor.fyi","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/conorluddy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-08T09:12:52.000Z","updated_at":"2025-03-17T19:57:00.000Z","dependencies_parsed_at":"2025-09-10T11:38:14.888Z","dependency_job_id":null,"html_url":"https://github.com/conorluddy/Crucai","commit_stats":null,"previous_names":["conorluddy/crucai"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/conorluddy/Crucai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conorluddy%2FCrucai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conorluddy%2FCrucai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conorluddy%2FCrucai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conorluddy%2FCrucai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conorluddy","download_url":"https://codeload.github.com/conorluddy/Crucai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conorluddy%2FCrucai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274455843,"owners_count":25288557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["frontend","hooks","hooks-api-react","javascript","react","react-components","react-hooks","reactjs","tools","typescript","ui","utilities"],"created_at":"2025-02-09T04:30:16.451Z","updated_at":"2025-10-25T07:38:39.892Z","avatar_url":"https://github.com/conorluddy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crúcai 🪝\n\n\u003e **Crúcai** - Irish for \"Hooks\" - A React Hooks library\n\nA collection of high-performance, zero-dependency (except for React), React hooks for building responsive and interactive UIs.\n\nThis is a [Turborepo](https://turbo.build/repo/docs) managed monorepo, with hooks as independent packages published to NPM.\n\n---\n\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/conorluddy/crucai/ci.yml) [![codecov](https://codecov.io/gh/conorluddy/crucai/branch/main/graph/badge.svg?token=WTHO1C6UL4)](https://codecov.io/gh/conorluddy/crucai) ![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fconorluddy%2Fcrucai%2Fmain%2F.github%2Ftype-coverage.json\u0026query=%24.percentString\u0026suffix=%25\u0026style=flat\u0026logo=typescript\u0026label=TS%20Coverage\u0026color=abff3d)\n![Last Commit](https://img.shields.io/github/last-commit/conorluddy/crucai) ![Version](https://img.shields.io/github/package-json/v/conorluddy/crucai)\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![NPM Version](https://img.shields.io/npm/v/crucai.svg)](https://www.npmjs.com/package/crucai)\n![TypeScript](https://img.shields.io/badge/TypeScript-4.9+-blue)\n![React](https://img.shields.io/badge/React-18.0+-blue)\n\n## 📚 Table of Contents\n\n- [Crúcai 🪝](#crúcai-)\n  - [📚 Table of Contents](#-table-of-contents)\n  - [🚀 Installation](#-installation)\n  - [🔌 Hooks Overview](#-hooks-overview)\n    - [Key Features:](#key-features)\n    - [Component API:](#component-api)\n    - [Options:](#options)\n    - [Key Features:](#key-features-1)\n    - [Options:](#options-1)\n  - [📝 License](#-license)\n\n## 🚀 Installation\n\nHooks can be installed individually, or as a full collection.\n\nInstall this whole repo\n\n```bash\nnpm install crucai\n```\n\nInstall only specific hook(s)\n\n```bash\nnpm install @crucai/use-scroll-tracker\nnpm install @crucai/use-fuzzy-filter\n...\n```\n\n## 🔌 Hooks Overview\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003euseScrollTracker\u003c/h3\u003e\u003c/summary\u003e\n\nA high-performance hook for tracking element visibility and position as users scroll.\n\n```tsx\nimport { useScrollTracker } from \"crucai\";\n\nfunction FadeInElement() {\n  const { ref, metrics } = useScrollTracker();\n\n  return (\n    \u003cdiv\n      ref={ref}\n      style={{\n        opacity: metrics.visibility.percentage / 100,\n        transform: `translateY(${(1 - metrics.visibility.percentage / 100) * 20}px)`,\n      }}\n    \u003e\n      This element fades in as it enters the viewport\n    \u003c/div\u003e\n  );\n}\n```\n\n#### Key Features:\n\n- **Visibility tracking**: Percentage visible, fully/partially visible states\n- **Position tracking**: Relative to viewport top, center, bottom\n- **Threshold detection**: Track when element crosses specific visibility points\n- **Scroll direction**: Detect up/down scrolling\n- **Scroll physics**: Velocity, acceleration, inertia measurements\n- **Entry/exit tracking**: Direction, timing, duration\n- **High performance**: Uses IntersectionObserver, throttling, and passive events\n\n#### Component API:\n\nThe hook also provides a component API using render props:\n\n```tsx\nimport { ScrollTracker } from \"crucai\";\n\nfunction AnimatedElement() {\n  return (\n    \u003cScrollTracker\u003e\n      {(metrics, ref) =\u003e (\n        \u003cdiv\n          ref={ref}\n          style={{\n            opacity: metrics.visibility.percentage / 100,\n          }}\n        \u003e\n          Animated content\n        \u003c/div\u003e\n      )}\n    \u003c/ScrollTracker\u003e\n  );\n}\n```\n\n#### Options:\n\n```tsx\nconst { ref, metrics } = useScrollTracker({\n  // Visibility thresholds to track (0-100)\n  thresholds: [0, 25, 50, 75, 100],\n\n  // Offset from top/bottom of viewport (e.g., for fixed headers/footers)\n  offsetTop: 0,\n  offsetBottom: 0,\n\n  // Custom scroll container instead of window\n  root: containerRef,\n\n  // Other options for fine-tuning\n  rootMargin: \"0px 0px 0px 0px\",\n  disabled: false,\n  throttleDelay: 0,\n\n  // Physics-based animation control\n  dynamics: {\n    inertiaDecayTime: 300,\n    maxVelocity: 1000,\n    easing: \"easeInOut\",\n    customEasingPoints: [0.33, 1, 0.68, 1],\n  },\n});\n```\n\n\u003e 💡 **Performance Tip:** The hook is optimized to prevent re-renders when metrics haven't changed significantly, making it suitable for scroll-based animations without performance degradation.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003euseFuzzyFilter\u003c/h3\u003e\u003c/summary\u003e\n\nA powerful hook for fuzzy text filtering with advanced matching capabilities.\n\n```tsx\nimport { useFuzzyFilter } from \"crucai\";\n\nfunction SearchableList({ items }) {\n  const { filteredItems, setQuery } = useFuzzyFilter({\n    items,\n    threshold: 2, // Max Levenshtein distance\n  });\n\n  return (\n    \u003cdiv\u003e\n      \u003cinput\n        type=\"text\"\n        onChange={(e) =\u003e setQuery(e.target.value)}\n        placeholder=\"Search items...\"\n      /\u003e\n      \u003cul\u003e\n        {filteredItems.map((item, index) =\u003e (\n          \u003cli key={index}\u003e{item}\u003c/li\u003e\n        ))}\n      \u003c/ul\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n#### Key Features:\n\n- **Fuzzy searching**: Finds close matches even with typos\n- **Levenshtein distance**: Controls how strict the matching is\n- **Performance optimized**: Uses trie data structure for efficient filtering\n- **Customizable**: Set match thresholds and search keys\n\n#### Options:\n\n```tsx\nconst { filteredItems, setQuery } = useFuzzyFilter({\n  // Items to filter (strings or objects)\n  items: [\"apple\", \"banana\", \"orange\"],\n\n  // If items are objects, specify which keys to search in\n  keys: [\"name\", \"description\"],\n\n  // Maximum Levenshtein distance for a match (default: 2)\n  threshold: 2,\n\n  // Initial search query (optional)\n  initialQuery: \"\",\n\n  // Whether to match entire query or individual words (default: false)\n  matchByWord: true,\n\n  // Sort results by relevance (default: true)\n  sortResults: true,\n});\n```\n\n\u003e 🔍 **Tip:** Using a lower threshold (1-2) provides stricter matching, while higher values (3+) allow more fuzzy results.\n\n\u003c/details\u003e\n\n## 📝 License\n\nThis project is licensed under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconorluddy%2Fcrucai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconorluddy%2Fcrucai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconorluddy%2Fcrucai/lists"}