0.7.2 • Published 12 months ago

@volvo-cars/react-layout-utils v0.7.2

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
12 months ago

React Layout Utils

Questions? Ask in Slack #vcc-ui

@volvo-cars/react-layout-utils

This package exposes useful utility hooks that can be use to help you with layout concerns.

Installation

💡 This package includes Typescript definitions


useElementDimensions

Useful for obtaining static render-time dimensions of a given DOM element. Returns a ref and Dimensions object.

NameDescriptionTypeDefault Value
disabledIf true, hook does not refresh dimensionsbooleanfalse
throttleA debounce interval to limit the frequency of dimension updatesnumber0

useResizeObserver

Useful for obtaining dynamic dimensions of a DOM element, where you need to act upon dimension changes in real time. Returns ref, width, and height.

NameDescriptionTypeDefault Value
refA ref to observeundefined \| RefObject \| HTMLElementundefined
boxThe box model to use for observation.undefined \| "border-box" \| "content-box" \| "device-pixel-content-box"content-box
onResizeA callback receiving the element size. If given, then the hook will not return the size, and instead will call this callback.undefined \| ({ width?: number, height?: number }) => voidundefined
roundA function to use for rounding values instead of the default.numberMath.round()

Examples

Demonstration implementations of the hooks can be found in the Storybook.

0.7.2

12 months ago

0.7.1

1 year ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.2

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.3.1

2 years ago

0.1.0

2 years ago