@svag/shadow
@svag/shadow
is a shadow from a window.
yarn add -E @svag/shadow
Table Of Contents
API
The package is available by importing its default function:
import shadow from '@svag/shadow'
shadow(
options: ShadowOptions,
): void
Creates a shadow for a window with given width and height.
ShadowOptions
: Options to generate macOS like shadow using a blur filter.
Name | Type | Description | Default |
---|---|---|---|
width* | number | The width of the window. | - |
height* | number | The height of the window. | - |
offsetY | number | The offset from the top of the window. | 25 |
stdDeviation | number | The standard deviation for the blur. It will spread twice this distance in each direction. | 27.5 |
import Shadow from '@svag/shadow'
const shadow = Shadow({
width: 250,
height: 250,
})
console.log(shadow)
<defs>
<filter x="-22%" y="-10%" width="144%" height="142%" id="shadow">
<feOffset dx="0" dy="25" in="SourceAlpha" result="so"/>
<feGaussianBlur stdDeviation="27.5" in="so" result="sb"/>
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0" type="matrix" in="sb" result="sm"/>
<feMerge>
<feMergeNode in="sm"/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</defs>
TODO
- API returns a string.
- Update the image refernce to display on NPM.
- Export types.
-
Cut example before
console.log
.
Copyright
(c) SVaG 2018