0.11.1 • Published 9 months ago

@k8slens/lds-carousel v0.11.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Lens Design System – React Carousel component

Documentation

Browse the documentation at lensapp.github.io/lens-design-system.

Usage in React apps

  • run npm i -s @k8slens/lds @k8slens/lds-tokens @k8slens/lds-carousel
  • import @k8slens/lds-tokens/lib/es/font-imports.css in your React app to include fonts
  • import @k8slens/lds/lib/es/index.css in your React app to include core styles
  • import @k8slens/lds-carousel/lib/es/index.css in your React app to include Carousel styles
  • Use in a component:
import Carousel from "@k8slens/lds-carousel";

export const Component = () => (
  <Carousel>
    <img src="src" alt="Alt text" />
    <img src="src" alt="Alt text" />
    <img src="src" alt="Alt text" />
  </Carousel>
);

Autoplay first slide when it's a video

import Carousel from "@k8slens/lds-carousel";

export const Component = () => {
  const videoRef = React.useRef<HTMLVideoElement>(null);

  const [isVideoPlaying, setIsVideoPlaying] = useState(false);
  const [playing, setVideoPlaying] = useState(false);

  useEffect(() => {
    if (videoRef?.current && playing && !isVideoPlaying) {
      videoRef.current.play().catch((e) => {
        console.log(e);
      });
    }
  }, [videoRef, playing, isVideoPlaying]);

  return (
    <Carousel>
      <video
        key="video-1" // Key needs to include the word "video"
        ref={videoRef}
        autoPlay={playing}
        src="src"
        muted // Mute video to avoid autoplay issues
        onPlay={() => setIsVideoPlaying(true)}
        onPause={() => setIsVideoPlaying(false)}
        onEnded={() => setIsVideoPlaying(false)}
      />
      <img src="src" alt="Alt text" />
      <img src="src" alt="Alt text" />
      <img src="src" alt="Alt text" />
    </Carousel>
  );
}
0.11.0

10 months ago

0.11.1

9 months ago

0.10.4

10 months ago

0.10.2

10 months ago

0.10.3

10 months ago

0.9.3

12 months ago

0.10.1

11 months ago

0.10.0

11 months ago

0.3.0

1 year ago

0.1.2

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.9.0

12 months ago

0.7.2

1 year ago

0.5.4

1 year ago

0.8.0

12 months ago

0.7.1

1 year ago

0.6.2

1 year ago

0.5.3

1 year ago

0.9.2

12 months ago

0.9.1

12 months ago

0.7.3

12 months ago

0.5.0

1 year ago

0.4.0

1 year ago

0.7.0

1 year ago

0.6.1

1 year ago

0.5.2

1 year ago

0.6.0

1 year ago

0.5.1

1 year ago

0.1.0

1 year ago