create-fomantic-icons
Version:
A simple CLI to generate the icon.variables and icon.html.eco files for FUI
98 lines (97 loc) • 3.31 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// utils
var Converter_1 = __importDefault(require("../util/Converter"));
// enums
var IconType_1 = __importDefault(require("../enums/IconType"));
// static
var corrections_json_1 = __importDefault(require("../static/corrections.json"));
var Icon = /** @class */ (function () {
function Icon(data) {
this.data = data;
}
Icon.prototype.hasCorrection = function (field) {
var iconCorrection = corrections_json_1.default[this.rawName];
if (iconCorrection !== undefined) {
return iconCorrection[field] !== undefined;
}
return false;
};
Icon.prototype.correction = function (field) {
return this.hasCorrection(field)
? corrections_json_1.default[this.rawName][field]
: '';
};
Object.defineProperty(Icon.prototype, "rawName", {
get: function () {
return this.data.name;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "name", {
get: function () {
var name = this.data.name;
if (this.type === IconType_1.default.OUTLINE) {
name += '-outline';
}
if (this.type === IconType_1.default.THIN) {
name += '-thin';
}
if (this.type === IconType_1.default.DUOTONE) {
name += '-duotone';
}
return this.hasCorrection('name')
? this.correction('name')
: Converter_1.default.iconName(name);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "className", {
get: function () {
return this.hasCorrection('className')
? this.correction('className')
: Converter_1.default.iconClassName(this.name);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "unicode", {
get: function () {
return this.hasCorrection('unicode')
? this.correction('unicode')
: "\\".concat(this.data.unicode);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "secondaryUnicode", {
get: function () {
return this.hasCorrection('unicode')
? this.correction('unicode')
: "\\10".concat(this.data.unicode);
},
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "type", {
get: function () {
return this.data.type;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "searchTerms", {
get: function () {
return this.data.searchTerms.join(', ');
},
enumerable: false,
configurable: true
});
return Icon;
}());
exports.default = Icon;