@trap_stevo/legendarybuilderproreact-ui
Version:
The legendary UI & utility API that makes your application a legendary application. ~ Created by Steven Compton
67 lines (66 loc) • 4.45 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import React from "react";
import { useMemo } from "react";
/**
* Renders © [yearLabel] CompanyName[ additionalText]. All rights reserved.
*
* @param {object} [copyRightConfigurationSettings] – optional inline styles
* @prop {(text: string) => React.ReactNode} [renderCopyrightLabel] – optional render prop, receives the full copyright string
* @param {string} [selectionBackground] – background color when text selected
* @param {string} [selectionColor] – text color when selected
* @param {string} [additionalText] – extra phrase to append (e.g. “and its affiliates”)
* @param {string} [companyName] – your company or product name
* @param {boolean} [showRange] – if true & startYear < currentYear, prints “start–current”; otherwise just currentYear
* @param {number} [startYear] – your founding year
*/
function HUDCopyright(_ref) {
var _ref$copyRightConfigu = _ref.copyRightConfigurationSettings,
copyRightConfigurationSettings = _ref$copyRightConfigu === void 0 ? {} : _ref$copyRightConfigu,
_ref$renderCopyrightL = _ref.renderCopyrightLabel,
renderCopyrightLabel = _ref$renderCopyrightL === void 0 ? null : _ref$renderCopyrightL,
_ref$selectionBackgro = _ref.selectionBackground,
selectionBackground = _ref$selectionBackgro === void 0 ? "rgba(170, 170, 170, 0.5)" : _ref$selectionBackgro,
_ref$selectionColor = _ref.selectionColor,
selectionColor = _ref$selectionColor === void 0 ? "#fff" : _ref$selectionColor,
_ref$additionalText = _ref.additionalText,
additionalText = _ref$additionalText === void 0 ? "" : _ref$additionalText,
_ref$showRange = _ref.showRange,
showRange = _ref$showRange === void 0 ? false : _ref$showRange,
startYear = _ref.startYear,
company = _ref.company;
var currentYear = useMemo(function () {
return new Date().getFullYear();
}, []);
var yearLabel = useMemo(function () {
return startYear && showRange && startYear < currentYear ? "".concat(startYear, "\u2013").concat(currentYear) : "".concat(currentYear);
}, [showRange, startYear, currentYear]);
var suffix = useMemo(function () {
return additionalText.trim() ? " ".concat(additionalText.trim()) : "";
}, [additionalText]);
var text = useMemo(function () {
return "\xA9 ".concat(yearLabel, " ").concat(company).concat(suffix, ". All rights reserved.");
}, [yearLabel, company, suffix]);
var id = useMemo(function () {
return "hud-copyright-".concat(Math.random().toString(36).substr(2, 9));
}, []);
var baseRender = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", {
dangerouslySetInnerHTML: {
__html: "\n #".concat(id, "::selection {\n background : ").concat(selectionBackground, ";\n color : ").concat(selectionColor, ";\n }\n \n #").concat(id, "::-moz-selection {\n background: ").concat(selectionBackground, ";\n color: ").concat(selectionColor, ";\n }\n ")
}
}), /*#__PURE__*/React.createElement("div", {
id: id,
style: _objectSpread({
textAlign: "center",
fontSize: "0.875rem",
color: "#888"
}, copyRightConfigurationSettings)
}, text));
if (typeof renderCopyrightLabel === "function") {
return /*#__PURE__*/React.createElement(React.Fragment, null, renderCopyrightLabel(text));
}
return baseRender;
}
;
export default HUDCopyright;