npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-lrc

v3.2.1

Published

The react component to display lyric from LRC.

Downloads

463

Readme

react-lrc version license

The react component to display lyric from LRC. See example or play on CodeSandbox.

2.x README

Feature

  • Auto scroll smoothly
  • Support multiple lrcs
  • User srcollable
  • Custom style
  • Typescript support

Install & Usage

npm install react-lrc
import { Lrc } from 'react-lrc';

const Demo = () => {
  // ...
  return (
    <Lrc
      lrc={lrc}
      lineRenderer={lineRenderer}
      currentMillisecond={currentMillisecond}
    />
  );
};

Reference

Common Component Props

lineRenderer: ({ index: number, active: boolean, line: Line }) => React.ReactNode

The method to render every valid line of parsed lrc. active means whether it is current line. Line is LrcLine when using Lrc component or is MultipleLrcLine when MultipleLrc.

currentMillisecond?: number

Current time of lrc, default -1.

verticalSpace?: boolean

Make active line always vertical-middle even start or end of line list, default false.

without verticalSpace:

with verticalSpace:

onLineUpdate?: ({ index: number, line: Line | null }) => void

Call this when current line changed. Line is LrcLine when using Lrc component or is MultipleLrcLine when MultipleLrc.

recoverAutoScrollInterval

The interval of recovering auto scroll after user scrolling. It is millisecond, default 5000.

onAutoScrollChange?: ({ autoScroll: boolean }) => void

There is a state which indicates whether or not it is auto-scroll, and which default value is true. When scrolling by user, it will be set to false. After recoverAutoScrollInterval milliseconds, it will be set to true automatically. onAutoScrollChange will be called when the state changed.

Component Lrc

lrc: string

The lrc.

Component MultipleLrc

lrcs: string[]

The lrc array.

Hook useRecoverAutoScrollImmediately

When user scroll, react-lrc will stop auto scroll during recoverAutoScrollInterval. useRecoverAutoScrollImmediately helps recover auto scroll immediately.

import { Lrc, useRecoverAutoScrollImmediately } from 'react-lrc';

const Demo = () => {
  const { signal, recoverAutoScrollImmediately } =
    useRecoverAutoScrollImmediately();

  return (
    <>
      <button type="button" onClick={recoverAutoScrollImmediately}>
        recover auto scroll immediately
      </button>
      <Lrc {...otherProps} recoverAutoScrollSingal={signal} />
    </>
  );
};

Q & A

How to prevent user scroll ?

const style = { overflow: 'hidden !important' };

<Lrc style={style} recoverAutoScrollInterval={0} {...otherProps} />;

How to hide scrollbar ?

.lrc {
  /* webkit */
  &::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  /* firefox */
  scrollbar-width: none;
}
<Lrc className="lrc" {...otherProps} />

License

MIT