{"id":13626500,"url":"https://github.com/JonnyBurger/use-color-change","last_synced_at":"2025-04-16T14:33:43.783Z","repository":{"id":39922222,"uuid":"237751710","full_name":"JonnyBurger/use-color-change","owner":"JonnyBurger","description":"📈📉React hook for flashing a text when a value becomes higher or lower","archived":false,"fork":false,"pushed_at":"2022-05-21T08:42:03.000Z","size":424,"stargazers_count":32,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-26T06:20:38.666Z","etag":null,"topics":["change","color","flash","hook","numeric","react","value"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-color-change","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/JonnyBurger.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}},"created_at":"2020-02-02T10:07:28.000Z","updated_at":"2024-04-05T15:19:44.000Z","dependencies_parsed_at":"2022-08-31T21:00:41.380Z","dependency_job_id":null,"html_url":"https://github.com/JonnyBurger/use-color-change","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonnyBurger%2Fuse-color-change","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonnyBurger%2Fuse-color-change/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonnyBurger%2Fuse-color-change/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonnyBurger%2Fuse-color-change/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonnyBurger","download_url":"https://codeload.github.com/JonnyBurger/use-color-change/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249250821,"owners_count":21237961,"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":["change","color","flash","hook","numeric","react","value"],"created_at":"2024-08-01T21:02:20.604Z","updated_at":"2025-04-16T14:33:43.434Z","avatar_url":"https://github.com/JonnyBurger.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# use-color-change\n\n\u003e React hook for flashing a numeric value when it changes\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/JonnyBurger/use-color-change/blob/master/usecolorchange.gif?raw=true\"\u003e\n\u003c/p\u003e\n\n## Installation\n\nThis module can be used in any React project that supports hooks.\n\n```\nnpm i use-color-change\n```\n\n## Usage\n\nUse the hook and pass a number as the first parameter. Specify the colors you want to flash and how long the animation should take.\nThe return value of the hook has the type `{animation: string}`, you can pass it as a style for any element and also further customize it for example using `animation-timing-function` if you please.\n\n```tsx\nexport const App = () =\u003e {\n    const [value, setValue] = useState(0);\n    const colorStyle = useColorChange(value, {\n        higher: 'limegreen',\n        lower: 'crimson',\n        duration: 1800\n    });\n\n    return \u003cdiv style={colorStyle}\u003e{value}\u003c/div\u003e;\n};\n```\n\n## Function signature\n\n```ts\nuseColorChange(value: number, {\n    higher: string | null;\n    lower: string | null;\n    duration?: number | undefined;\n})\n```\n\n-   `value`: The numeric value for which the animation should be based on.\n-   `options`:\n    -   `higher`: The color which should be flashing when the value increases. You can pass `null` for no animation.\n    -   `lower`: The color which should be flashing when the value decreases. You can pass `null` for no animation.\n    -   `duration`: _(optional)_ How long the flash should take in miliseconds. Default is `1800`.\n    -   `property`: _(optional)_ either `color` or `background-color`, allowing you to animate the background color instead.\n\n### Author\n\n© Jonny Burger\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJonnyBurger%2Fuse-color-change","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJonnyBurger%2Fuse-color-change","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJonnyBurger%2Fuse-color-change/lists"}