npm install @wethegit/react-marqueeImport this wherever it makes sense to, based on your project structure:
import "@wethegit/react-marquee/style.css"const YourComponent = () => {
const prefersReducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches
return (
<Marquee
className="marquee--modifier-class"
prefersReducedMotion={prefersReducedMotion}
reducedMotionSpeed={20}
>
{/* Good practice to add size of image to avoid stutter */}
<img src="image-1.png" alt="" width="500" height="500" />
<img src="image-2.png" alt="" width="500" height="500" />
<img src="image-3.png" alt="" width="500" height="500" />
</Marquee>
)
}| Prop | Type | Default value | Description |
|---|---|---|---|
| speed | Number | 50 | Controls the speed of the marquee animation. If prefersReducedMotion is true, speed defaults to reducedMotionSpeed. |
| reducedMotionSpeed | Number | 20 | A customisable value used to set the speed of the component if prefersReducedMotion is true. |
| prefersReducedMotion | Boolean | false | Whether the user prefers reduced motion. If true, the component will default to a much slower speed, unless a custom speed is specified using: reducedMotionSpeed. |
| playing | Boolean | true | Whether the marquee animation is playing or paused. |
| reverse | Boolean | false | Whether the marquee should animate from left to right. |
| className | String | Optional class added to the parent element. | |
| children | Node | The child elements rendered within the component. In the example above these are images, however they can be any type of element. |
This component uses the BEM methodology for CSS classNames — the block here being .marquee.
Use the prefersReducedMotion prop to serve up a reduced motion experience for your users who have that option enabled on their systems. The boolean prefersReducedMotion prop can be derived via the browser's matchMedia API, if true the marquee defaults to a much slower speed, unless reducedMotionSpeed is passed. This workflow is demonstrated in the Usage section above.
This package uses Changesets to manage versions, changelogs and publishing. Any PR that changes the published package (a bug fix, a new feature or a breaking change) should include a changeset.
To add one, run this from the root of the repo:
npm run changesetThe CLI will ask you to:
- Pick a bump type, following semver:
patch: bug fixes and internal changes that don't affect the APIminor: new, backwards-compatible features (for example, a new prop)major: breaking changes (for example, removing or renaming a prop, or changing a default)
- Write a summary. This text goes straight into
CHANGELOG.md, so write it for people who use the package: say what changed and, for breaking changes, how to migrate.
This creates a markdown file in .changeset/ with a random name, like this:
---
"@wethegit/react-marquee": patch
---
Fixed the marquee width calculation when children load after the first render.Commit this file with the rest of your changes. You can edit it by hand before merging, and a single PR can include more than one changeset.
Changes that don't affect the published package, like docs, CI or tooling updates, don't need a changeset.
When a PR with a changeset is merged into main, the release workflow opens (or updates) a Version Packages PR. That PR bumps the version in package.json and updates CHANGELOG.md. Merging the Version Packages PR publishes the new version to npm and creates a GitHub release.