{"id":13850418,"url":"https://github.com/trainline/react-skeletor","last_synced_at":"2025-04-04T06:10:12.136Z","repository":{"id":57167484,"uuid":"91596816","full_name":"trainline/react-skeletor","owner":"trainline","description":"Skeleton loading for React","archived":false,"fork":false,"pushed_at":"2019-10-30T17:24:35.000Z","size":1603,"stargazers_count":554,"open_issues_count":10,"forks_count":27,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-28T05:12:28.550Z","etag":null,"topics":["hoc","loading","react","skeleton"],"latest_commit_sha":null,"homepage":"https://trainline.github.io/react-skeletor/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trainline.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-17T16:18:20.000Z","updated_at":"2024-01-04T16:14:07.000Z","dependencies_parsed_at":"2022-08-30T13:10:09.613Z","dependency_job_id":null,"html_url":"https://github.com/trainline/react-skeletor","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trainline%2Freact-skeletor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trainline%2Freact-skeletor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trainline%2Freact-skeletor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trainline%2Freact-skeletor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trainline","download_url":"https://codeload.github.com/trainline/react-skeletor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128753,"owners_count":20888235,"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":["hoc","loading","react","skeleton"],"created_at":"2024-08-04T20:01:11.598Z","updated_at":"2025-04-04T06:10:12.116Z","avatar_url":"https://github.com/trainline.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/@trainline/react-skeletor.svg)](https://www.npmjs.com/package/@trainline/react-skeletor)\n[![license](https://img.shields.io/github/license/trainline/react-skeletor.svg)](https://github.com/trainline/react-skeletor/blob/master/LICENSE.md)\n[![Travis](https://img.shields.io/travis/trainline/react-skeletor.svg)]()\n[![npm](https://img.shields.io/npm/dm/@trainline/react-skeletor.svg)](https://www.npmjs.com/package/@trainline/react-skeletor)\n\n# React Skeletor\n\n![React-skeletor gif](/react-skeletor.gif)\n\nDisplay a skeleton preview of the application's content before the data get loaded.\n\u003cbr/\u003e\n- Inject dummy data into the provider\n- Define your loading status with the provider\n- Wrap leaf component with `createSkeletorElement` and define the style of the component when it is pending. The component will do all the magic for you, it will turn on / off the pending design for you.\n\n## [Demo](https://trainline.github.io/react-skeletor)\n\n## [Documentation](Documentation.md)\n\n### Basic usage\n\n1. Install via npm\n\n```\nnpm install @trainline/react-skeletor\n```\n\n2. Wrap the component (often a container) with the `createSkeletonProvider` high order component. This adds the loading status and style into the [context](https://facebook.github.io/react/docs/context.html) and inject fake data in the components subtree.\n\n```jsx\n// UserDetailPage.jsx\n\nimport { createSkeletonProvider } from '@trainline/react-skeletor';\n\nconst UserDetailPage = ({ user }) =\u003e (\n  \u003cdiv\u003e\n    ...\n    \u003cNameCard user={user} /\u003e\n    ...\n  \u003c/div\u003e\n)\n\nexport default createSkeletonProvider(\n  // Dummy data with a similar shape to the component's data\n  {\n    user: {\n      firstName: '_____',\n      lastName: '________'\n    }\n  },\n  // Predicate that returns true if component is in a loading state\n  ({ user }) =\u003e user === undefined,\n  // Define the placeholder styling for the children elements,\n  () =\u003e ({\n    color: 'grey',\n    backgroundColor: 'grey'\n  })\n)(UserDetailPage);\n```\n\n3. Use a skeleton element to toggle between the placehoder design and the real content depending on the loading status in the context.\n\n```jsx\n// NameCard.jsx\n\nimport { createSkeletonElement } from '@trainline/react-skeletor';\n\nconst H1 = createSkeletonElement('h1');\nconst H2 = createSkeletonElement('h2');\n\nconst NameCard = ({ firstName, lastName }) =\u003e (\n  \u003cdiv\u003e\n    \u003cH1 style={style}\u003e{ firstName }\u003c/H1\u003e\n    \u003cH2 style={style}\u003e{ lastName }\u003c/H2\u003e\n  \u003c/div\u003e\n)\n\nexport default NameCard;\n\n```\n\n### Contribute\nBefore opening any Pull Request please [post an issue](https://github.com/trainline/react-skeletor/issues/new) explaining the problem so that the team can evaluate if the Pull Request is relevant.\n\n[Learn more on medium](https://codeburst.io/achieve-skeleton-loading-with-react-a12404678030)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrainline%2Freact-skeletor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrainline%2Freact-skeletor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrainline%2Freact-skeletor/lists"}