1.1.2 • Published 6 years ago

svag v1.1.2

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

svag

npm version

svag is the ultimate collection of SVaG elements which can be used to create mockups of the UI by dynamically generating SVGs. It contains all packages from the @svag scope.

yarn add -E svag

Table Of Contents

API

The package is available by importing its named exports which are the components. The library methods can be imported from svag/lib alias.

import {
  Window,
  Shadow,
  Toolbar,
} from 'svag'
import {
  makeElement,
  roundedCorner,
  minify
  svg,
  rect,
} from 'svag/lib'

Window(  options: WindowOptions,): string

Creates a @svag/window.

WindowOptions

NameTypeDescriptionDefault
content*stringThe content to display inside of the window.-
width*numberThe width of the content.-
height*numberThe height of the content.-
backgroundColorstringThe color of the window.#000000
foregroundColorstringThe foreground color of the container group which will hold the content.#FFFFFF
noStretchbooleanDo not stretch the SVG when embedded as an image. This is achieved by explicitly setting width and height attributes on the svg element.false
titlestringAn optional title for the window.-
attributesobjectAny additional attributes to set on the holder of the content, e.g., font-family.-
minWidthnumberThe minimum width that the window should take. If the content's width is greater than this value, the height will adjust to the content.-
minHeightnumberThe minimum height that the window should take. If the content's height is greater than this value, the height will adjust to the content.-
paddingYnumberThe padding on the Y-axis (top and bottom).5
paddingXnumberThe padding on the X-axis (left and right).5
noShadowbooleanDisable the dropping shadow.false
minifybooleanRemove whitespace between tags (e.g., between > and <). If there are any problems with generated SVG, this could be disabled.true

Shadow(  options: ShadowOptions,): { translate: string, shadow: string }

Creates a @svag/shadow. It will be able to resize on mobile Safari without the window's contents loosing quality.

ShadowOptions: Options to generate macOS like shadow using a blur filter.

NameTypeDescriptionDefault
width*numberThe width of the window.-
height*numberThe height of the window.-
rxnumberThe x corner radius of a window which drops the shadow.6
rynumberThe y corner radius of a window which drops the shadow.6
offsetYnumberThe offset from the top of the window.25
stdDeviationnumberThe standard deviation for the blur. It will spread twice this distance in each direction.27.5

Toolbar(  options: ToolbarOptions,): string

Returns a new @svag/toolbar either with or without a title.

ToolbarOptions: Options to make a toolbar.

NameTypeDescriptionDefault
width*numberThe width of the toolbar.-
titlestringAn optional title to display in the toolbar.-

Lib

The @svag/lib has a number of methods to create dynamically generated SVGs.

  • makeElement: create a new SVG element.
  • roundedCorner: write a C directive of the path to make a rounded corner, e.g., to create rectangles with only some rounded corners.
  • minify: remove whitespace between tags.

Elements: For easier access to elements, some of them were converted into methods, along with their documentation. The autocompletion hints can be accessed by hitting ctrlspace combination when writing a call to any API function.

  • svg: make a complete svg image.
  • react: draw a rectangle.

TODO

  • Add a note about VS Code hints to the @svag/lib package.

Copyright

(c) SVaG 2018