Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lendi-ui/icon

Package Overview
Dependencies
Maintainers
8
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lendi-ui/icon - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

dist/cjs/icons-compiled/bloom-savings.js

72

dist/cjs/index.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var loadedSpritesheet = false;
var Icon = /** @class */ (function (_super) {
__extends(Icon, _super);
function Icon(props) {
return _super.call(this, props) || this;
}
Icon.prototype.mountSVGSpritesheet = function (response) {
var svgWrapper = document.createElement('div');
svgWrapper.setAttribute('id', 'svg-icons');
svgWrapper.setAttribute('style', 'display:none;');
svgWrapper.innerHTML = response;
document.body.insertAdjacentHTML('afterbegin', svgWrapper.outerHTML);
loadedSpritesheet = true;
};
Icon.prototype.componentDidMount = function () {
var _this = this;
if (!loadedSpritesheet) {
loadedSpritesheet = true;
fetch('./sprite.symbol.svg')
.then(function (res) { return res.text(); })
.then(function (text) {
_this.mountSVGSpritesheet(text);
})
.catch(function (error) {
/* tslint:disable-next-line no-console */
console.warn(error);
loadedSpritesheet = false;
});
}
return undefined;
};
Icon.prototype.render = function () {
return (React.createElement("svg", { className: this.props.className, focusable: "false", role: "img" },
React.createElement("use", { href: "#" + this.props.name })));
};
Icon.defaultProps = {
className: undefined,
};
return Icon;
}(React.Component));
exports.Icon = Icon;
var styled_components_1 = require("styled-components");
var color_1 = require("@lendi-ui/color");
var index_1 = require("./icons-compiled/index");
var IconWrapper = styled_components_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & > svg {\n fill: ", ";\n }\n"], ["\n & > svg {\n fill: ", ";\n }\n"])), function (_a) {
var fill = _a.fill;
return color_1.color(fill);
});
var Icon = function (_a) {
var name = _a.name, color = _a.color;
var Svg = index_1.Icons[name];
return (React.createElement(IconWrapper, { fill: color },
React.createElement(Svg, null)));
};
exports.default = Icon;
var templateObject_1;
//# sourceMappingURL=index.js.map

@@ -1,57 +0,21 @@

var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
import * as React from 'react';
var loadedSpritesheet = false;
var Icon = /** @class */ (function (_super) {
__extends(Icon, _super);
function Icon(props) {
return _super.call(this, props) || this;
}
Icon.prototype.mountSVGSpritesheet = function (response) {
var svgWrapper = document.createElement('div');
svgWrapper.setAttribute('id', 'svg-icons');
svgWrapper.setAttribute('style', 'display:none;');
svgWrapper.innerHTML = response;
document.body.insertAdjacentHTML('afterbegin', svgWrapper.outerHTML);
loadedSpritesheet = true;
};
Icon.prototype.componentDidMount = function () {
var _this = this;
if (!loadedSpritesheet) {
loadedSpritesheet = true;
fetch('./sprite.symbol.svg')
.then(function (res) { return res.text(); })
.then(function (text) {
_this.mountSVGSpritesheet(text);
})
.catch(function (error) {
/* tslint:disable-next-line no-console */
console.warn(error);
loadedSpritesheet = false;
});
}
return undefined;
};
Icon.prototype.render = function () {
return (React.createElement("svg", { className: this.props.className, focusable: "false", role: "img" },
React.createElement("use", { href: "#" + this.props.name })));
};
Icon.defaultProps = {
className: undefined,
};
return Icon;
}(React.Component));
export { Icon };
import styled from 'styled-components';
import { color } from '@lendi-ui/color';
import { Icons } from './icons-compiled/index';
var IconWrapper = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & > svg {\n fill: ", ";\n }\n"], ["\n & > svg {\n fill: ", ";\n }\n"])), function (_a) {
var fill = _a.fill;
return color(fill);
});
var Icon = function (_a) {
var name = _a.name, color = _a.color;
var Svg = Icons[name];
return (React.createElement(IconWrapper, { fill: color },
React.createElement(Svg, null)));
};
export default Icon;
var templateObject_1;
//# sourceMappingURL=index.js.map
import * as React from 'react';
import { NameOrNameMap } from '@lendi-ui/color';
import { IconMap } from './icons-compiled/index';
export interface IconProps {
/** Name of the svg icon */
name: string;
className?: string;
name: keyof IconMap;
color: NameOrNameMap;
}
export declare class Icon extends React.Component<IconProps> {
static defaultProps: Partial<IconProps>;
constructor(props: IconProps);
private mountSVGSpritesheet;
componentDidMount(): undefined;
render(): JSX.Element;
}
declare const Icon: React.SFC<IconProps>;
export default Icon;
{
"name": "@lendi-ui/icon",
"version": "1.0.0",
"version": "2.0.0",
"source": "src/index.tsx",

@@ -16,7 +16,11 @@ "main": "dist/cjs/index.js",

"@types/react": "^15 || ^16.4",
"react": "^15 || ^16.4"
"react": "^15 || ^16.4",
"styled-components": "^2 || ^3"
},
"devDependencies": {
"svg-sprite": "^1.4.0"
"@svgr/core": "^2.2.0"
},
"dependencies": {
"@lendi-ui/color": "^2.0.1"
},
"scripts": {

@@ -23,0 +27,0 @@ "build:svg": "node ./build.js",

# Icon
## NOTE
This currently builds to ./packages/website/static/sprite.symbol.svg
TODO: Deploy SVG spritesheet https://creditandfinance.atlassian.net/browse/LIP-529
## Adding a new icon
Add the SVG into src/icons. Be thoughtful with naming, as this will determine the name of the component. For example, the file `computer-bank` will create a SVG component called `computerBank` (note that the kebab-case filename will become a camelCase component).
When this package is built, an equivalent react component will be created in src/icons-compiled.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc