1.1.0 • Published 1 year ago

@reactour/mask v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Install

npm i -S @reactour/mask
# or
yarn add @reactour/mask

Usage

import { Mask } from '@reactour/mask'

function App() {
  const sizes = {
    width: 100,
    height: 100,
    top: 100,
    left: 100,
  }

  return (
    <>
      {/* ... */}
      <Mask sizes={sizes} />
    </>
  )
}

Mask

sizes: RectResult

type RectResult = {
  width: number
  height: number
  top: number
  left: number
  bottom?: number
  right?: number
}

Object containing size and position informations of where to position the Mask

className?: string

Class to apply to the Mask wrapper

highlightedAreaClassName?: string

Class to apply to the Highlighted area rect

padding?: number | number[]

Extra space to add in Mask calculations. Useful when calculating space from Element bounding rect and want to add more space.

Single number sets same space for all sides, otherwise an Array sets [x, y] or [top, x, bottom] or [top, right, bottom, left].

wrapperPadding?: number | number[]

Extra space to add between viewport with and height.

Single number sets same space for all sides, otherwise an Array sets [x, y] or [top, x, bottom] or [top, right, bottom, left].

onClick?: MouseEventHandler<HTMLDivElement>

Click handler for the Mask except the highlighted area.

onClickHighlighted?: MouseEventHandler<SVGRectElement>

Click handler for the Highlighted area.

maskId?: string

String to be assigned to the <mask /> element, otherwise an automatic unique id is assigned.

clipId?: string

String to be assigned to the <clipPath /> element, otherwise an automatic unique id is assigned.

styles?: StylesObj

Prop to customize styles for the different parts of the Mask using a function that allows to extend the base styles an take advantage of some state props.

Style keys and props available

keyprops
maskWrapper
maskAreax, y, width, height
maskRectwindowWidth, windowHeight, maskID
clickAreawindowWidth, windowHeight, clipID
highlightedAreax, y, width, height

Example

const styles = {
  maskWrapper: (base) => ({
    ...base,
    color: 'red',
  }),
  highlightedArea: (base, { x, y }) => ({
    ...base,
    x: x + 10,
    y: y + 10,
  }),
}
1.1.0

1 year ago

1.0.5

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.0

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.3.1

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago