0.8.1 • Published 5 months ago

@react-visual/next v0.8.1

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

@react-visual/next react-visual

Renders images and videos into a container. Features:

  • Uses next/image to render images
  • Easily render assets using aspect ratios
  • Videos are lazyloaded (unless priority flag is set)

Install

yarn add @react-visual/next

Images will be rendered using next/image so expect to do configuration of remotePatterns for CMS hosted images.

Usage

import Visual from '@react-visual/next'

export default function Example() {
  return (
    <Visual
      image='https://placehold.co/300x150'
      video='https://placehold.co/300x150.mp4'
      aspect={300/150}
      sizes='100vw'
      alt='Example using placeholder images' />
  )
}

For more examples, read the Cypress component tests.

Props

Sources

PropTypeDescription
imagestringURL to an image asset.
videostringURL to a video asset asset.
placeholderDatastringA Data URL that is rendered before the image loads via next/image's blurDataURL.

Layout

PropTypeDescription
expandbooleanMake the Visual fill it's container via CSS using absolute positioning.
aspectnumberForce the Visual to a specific aspect ratio.
widthnumber, stringA CSS dimension value or a px number.
heightnumber, stringA CSS dimension value or a px number.
fitstringAn object-fit value that is applied to the assets. Defaults to cover.
positionstringAn object-position value.

Loading

PropTypeDescription
prioritybooleanSets next/image's priority and videos to not lazy load.
sizesstringSets next/image's sizes prop.
imageLoaderFunctionThis is passed through to next/image's loader prop.

Video

PropTypeDescription
pausedbooleanDisables autoplay of videos. This prop is reactive, unlike the paused property of the html <video> tag. You can set it to true to pause a playing video or set it to false to play a paused video.

Accessibility

PropTypeDescription
altstringSets the alt attribute or aria-label value, depending on asset type.

Theming

PropTypeDescription
classNamestringAdd a custom CSS class.
styleCSSPropertiesAdd additional styles.
0.8.1

5 months ago

0.8.0

5 months ago

0.7.1

5 months ago

0.7.0

5 months ago

0.6.0

6 months ago

0.5.1

8 months ago

0.5.0

8 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.3.4

9 months ago

0.3.3

9 months ago

0.3.2

9 months ago

0.3.1

9 months ago

0.3.0

9 months ago