phosphor-solid
Version:
A clean and friendly icon family for Solid-js
117 lines (84 loc) • 4.33 kB
JavaScript
import { useContext } from 'solid-js';
import { IconContext } from '../lib/index.esm.js';
import { template, setAttribute, spread, insert } from 'solid-js/web';
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../_virtual/_rollupPluginBabelHelpers.js';
const _tmpl$ = template(`<svg><rect x="32.00781" y="48.00005" width="192" height="160" rx="8" stroke-width="24" stroke-linecap="round" stroke-linejoin="round" fill="none"></rect></svg>`, 4, true),
_tmpl$2 = template(`<svg><rect x="32.00781" y="48.00005" width="192" height="160" rx="8" opacity="0.2"></rect></svg>`, 4, true),
_tmpl$3 = template(`<svg><rect x="32.00781" y="48.00005" width="192" height="160" rx="8" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" fill="none"></rect></svg>`, 4, true),
_tmpl$4 = template(`<svg><rect x="24.00781" y="40" width="208" height="176" rx="16"></rect></svg>`, 4, true),
_tmpl$5 = template(`<svg><rect x="32.00781" y="48.00005" width="192" height="160" rx="8" stroke-width="12" stroke-linecap="round" stroke-linejoin="round" fill="none"></rect></svg>`, 4, true),
_tmpl$6 = template(`<svg><rect x="32.00781" y="48.00005" width="192" height="160" rx="8" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" fill="none"></rect></svg>`, 4, true),
_tmpl$7 = template(`<svg><rect x="32" y="48" width="192" height="160" rx="8" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" fill="none"></rect></svg>`, 4, true),
_tmpl$8 = template(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect></svg>`, 4);
var renderPathFor = function renderPathFor(weight, color) {
switch (weight) {
case "bold":
return function () {
var _el$ = _tmpl$.cloneNode(true);
setAttribute(_el$, "stroke", color);
return _el$;
}();
case "duotone":
return [_tmpl$2.cloneNode(true), function () {
var _el$3 = _tmpl$3.cloneNode(true);
setAttribute(_el$3, "stroke", color);
return _el$3;
}()];
case "fill":
return _tmpl$4.cloneNode(true);
case "light":
return function () {
var _el$5 = _tmpl$5.cloneNode(true);
setAttribute(_el$5, "stroke", color);
return _el$5;
}();
case "thin":
return function () {
var _el$6 = _tmpl$6.cloneNode(true);
setAttribute(_el$6, "stroke", color);
return _el$6;
}();
case "regular":
return function () {
var _el$7 = _tmpl$7.cloneNode(true);
setAttribute(_el$7, "stroke", color);
return _el$7;
}();
default:
console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".');
return null;
}
};
var Rectangle = function Rectangle(props, ref) {
var color = props.color,
size = props.size,
weight = props.weight,
mirrored = props.mirrored,
children = props.children,
restProps = _objectWithoutPropertiesLoose(props, ["color", "size", "weight", "mirrored", "children"]);
var _useContext = useContext(IconContext),
contextColor = _useContext.color,
contextSize = _useContext.size,
contextWeight = _useContext.weight,
contextMirrored = _useContext.mirrored,
restContext = _objectWithoutPropertiesLoose(_useContext, ["color", "size", "weight", "mirrored"]);
return function () {
var _el$8 = _tmpl$8.cloneNode(true),
_el$9 = _el$8.firstChild;
var _ref$ = ref;
typeof _ref$ === "function" ? _ref$(_el$8) : ref = _el$8;
setAttribute(_el$8, "width", size != null ? size : contextSize);
setAttribute(_el$8, "height", size != null ? size : contextSize);
setAttribute(_el$8, "fill", color != null ? color : contextColor);
setAttribute(_el$8, "transform", mirrored || contextMirrored ? "scale(-1, 1)" : undefined);
spread(_el$8, restContext, true, true);
spread(_el$8, restProps, true, true);
insert(_el$8, children, _el$9);
insert(_el$8, function () {
return renderPathFor(weight != null ? weight : contextWeight, color != null ? color : contextColor);
}, null);
return _el$8;
}();
};
export default Rectangle;
//# sourceMappingURL=Rectangle.esm.js.map