Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-aspect-ratio-fence

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-aspect-ratio-fence

Set Custom Aspect Ratio to the Wrap Element(fence)

  • 1.8.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-aspect-ratio-fence

Build Status codecov NPM version

for more information, please see: Document

Installation

npm i react-aspect-ratio-fence

Components

  • AspectRatioFence (no IE support)

    Set ratio as css custom properties, and calc() the height of elementType's pseudo-element as placeholder. The defailt style will fit the children node into the placeholer.

    propstyperequireddefaultdescription
    elementTypestringfalsedivhtml tag name for the wrap component
    rationumbertrue1The aspect ratio of an image describes the proportional relationship between width and height
    classNamestringfalseundefinedCustom class name
    childrenReactNodefalseundefinedcustom children node
  • AspectRatioFenceLegacy

    Caculate the height of innerElementType base on the width of outerElementType and ratio. The defailt style will fit the children node into the placeholer.

    propstyperequireddefaultdescription
    outerElementTypestringfalsedivhtml tag name for the outer component
    innerElementTypestringfalsedivhtml tag name for the inner component
    rationumbertrue1The aspect ratio of an image describes the proportional relationship between width and height
    classNamestringfalseundefinedCustom class name
    childrenReactNodefalseundefinedcustom children node
  • SquareFence

    Set height of elementType's pseudo-element to the value of elementType's width. The defailt style will fit the children node into the placeholer.

    propstyperequireddefaultdescription
    elementTypestringfalsedivhtml tag name for the wrap component
    classNamestringfalseundefinedCustom class name
    childrenReactNodefalseundefinedcustom children node

Way to Ride

  • Common jS
// import from package entry point
const uc = require('react-aspect-ratio-fence')
require('react-aspect-ratio-fence/css/style.css')

  <uc.AspectRatioFence {...props} />
  <uc.SquareFence {...props} />
// only import specific component
const AspectRatioFence = require('react-aspect-ratio-fence/lib/components/AspectRatioFence')
require('react-aspect-ratio-fence/css/components/AspectRatioFence/style.css')

  <AspectRatioFence {...props} />
  • ESM
// import from package entry point
import { AspectRatioFence, SquareFence } from 'react-aspect-ratio-fence'
import 'react-aspect-ratio-fence/css/style.css'

  <AspectRatioFence {...props} />
  <SquareFence {...props} />
// only import specific component
import AspectRatioFence from 'react-aspect-ratio-fence/es/components/AspectRatioFence'
import 'react-aspect-ratio-fence/css/components/AspectRatioFence/style.css'

  <AspectRatioFence {...props} />

Development by storybook

npm install
npm start storybook
  • configuration files list in .storybook directory
  • story files list in .stories directory

Test with Jest and Puppeteer

npm run test
  • __tests__
    • unit test running by jest
    • use test:update to update jest snapshot

Keywords

FAQs

Package last updated on 21 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc