{"id":18421190,"url":"https://github.com/brybrophy/react-sorcerer","last_synced_at":"2025-04-07T14:31:38.279Z","repository":{"id":17278335,"uuid":"81612647","full_name":"brybrophy/react-sorcerer","owner":"brybrophy","description":"A react component and companion hook that builds a srcset for your img tags.","archived":false,"fork":false,"pushed_at":"2023-03-15T09:55:06.000Z","size":21799,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T19:43:43.844Z","etag":null,"topics":["image-processing","react","srcset"],"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/brybrophy.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-02-10T22:26:47.000Z","updated_at":"2023-01-11T01:10:49.000Z","dependencies_parsed_at":"2024-11-06T04:27:04.938Z","dependency_job_id":"0b2f9dbc-338e-4149-91fc-3f22f16865ef","html_url":"https://github.com/brybrophy/react-sorcerer","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brybrophy%2Freact-sorcerer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brybrophy%2Freact-sorcerer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brybrophy%2Freact-sorcerer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brybrophy%2Freact-sorcerer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brybrophy","download_url":"https://codeload.github.com/brybrophy/react-sorcerer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247669883,"owners_count":20976465,"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":["image-processing","react","srcset"],"created_at":"2024-11-06T04:24:41.295Z","updated_at":"2025-04-07T14:31:37.950Z","avatar_url":"https://github.com/brybrophy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Sorcerer\n\n![https://img.shields.io/github/license/brybrophy/react-sorcerer?color=blue](https://img.shields.io/github/license/brybrophy/react-sorcerer?color=blue) ![https://img.shields.io/npm/v/react-sorcerer](https://img.shields.io/npm/v/react-sorcerer) ![https://img.shields.io/bundlephobia/minzip/react-sorcerer](https://img.shields.io/bundlephobia/minzip/react-sorcerer) ![https://img.shields.io/librariesio/release/npm/react-sorcerer](https://img.shields.io/librariesio/release/npm/react-sorcerer)\n\nReact Sorcerer is a react component and companion hook that helps you use source sets for your img tags.\n\nSource sets work by using a set of image sources to allow the browser to make a calculated decision and display the most optimal image for the current screen size. They increase site performance, and save your users bandwidth. They are like the Goldilocks of image optimization.\n\n### Demo\n\n![react-sorcerer-demo](https://media.giphy.com/media/L2MvvdegguOwzUZV0h/giphy.gif)\n\n### Install\n\n```\n\nyarn add react-sorcerer\n\n```\n\n## Use as a Component\n\n```jsx\nimport { Sorcerer } from 'react-sorcerer';\n\n\u003cSorcerer\n  alt=\"an image\"\n  coverage={100}\n  src=\"https://dummyimage.com/1024x800/f00/fff\"\n  srcSetData={[\n    {\n      src: 'https://dummyimage.com/300x200/f00/fff',\n      width: 300,\n    },\n    {\n      src: 'https://dummyimage.com/400x300/f00/fff',\n      width: 400,\n    },\n    {\n      src: 'https://dummyimage.com/800x600/f00/fff',\n      width: 800,\n    },\n    {\n      src: 'https://dummyimage.com/1100x800/f00/fff',\n      width: 1100,\n    },\n  ]}\n/\u003e;\n```\n\n## Use as a Hook\n\n```jsx\nimport { useSorcerer } from 'react-sorcerer';\n\nconst imgSrcData = useSorcerer({\n  alt: 'an image',\n  coverage: 100,\n  src: 'https://dummyimage.com/1024x800/f00/fff',\n  srcSetData: [\n    {\n      src: 'https://dummyimage.com/300x200/f00/fff',\n      width: 300,\n    },\n    {\n      src: 'https://dummyimage.com/400x300/f00/fff',\n      width: 400,\n    },\n    {\n      src: 'https://dummyimage.com/800x600/f00/fff',\n      width: 800,\n    },\n    {\n      src: 'https://dummyimage.com/1100x800/f00/fff',\n      width: 1100,\n    },\n  ],\n});\n\n\u003cimg {...imgSrcData} /\u003e;\n```\n\nNote: The `coverage` prop is used to help the browser determine which image to use at each screen size based on the image's width. A full width image would have a `coverage` of 100. An image in a 4 column grid might have a `coverage` of 25.\n\n### Props\n\n| Name       | Type                               | Required | Description                                                 |\n| ---------- | ---------------------------------- | -------- | ----------------------------------------------------------- |\n| alt        | `string`                           | `true`   | alt tag for the image                                       |\n| className  | `string`                           | `false`  | className for the image                                     |\n| coverage   | `number`                           | `true`   | an estimate of the display width of the image in percentage |\n| src        | `string`                           | `true`   | the src of the main image                                   |\n| srcSetData | `{ src: string, width: number }[]` | `true`   | an array of image sources and their width in pixels         |\n| style      | `object`                           | `false`  | style object for the image                                  |\n\n### License\n\nMIT\n\nCopyright (c) 2017 Bryan Brophy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrybrophy%2Freact-sorcerer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrybrophy%2Freact-sorcerer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrybrophy%2Freact-sorcerer/lists"}