@liquid-js/qr-code-styling
Version:
Generate styled QR codes on web or in Node
55 lines (54 loc) • 1.78 kB
TypeScript
import { RecursivePartial } from '../types/helper.js';
import { Options } from '../utils/options.js';
export type ExtensionFunction = (svg: SVGElement, options: RecursivePartial<Options>) => void;
export declare class QRCodeStyling {
private options;
private container?;
private qr?;
private extension?;
private svgDrawingPromise?;
private qrSVG?;
get size(): {
width: number;
height: number;
} | undefined;
constructor(options?: RecursivePartial<Options>);
update(
/** The same options as for initialization */
options?: RecursivePartial<Options>): void;
append(
/** This container will be used for appending of the QR code */
container?: HTMLElement): void;
/**
*
* @example
*
* ```js
* const extension = (svg, options) => {
* const { width, height } = options;
* const size = Math.min(width, height);
* const border = options.document.createElementNS("http://www.w3.org/2000/svg", "rect");
* const borderAttributes = {
* fill: "none",
* x: (width - size + 40) / 2,
* y: (height - size + 40) / 2,
* width: size - 40,
* height: size - 40,
* stroke: "black",
* "stroke-width": 40,
* rx: 100
* };
* Object.keys(borderAttributes).forEach((attribute) => {
* border.setAttribute(attribute, borderAttributes[attribute]);
* });
* svg.appendChild(border);
* };
* ```
*/
applyExtension(
/** Extension is a function that takes svg and previously applied options and modifies an svg */
extension: ExtensionFunction): void;
deleteExtension(): void;
serialize(): Promise<string | undefined>;
private setupSvg;
}