1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = Object.setPrototypeOf ||
|
4 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6 | return function (d, b) {
|
7 | extendStatics(d, b);
|
8 | function __() { this.constructor = d; }
|
9 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10 | };
|
11 | })();
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | var React = require("react");
|
14 | var react_malibu_1 = require("@heroku/react-malibu");
|
15 | var classnames = require("classnames");
|
16 | var constants_1 = require("./constants");
|
17 | var HKLegendItem = (function (_super) {
|
18 | __extends(HKLegendItem, _super);
|
19 | function HKLegendItem() {
|
20 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
21 | _this.handleOnClick = function () {
|
22 | var _a = _this.props, onToggle = _a.onToggle, label = _a.label, zIndex = _a.zIndex;
|
23 | if (!onToggle) {
|
24 | return null;
|
25 | }
|
26 | onToggle(label, zIndex);
|
27 | };
|
28 | return _this;
|
29 | }
|
30 | HKLegendItem.prototype.render = function () {
|
31 | var _a = this.props, className = _a.className, disableToggle = _a.disableToggle, label = _a.label, show = _a.show, value = _a.value, zIndex = _a.zIndex, type = _a.type;
|
32 | var legendIcon = show && (React.createElement("div", { className: 'flex items-center' },
|
33 | React.createElement(react_malibu_1.MalibuIcon, { name: 'confirm-16', fillClass: 'dark-gray', extraClasses: 'icon malibu-icon h1 w1 mr1 fill-dark-gray di' }),
|
34 | React.createElement("svg", { width: '7', height: '31', viewBox: "0 0 7 31", className: 'mr1' },
|
35 | React.createElement("rect", { x: '0', y: '0', height: '100%', width: '7', fill: type === 'line' ? '#79589f' : constants_1.colours[zIndex], fillOpacity: type === 'line' ? (0.2 * (zIndex + 1)) : 1 }))));
|
36 | return (React.createElement("a", { className: classnames({ 'cursor-hand': !disableToggle }), onClick: !disableToggle ? this.handleOnClick : undefined },
|
37 | React.createElement("div", { className: classnames('hk-label', className, 'flex flex-row br2 pa2 mh2 items-center', { 'bg-lightest-silver': show }) },
|
38 | legendIcon,
|
39 | React.createElement("div", { className: 'items-center' },
|
40 | React.createElement("span", { className: 'db ma1 ttu f7 tracked' }, label),
|
41 | React.createElement("span", { className: 'db ma1 ttu b f6' }, value)))));
|
42 | };
|
43 | HKLegendItem.defaultProps = {
|
44 | disableToggle: false,
|
45 | };
|
46 | return HKLegendItem;
|
47 | }(React.PureComponent));
|
48 | exports.default = HKLegendItem;
|
49 |
|
\ | No newline at end of file |