UNPKG

opds-web-client

Version:
49 lines (48 loc) 1.99 kB
"use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var React = require("react"); var CatalogLink_1 = require("./CatalogLink"); var LaneMoreLink = (function (_super) { __extends(LaneMoreLink, _super); function LaneMoreLink() { _super.apply(this, arguments); } LaneMoreLink.prototype.render = function () { var cellStyle = Object.assign({ display: "table-cell", verticalAlign: "middle", backgroundColor: "#eee", textAlign: "center", padding: "10px", color: "#888", fontWeight: "bold", width: "150px", height: "200px" }, this.computeFontStyle(), this.props.style); var moreLinkStyle = { display: "block", height: "250px", whiteSpace: "normal", textDecoration: "none" }; return (React.createElement(CatalogLink_1.default, {className: "moreLink", style: moreLinkStyle, collectionUrl: this.props.lane.url}, React.createElement("div", {style: cellStyle}, "More", React.createElement("br", null), this.props.lane.title))); }; LaneMoreLink.prototype.computeFontStyle = function () { var words = this.props.lane.title.split(/\s/); var wordCount = words.length; var maxLength = Math.max.apply(Math, words.map(function (word) { return word.length; })); var fontSize = Math.max(15, 43 - maxLength * 2 - Math.max(0, wordCount - 3) * 2); var lineHeight = fontSize + 5; return { fontSize: fontSize + "px", lineHeight: "1.1em" }; }; return LaneMoreLink; }(React.Component)); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = LaneMoreLink;