This node module generates a buffer of a button png image based on a set of parameters. It is used in the Usabilla Themes Publisher to create feedback buttons.
yarn install
For generating a button we require these properties:
options.fontCssUrl
OR a font file url - options.fontFileUrl
(optional, will default to CSS url if both are defined)options.fontName
options.fontSize
options.backgroundColor
options.textColor
option.borderRadius
options.width
options.height
options.text
A string for the placement position of the button. The available options are: right, left, top, bottom. - options.edge
The method generate(options)
will generate a png buffer.
const options = {
fontCssUrl: '//fonts.googleapis.com/css?family=Open+Sans',
fontFileUrl: 'http://www.amazon.com/my-font.woff',
fontName: 'Open Sans',
fontSize: 18,
backgroundColor: '#000000',
textColor: '#fff',
borderRadius: 3,
width: 40,
height: 130,
text: 'Feedback',
edge: 'left'
};
const button = new ButtonGenerator(options);
button
.generate()
.then(buffer => console.log(buffer))