UNPKG

decentraland-ui

Version:

Decentraland's UI components and styles

130 lines (129 loc) 4.61 kB
"use strict"; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSubtitle = exports.getBadges = void 0; var react_1 = __importDefault(require("react")); var schemas_1 = require("@dcl/schemas"); var colors_1 = require("../../lib/colors"); var Profile_1 = require("../Profile/Profile"); var DEFAULT_BADGE_COLOR = '#37333d'; function _getEmoteBadges(emote, i18n) { var _a = schemas_1.Rarity.getGradient(emote.rarity), lightColor = _a[0], regularColor = _a[1]; var hexColor = (0, colors_1.hex2rgb)(regularColor); return __spreadArray([ { color: "rgb(".concat(hexColor.r, " ").concat(hexColor.g, " ").concat(hexColor.b, " / 20%)"), label: emote.rarity, textColor: lightColor }, { color: DEFAULT_BADGE_COLOR, label: emote.loop ? i18n.playMode.loop : i18n.playMode.once, icon: emote.loop ? 'dui-nft-card__badge-icon--loop' : 'dui-nft-card__badge-icon--once', hideLabel: true } ], (emote.hasSound ? [ { color: DEFAULT_BADGE_COLOR, label: i18n.withSound, icon: 'dui-nft-card__badge-icon--sound', hideLabel: true } ] : []), true); } function _getWearableBadges(wearable, i18n) { var bodyShape = wearable.bodyShapes.length === 2 ? 'unisex' : wearable.bodyShapes[0] === schemas_1.BodyShape.MALE ? 'male' : 'female'; var _a = schemas_1.Rarity.getGradient(wearable.rarity), lightColor = _a[0], regularColor = _a[1]; var hexColor = (0, colors_1.hex2rgb)(regularColor); return __spreadArray([ { color: "rgb(".concat(hexColor.r, " ").concat(hexColor.g, " ").concat(hexColor.b, " / 20%)"), label: wearable.rarity, textColor: lightColor }, { color: DEFAULT_BADGE_COLOR, label: i18n.category[wearable.category], icon: "dui-nft-card__badge-icon--".concat(wearable.category), hideLabel: true }, { color: DEFAULT_BADGE_COLOR, label: i18n.bodyShape[bodyShape], icon: "dui-nft-card__badge-icon--".concat(bodyShape), hideLabel: true } ], (wearable.isSmart ? [ { color: DEFAULT_BADGE_COLOR, label: i18n.smart, icon: 'dui-nft-card__badge-icon--smart', hideLabel: true } ] : []), true); } function _getEstateBadges(estate) { return [ { color: DEFAULT_BADGE_COLOR, label: "".concat(estate.parcels.length, " LAND") } ]; } function _getParcelBadges(parcel) { return [ { color: DEFAULT_BADGE_COLOR, label: "".concat(parcel.x, ",").concat(parcel.y), icon: 'dui-nft-card__badge-icon--parcel' } ]; } function getBadges(nft, i18n) { switch (nft.category) { case schemas_1.NFTCategory.EMOTE: return _getEmoteBadges(nft.data.emote, i18n); case schemas_1.NFTCategory.WEARABLE: return _getWearableBadges(nft.data.wearable, i18n); case schemas_1.NFTCategory.ESTATE: return _getEstateBadges(nft.data.estate); case schemas_1.NFTCategory.PARCEL: return _getParcelBadges(nft.data.parcel); case schemas_1.NFTCategory.ENS: return []; } } exports.getBadges = getBadges; function getSubtitle(nft, i18n) { switch (nft.category) { case schemas_1.NFTCategory.EMOTE: case schemas_1.NFTCategory.WEARABLE: return react_1.default.createElement(Profile_1.Profile, { address: nft.owner, textOnly: true }); case schemas_1.NFTCategory.ENS: case schemas_1.NFTCategory.ESTATE: case schemas_1.NFTCategory.PARCEL: return i18n.network["".concat(nft.network.toLowerCase())]; } } exports.getSubtitle = getSubtitle;