UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

70 lines (59 loc) 2 kB
import constant from './constant.js'; import { withPath } from './path.js'; import asterisk from './symbol/asterisk.js'; import symbolCircle from './symbol/circle.js'; import symbolCross from './symbol/cross.js'; import symbolDiamond from './symbol/diamond.js'; import diamond2 from './symbol/diamond2.js'; import plus from './symbol/plus.js'; import symbolSquare from './symbol/square.js'; import square2 from './symbol/square2.js'; import symbolStar from './symbol/star.js'; import symbolTriangle from './symbol/triangle.js'; import triangle2 from './symbol/triangle2.js'; import symbolWye from './symbol/wye.js'; import times from './symbol/times.js'; // These symbols are designed to be filled. const symbolsFill = [ symbolCircle, symbolCross, symbolDiamond, symbolSquare, symbolStar, symbolTriangle, symbolWye ]; // These symbols are designed to be stroked (with a width of 1.5px and round caps). const symbolsStroke = [ symbolCircle, plus, times, triangle2, asterisk, square2, diamond2 ]; function Symbol(type, size) { let context = null, path = withPath(symbol); type = typeof type === "function" ? type : constant(type || symbolCircle); size = typeof size === "function" ? size : constant(size === undefined ? 64 : +size); function symbol() { let buffer; if (!context) context = buffer = path(); type.apply(this, arguments).draw(context, +size.apply(this, arguments)); if (buffer) return context = null, buffer + "" || null; } symbol.type = function(_) { return arguments.length ? (type = typeof _ === "function" ? _ : constant(_), symbol) : type; }; symbol.size = function(_) { return arguments.length ? (size = typeof _ === "function" ? _ : constant(+_), symbol) : size; }; symbol.context = function(_) { return arguments.length ? (context = _ == null ? null : _, symbol) : context; }; return symbol; } export { Symbol as default, symbolsFill, symbolsStroke }; //# sourceMappingURL=symbol.js.map