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

@stianlarsen/react-light-beam

v1.0.11

Published

A customizable React component that creates a light beam effect using conic gradients. Supports dark mode and various customization options.

Downloads

166

Readme

@stianlarsen/react-light-beam

🚀 New Feature Alert!

We've added a new prop: scrollElement. This allows you to specify which element should have the scroll listener attached, giving you greater flexibility in using the LightBeam component!

npm version

A customizable React component that creates a light beam effect using conic gradients. The component is fully responsive and supports both light and dark modes. Ideal for adding dynamic and engaging visual elements to your web applications.

Preview

LightBeam Component

A preview of @stianlarsen/react-light-beam

Installation

npm install @stianlarsen/react-light-beam

or

yarn add @stianlarsen/react-light-beam

Usage

import { LightBeam } from "@stianlarsen/react-light-beam";
import "your-css-file.css"; // Include the necessary styles

const App = () => {
  return (
    <div className="your-container-class">
      <LightBeam
        id="unique-lightbeam"
        className="your-lightbeam-class"
        colorDarkmode="rgba(255, 255, 255, 0.8)"
        colorLightmode="rgba(0, 0, 0, 0.2)"
        fullWidth={0.8}
        maskLightByProgress={true}
        invert={false}
        scrollElement={window} // New prop to specify scroll element
      />
      <YourContentHere />
    </div>
  );
};

export default App;

Props

| Prop Name | Type | Default Value | Description | | --------------------- | ---------------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | id | string | undefined | Optional string representing a unique ID for the LightBeam container. | | className | string | undefined | Optional string representing custom classes to be added to the LightBeam container. | | colorLightmode | string | rgba(0,0,0, 0.5) | Optional string representing the color of the light beam in light mode. | | colorDarkmode | string | rgba(255, 255, 255, 0.5) | Optional string representing the color of the light beam in dark mode. | | fullWidth | number | 1.0 | Optional number between 0 and 1 representing the maximum width the light beam can reach. | | maskLightByProgress | boolean | false | If true, the mask-image's linear gradient will start with the chosen color at 0% and the transparent part starting at 50%. As the user scrolls, it will dynamically change to have the transparent part at 95%, reducing the glow effect. If false, it will default to linear-gradient(to bottom, chosenColor 25%, transparent 95%). | | invert | boolean | false | Optional boolean to invert the scroll progress calculation. | | scrollElement | EventTarget or undefined | window | Optional prop for which element to attach the scroll listener to. This could be the window, document.body, or any other scrollable element. | | onLoaded | undefined or () => void | undefined | Optional function to run when the component has mounted |

Default Configuration

The component comes with the following default styles:

.react__light__beam {
  height: 500px;
  width: 100vw;
  transition: all 0.5s ease;
  will-change: auto;
}

These default styles ensure that the component is immediately visible when added to your application. However, for more effective use, you might want to customize its position and behavior.

Recommended Usage

For best results, it's recommended to position the LightBeam component as an absolutely positioned element within a relatively positioned container. This allows the light beam to cast light downwards over your content, creating a more dynamic and engaging visual effect.

Example:

<div className="container">
  <LightBeam className="lightBeam" />
</div>

And in your CSS or SCSS:

.container {
  position: relative;
  z-index: 1;

  .lightBeam {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100%; // Important: Ensure the beam covers the entire height
    z-index: -1;
    margin-top: -300px; // Adjust as needed to position the light beam above the content
  }
}

Dark Mode Support

The component automatically adjusts between light and dark modes based on the user's system preferences. You can pass different colors for light and dark modes using the colorLightmode and colorDarkmode props.

Example

<LightBeam
  id="lightbeam-example"
  className="custom-lightbeam"
  colorDarkmode="rgba(255, 255, 255, 0.8)"
  colorLightmode="rgba(0, 0, 0, 0.2)"
  fullWidth={0.5}
  maskLightByProgress={true}
  invert={true}
  scrollElement={document.body} // Example usage of the new scrollElement prop
/>

License

MIT © Stian Larsen