{"id":23967928,"url":"https://github.com/the-bugging/react-use-presentation","last_synced_at":"2025-04-13T15:12:52.689Z","repository":{"id":40562659,"uuid":"337481198","full_name":"the-bugging/react-use-presentation","owner":"the-bugging","description":"Creates pure HTML or React presentations with a provided array of components and their time durations","archived":false,"fork":false,"pushed_at":"2023-03-09T02:27:53.000Z","size":29053,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-13T15:12:47.402Z","etag":null,"topics":["animation","frame","frames","hook","html5","powerpoint","ppt","pptx","presentation","react","slide","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-use-presentation","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/the-bugging.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-09T17:23:34.000Z","updated_at":"2023-02-26T19:01:45.000Z","dependencies_parsed_at":"2023-01-22T21:31:01.455Z","dependency_job_id":null,"html_url":"https://github.com/the-bugging/react-use-presentation","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-bugging%2Freact-use-presentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-bugging%2Freact-use-presentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-bugging%2Freact-use-presentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-bugging%2Freact-use-presentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-bugging","download_url":"https://codeload.github.com/the-bugging/react-use-presentation/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732487,"owners_count":21152852,"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":["animation","frame","frames","hook","html5","powerpoint","ppt","pptx","presentation","react","slide","typescript"],"created_at":"2025-01-06T23:57:04.998Z","updated_at":"2025-04-13T15:12:52.658Z","avatar_url":"https://github.com/the-bugging.png","language":"TypeScript","readme":"\u003cimg align=\"right\" alt=\"traffic\" src=\"https://pv-badge.herokuapp.com/total.svg?repo_id=olavoparno-react-use-presentation\"/\u003e\n\n# react-use-presentation\n\n\u003e Create pure HTML (React enriched if you will) presentations with a provided array of components and their time durations. The library will do the rest triggering a re-render per array item.\n\n[![NPM](https://img.shields.io/npm/v/react-use-presentation.svg)](https://www.npmjs.com/package/react-use-presentation)\n\n---\n\n| Statements                                                                    | Branches                                                                  | Functions                                                                   | Lines                                                               |\n| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------- |\n| ![Statements](https://img.shields.io/badge/statements-100%25-brightgreen.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-100%25-brightgreen.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-100%25-brightgreen.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-100%25-brightgreen.svg?style=flat) |\n\n## Table of Contents\n\n- [Running example](#running-example)\n- [Install](#install)\n- [Usage](#usage)\n- [Documentation](#documentation)\n- [Contributors](#contributors)\n- [License](#license)\n\n---\n\n## Running example\n\n| Plain                                                             | Video BG                                                                                |\n| ----------------------------------------------------------------- | --------------------------------------------------------------------------------------- |\n| ![Example](./assets/readme.gif)                                   | ![Example](./assets/readme-bg.gif)                                                      |\n| [Preview!](https://codesandbox.io/s/react-use-presentation-1c2du) | [Preview with BG video!](https://codesandbox.io/s/react-use-presentation-with-bg-d7f7j) |\n\n\u003e You may also find a running [example](./example) in this project which are served at [Github Pages](https://olavoparno.github.io/react-use-presentation).\n\n---\n\n## Install\n\n```bash\nnpm install --save react-use-presentation\n```\n\n---\n\n## Usage\n\n- Set up your presentation array with each object acting as a movie frame. See the example and contract below:\n\n```tsx\nexport const myFramesArray = [\n  {\n    component: \u003cdiv\u003eFirst Frame with 1 second duration\u003c/div\u003e,\n    time: 1000\n  },\n  {\n    component: \u003cdiv\u003eSecond Frame with 2 second duration\u003c/div\u003e,\n    time: 2000\n  },\n  {\n    component: \u003cdiv\u003eLast Frame without duration\u003c/div\u003e,\n  },\n  ...\n]\n```\n\n- To initialize a Presentation component:\n\n```tsx\nimport * as react from 'react';\nimport usePresentation from 'react-use-presentation';\nimport { myFramesArray1 } from './myFramesArray';\n\nexport default function App() {\n  const [Presentation] = usePresentation({\n    framesOptions: myFramesArray1,\n    startTrigger: false,\n  });\n\n  return \u003cPresentation /\u003e;\n}\n```\n\n- To initialize a **delayed** (in milliseconds) Presentation component:\n\n```tsx\nimport * as react from 'react';\nimport usePresentation from 'react-use-presentation';\nimport { myFramesArray2 } from './myFramesArray';\n\nexport default function App() {\n  const [DelayedPresentation] = usePresentation({\n    framesOptions: myFramesArray2,\n    startTrigger: true,\n    startDelay: 1000,\n  });\n\n  return \u003cDelayedPresentation /\u003e;\n}\n```\n\n- To initialize a **delayed** (in milliseconds) and also in **loop** Presentation component:\n\n```tsx\nimport * as react from 'react';\nimport usePresentation from 'react-use-presentation';\nimport { myFramesArray3 } from './myFramesArray';\n\nexport default function App() {\n  const [DelayedAndLoopedPresentation] = usePresentation({\n    framesOptions: myFramesArray3,\n    startTrigger: true,\n    startDelay: 1000,\n    isLoop: true,\n  });\n\n  return \u003cDelayedAndLoopedPresentation /\u003e;\n}\n```\n\n- To initialize multiple separated presentations and with its current frame and length:\n\n```tsx\nimport * as react from 'react';\nimport usePresentation from 'react-use-presentation';\nimport {\n  myFramesArray1,\n  myFramesArray2,\n  myFramesArray3,\n} from './myFramesArray';\n\nexport default function App() {\n  const [Presentation] = usePresentation({\n    framesOptions: myFramesArray1,\n    startTrigger: false,\n  });\n  const [DelayedPresentation] = usePresentation({\n    framesOptions: myFramesArray2,\n    startTrigger: true,\n    startDelay: 1000,\n  });\n  const [DelayedAndLoopedPresentation, currentLoopFrame, loopFramesLength] =\n    usePresentation({\n      framesOptions: myFramesArray3,\n      startTrigger: true,\n      startDelay: 1000,\n      isLoop: true,\n    });\n\n  return (\n    \u003c\u003e\n      \u003cPresentation /\u003e\n      \u003cDelayedPresentation /\u003e\n      \u003cdiv\u003e\n        \u003cp\u003e\n          Current frame: {currentLoopFrame}/{loopFramesLength}\n        \u003c/p\u003e\n        \u003cDelayedAndLoopedPresentation /\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n- You can also render elements as children (note that the component passed via array must support children):\n\n```tsx\nimport * as react from 'react';\nimport usePresentation from 'react-use-presentation';\nimport { myFramesArray1 } from './myFramesArray';\n\nexport default function App() {\n  const [PresentationWithChildren, currentFrame, framesLength] =\n    usePresentation({\n      framesOptions: myFramesArray1,\n      startTrigger: true,\n    });\n\n  return (\n    \u003cPresentationWithChildren\u003e\n      \u003cp\u003e\n        Current frame: {currentFrame}/{framesLength}\n      \u003c/p\u003e\n    \u003c/PresentationWithChildren\u003e\n  );\n}\n```\n\n- You can control when to start the presentation using `startTrigger` as a control. You can also specify a callback to when it finishes:\n\n```tsx\nimport * as react from 'react';\nimport usePresentation from 'react-use-presentation';\nimport { myFramesArray1 } from './myFramesArray';\n\nexport default function App() {\n  const [startTrigger, setStartTrigger] = React.useState(false);\n\n  const [PresentationTriggered] = usePresentation({\n    framesOptions: myFramesArray1,\n    startTrigger,\n    callback: () =\u003e setStartTrigger(false),\n  });\n\n  return (\n    \u003c\u003e\n      \u003cbutton type=\"button\" onClick={() =\u003e setStartTrigger(true)}\u003e\n        Click to start presenting!\n      \u003c/button\u003e\n      \u003cPresentationTriggered /\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n---\n\n## Documentation\n\n`usePresentation()` constructor:\n\n```tsx\ntype TFrameOptions = {\n  component: Component | null;\n  time?: number;\n};\n\ntype TUsePresentation = {\n  framesOptions: TFrameOptions[];\n  startTrigger: boolean;\n  startDelay?: number;\n  isLoop?: boolean;\n};\n\nusePresentation(TUsePresentation);\n```\n\n`usePresentation()` returns:\n\n- An array with 3 positions, described below:\n\n  1. The very animation component;\n  2. The current position of the frame (1 based);\n  3. The total quantity of frames;\n\n\u003e As the return is an array you may name each array position in an arbitrary way, e.g.:\n\n```tsx\nconst [MyLittleComponent, currentFrameLittle, totalLengthLittle] =\n  usePresentation();\n```\n\n`CSS selectors`:\n\n- Both frames with or without children have its own CSS selectors:\n\n1. Without children: `className=\"animation-frame\"`\n2. With children: `className=\"animation-frame with-children\"`\n\n- You can also pass in your own className:\n\n1. With or without children:\n\n```tsx\nconst [PresentationCustomCss] = usePresentation({\n  framesOptions: myFramesArray1,\n  startTrigger: true,\n});\n\nreturn \u003cPresentationCustomCss className=\"my-custom-class\" /\u003e;\n```\n\n- **The default behaviour is to automatically merge classNames.**\n\n---\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://olavoparno.github.io\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/7513162?v=4?s=70\" width=\"70px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eOlavo Parno\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-olavoparno\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/the-bugging/react-use-presentation/commits?author=olavoparno\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/the-bugging/react-use-presentation/commits?author=olavoparno\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n---\n\n## License\n\nreact-use-presentation is [MIT licensed](./LICENSE).\n\n---\n\nThis hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-bugging%2Freact-use-presentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-bugging%2Freact-use-presentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-bugging%2Freact-use-presentation/lists"}