{"id":16049204,"url":"https://github.com/ayan4m1/react-geopattern","last_synced_at":"2025-03-18T04:31:08.648Z","repository":{"id":115427138,"uuid":"332591397","full_name":"ayan4m1/react-geopattern","owner":"ayan4m1","description":"GeoPattern wrapper for React","archived":false,"fork":false,"pushed_at":"2025-01-24T15:36:47.000Z","size":1382,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-13T14:08:05.865Z","etag":null,"topics":["geopattern","react"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayan4m1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2021-01-25T00:47:25.000Z","updated_at":"2025-01-24T15:36:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"407777fd-5f92-4703-977d-00a2a7c12fd5","html_url":"https://github.com/ayan4m1/react-geopattern","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"54bc95444f4318b472a2a9dbe28ca6d596d1a7ce"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayan4m1%2Freact-geopattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayan4m1%2Freact-geopattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayan4m1%2Freact-geopattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayan4m1%2Freact-geopattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayan4m1","download_url":"https://codeload.github.com/ayan4m1/react-geopattern/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902273,"owners_count":20366259,"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","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":["geopattern","react"],"created_at":"2024-10-09T00:14:55.503Z","updated_at":"2025-03-18T04:31:08.242Z","avatar_url":"https://github.com/ayan4m1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-geopattern\n\n[![Package Version](https://badge.fury.io/js/react-geopattern.svg)](https://www.npmjs.com/package/react-geopattern)\n[![codecov](https://codecov.io/gh/ayan4m1/react-geopattern/branch/main/graph/badge.svg?token=ZGX9D11EZO)](https://codecov.io/gh/ayan4m1/react-geopattern)\n\nUse [GeoPattern](https://github.com/btmills/geopattern) from [React](https://github.com/facebook/react).\n\n## features\n\n- Written in TypeScript\n- Adds less than 200 bytes at runtime\n- Supports CommonJS or ESM\n- Extensive unit testing\n- Zero-configuration caching of generated patterns\n\n## prerequisites\n\n- Node.js 16+\n- React 18\n\n## installation\n\n\u003e npm install --save geopattern@1 react-geopattern\n\n## usage\n\nThis package provides one primary hook, `useGeoPattern`. The first two arguments are the same as those of `GeoPattern.generate`, namely an input string and an options object. The third argument is optional and allows you to override the caching behavior by providing your own instance of `Map\u003cstring, Pattern\u003e`.\n\nThe most direct way of rendering the returned `Pattern` object is to call .toDataUrl() on it. Use the result in your CSS via the `style` prop or another prop that your style framework exposes (e.g. `sx` in Material-UI).\n\n## examples\n\nSimplest usage:\n\n```jsx\nimport { useGeoPattern } from 'react-geopattern';\n\nexport default function TestComponent() {\n  const pattern = useGeoPattern('input-string');\n\n  return \u003cdiv style={{ 'background-image': pattern.toDataUrl() }}\u003eTest\u003c/div\u003e;\n}\n```\n\nWith custom GeoPattern options:\n\n```jsx\nimport { useGeoPattern } from 'react-geopattern';\n\nexport default function TestComponent() {\n  const pattern = useGeoPattern('input-string', {\n    // any options that GeoPattern accepts\n    color: '#ff0000'\n  });\n\n  return \u003cdiv style={{ 'background-image': pattern.toDataUrl() }}\u003eTest\u003c/div\u003e;\n}\n```\n\nWith self-managed pattern cache:\n\n```jsx\nimport { useMemo } from 'react';\nimport { useGeoPattern } from 'react-geopattern';\n\nexport default function TestComponent() {\n  // you can invalidate the cache as needed with useMemo()\n  const cache = useMemo(() =\u003e new Map(), []);\n  const pattern = useGeoPattern('input-string', undefined, cache);\n\n  return \u003cdiv style={{ 'background-image': pattern.toDataUrl() }}\u003eTest\u003c/div\u003e;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayan4m1%2Freact-geopattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayan4m1%2Freact-geopattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayan4m1%2Freact-geopattern/lists"}