decentraland-ui
Version:
Decentraland's UI components and styles
74 lines (73 loc) • 5.84 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.replaceWithValues = exports.CURRENT_AVAILABLE_NOTIFICATIONS = exports.NotificationComponentByType = exports.getBGColorByRarity = exports.formatMana = exports.MAXIMUM_FRACTION_DIGITS = void 0;
var react_1 = __importDefault(require("react"));
var schemas_1 = require("@dcl/schemas");
var NotificationTypes_1 = require("./NotificationTypes");
var RewardInProgressNotification_1 = __importDefault(require("./NotificationTypes/Reward/RewardInProgressNotification"));
var CampaignOutOfStockNotification_1 = __importDefault(require("./NotificationTypes/Reward/CampaignOutOfStockNotification"));
var CampaignGasPriceHigherThanExpectedNotification_1 = __importDefault(require("./NotificationTypes/Reward/CampaignGasPriceHigherThanExpectedNotification"));
var CampaignOutOfFundsNotification_1 = __importDefault(require("./NotificationTypes/Reward/CampaignOutOfFundsNotification"));
var RewardDelayedNotification_1 = __importDefault(require("./NotificationTypes/Reward/RewardDelayedNotification"));
exports.MAXIMUM_FRACTION_DIGITS = 2;
function formatMana(mana, maximumFractionDigits) {
if (maximumFractionDigits === void 0) { maximumFractionDigits = exports.MAXIMUM_FRACTION_DIGITS; }
return (Number(mana) / 1e18).toFixed(maximumFractionDigits).toLocaleString();
}
exports.formatMana = formatMana;
function getBGColorByRarity(rarity) {
return schemas_1.Rarity.getGradient(rarity).join();
}
exports.getBGColorByRarity = getBGColorByRarity;
exports.NotificationComponentByType = (_a = {},
_a[schemas_1.NotificationType.ROYALTIES_EARNED] = NotificationTypes_1.RoyaltiesEarnedNotification,
_a[schemas_1.NotificationType.ITEM_SOLD] = NotificationTypes_1.ItemSoldNotification,
_a[schemas_1.NotificationType.BID_ACCEPTED] = NotificationTypes_1.BidAcceptedNotification,
_a[schemas_1.NotificationType.BID_RECEIVED] = NotificationTypes_1.BidReceivedNotification,
_a[schemas_1.NotificationType.GOVERNANCE_ANNOUNCEMENT] = NotificationTypes_1.GovernanceAnnouncementNotification,
_a[schemas_1.NotificationType.GOVERNANCE_COAUTHOR_REQUESTED] = NotificationTypes_1.GovernanceCoauthorRequestedNotification,
_a[schemas_1.NotificationType.GOVERNANCE_AUTHORED_PROPOSAL_FINISHED] = NotificationTypes_1.GovernanceAuthoredProposalFinishedNotification,
_a[schemas_1.NotificationType.GOVERNANCE_NEW_COMMENT_ON_PROPOSAL] = NotificationTypes_1.GovernanceNewCommentOnProposalNotification,
_a[schemas_1.NotificationType.GOVERNANCE_NEW_COMMENT_ON_PROJECT_UPDATE] = NotificationTypes_1.GovernanceNewCommentOnProjectUpdateNotification,
_a[schemas_1.NotificationType.GOVERNANCE_PROPOSAL_ENACTED] = NotificationTypes_1.GovernanceProposalEnactedNotification,
_a[schemas_1.NotificationType.GOVERNANCE_VOTING_ENDED_VOTER] = NotificationTypes_1.GovernanceVotingEndedVoterNotification,
_a[schemas_1.NotificationType.GOVERNANCE_PITCH_PASSED] = NotificationTypes_1.GovernancePitchPassedNotification,
_a[schemas_1.NotificationType.GOVERNANCE_TENDER_PASSED] = NotificationTypes_1.GovernanceTenderPassedNotification,
_a[schemas_1.NotificationType.GOVERNANCE_WHALE_VOTE] = NotificationTypes_1.GovernanceWhaleVoteNotification,
_a[schemas_1.NotificationType.GOVERNANCE_CLIFF_ENDED] = NotificationTypes_1.GovernanceCliffEndedNotification,
_a[schemas_1.NotificationType.GOVERNANCE_VOTED_ON_BEHALF] = NotificationTypes_1.GovernanceVotedOnBehalfNotification,
_a[schemas_1.NotificationType.WORLDS_MISSING_RESOURCES] = NotificationTypes_1.WorldsMissingResourcesNotification,
_a[schemas_1.NotificationType.WORLDS_ACCESS_RESTORED] = NotificationTypes_1.WorldsAccessRestoredNotification,
_a[schemas_1.NotificationType.WORLDS_ACCESS_RESTRICTED] = NotificationTypes_1.WorldsAccessRestrictedNotification,
_a[schemas_1.NotificationType.LAND_RENTED] = NotificationTypes_1.LandRentedNotification,
_a[schemas_1.NotificationType.LAND_RENTAL_ENDED] = NotificationTypes_1.LandRentalEndedNotification,
_a[schemas_1.NotificationType.REWARD_ASSIGNED] = NotificationTypes_1.RewardAssignedNotification,
_a[schemas_1.NotificationType.REWARD_IN_PROGRESS] = RewardInProgressNotification_1.default,
_a[schemas_1.NotificationType.REWARD_DELAYED] = RewardDelayedNotification_1.default,
_a[schemas_1.NotificationType.REWARD_CAMPAIGN_OUT_OF_FUNDS] = CampaignOutOfFundsNotification_1.default,
_a[schemas_1.NotificationType.REWARD_CAMPAIGN_OUT_OF_STOCK] = CampaignOutOfStockNotification_1.default,
_a[schemas_1.NotificationType.REWARD_CAMPAIGN_GAS_PRICE_HIGHER_THAN_EXPECTED] = CampaignGasPriceHigherThanExpectedNotification_1.default,
_a[schemas_1.NotificationType.EVENTS_STARTS_SOON] = NotificationTypes_1.EventsStartsSoonNotification,
_a[schemas_1.NotificationType.EVENTS_STARTED] = NotificationTypes_1.EventsStartedNotification,
_a[schemas_1.NotificationType.WORLDS_PERMISSION_GRANTED] = NotificationTypes_1.WorldsPermissionGrantedNotification,
_a[schemas_1.NotificationType.WORLDS_PERMISSION_REVOKED] = NotificationTypes_1.WorldsPermissionRevokedNotification,
_a);
exports.CURRENT_AVAILABLE_NOTIFICATIONS = Object.keys(exports.NotificationComponentByType);
var replaceWithValues = function (str, values) {
var parts = str.split(/{|}/);
var jsxElements = parts.map(function (part, index) {
if (index % 2 === 0) {
return part;
}
else {
var value = values[part.trim()];
return value !== undefined ? value : "{".concat(part, "}");
}
});
return react_1.default.createElement(react_1.default.Fragment, null, jsxElements);
};
exports.replaceWithValues = replaceWithValues;