1.0.10 • Published 6 years ago

shadowboxing v1.0.10

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

ShadowBoxing

npm version

Simple package for adding material-design-like shadow effects to React elements.

Installation

npm i shadowboxing

Type declarations are bundled with the package

Usage

Using the bashadowBoxing element with only the level attribute specified will yield material-design-like shadow effects.

import * as ReactDOM from "react-dom"
import ShadowBoxing from "shadowboxing"

ReactDOM.render(
  (
    <ShadowBoxing level={4}>
      Cool
    </ShadowBoxing>
  ),
  document.getElementById("root") as HTMLElement
)

Alternatively the element can be used as a wrapper to produce desired shadow effects and styles on an element

import * as ReactDOM from "react-dom"
import ShadowBoxing from "shadowboxing"

ReactDOM.render(
  (
    <ShadowBoxing shadowHorizontalOffset={4} style={{border: "solid black"}}>
      Nice
    </ShadowBoxing>
  ),
  document.getElementById("root") as HTMLElement
)

Things to Note

If the element you are puting in the bashadowBoxing element has any sort of border radius and inheritted background color styling, it's recommended that you add that border styling to the bashadowBoxing element instead; otherwise the background color of the parent element will also show on the bashadowBoxing element, resulting in the child element having rounded corners and the wrapping div of the bashadowBoxing element having pointy corners

import * as ReactDOM from "react-dom"
import ShadowBoxing from "shadowboxing"

ReactDOM.render(
  (
    <div style={{backgroundColor: "red"}}>
        <ShadowBoxing shadowHorizontalOffset={4} style={{border: "solid black", borderRadius: ".25rem"}}>
          This
        </ShadowBoxing>
        <ShadowBoxing shadowHorizontalOffset={4}>
          <div style={{border: "solid black"}}>
            Instead of this
          </div>
        </ShadowBoxing>
    </div>
  ),
  document.getElementById("root") as HTMLElement
)

Initially, some elements will not render correctly when put inside of the bashadowBoxing element due to the default display: "inline-block" styling of the div which wraps the child elements put inside of the bashadowBoxing element. If this is the case, the display property can be overridden by providing a style object with the desired overriding value

import * as ReactDOM from "react-dom"
import ShadowBoxing from "shadowboxing"

ReactDOM.render(
  (
    <ShadowBoxing level={8} style={{display: "block"}}>
      <SomeConflictingElement />
    </ShadowBoxing>
  ),
  document.getElementById("root") as HTMLElement
)
1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago