@ltht-react/flag-summary
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.0.3](https://github.com/ltht-epr/ltht-react/compare/@ltht-react/flag-summary@0.0.2...@ltht-react/flag-summary@0.0.3) (2020-01-07) | ||
**Note:** Version bump only for package @ltht-react/flag-summary | ||
## [0.0.2](https://github.com/ltht-epr/ltht-react/compare/@ltht-react/flag-summary@0.0.1...@ltht-react/flag-summary@0.0.2) (2020-01-06) | ||
@@ -8,0 +16,0 @@ |
@@ -1,10 +0,9 @@ | ||
/** @jsx jsx */ | ||
import React from 'react'; | ||
/// <reference types="react" /> | ||
import { Flag } from '@ltht-react/types'; | ||
declare const FlagSummary: React.FC<FlagSummaryProps>; | ||
interface FlagSummaryProps { | ||
title?: string; | ||
flags?: Flag[]; | ||
handleItemClick(flag: Flag): void; | ||
declare const FlagSummary: ({ title, flags, clickHandler }: Props) => JSX.Element; | ||
interface Props { | ||
title: string; | ||
flags: Flag[]; | ||
clickHandler(flag: Flag): void; | ||
} | ||
export default FlagSummary; |
@@ -11,64 +11,14 @@ "use strict"; | ||
var core_1 = require("@emotion/core"); | ||
var types_1 = require("@ltht-react/types"); | ||
var styles_1 = require("@ltht-react/styles"); | ||
var exclamation_icon_1 = __importDefault(require("@ltht-react/exclamation-icon")); | ||
var CodeableConceptSnippet = function (_a) { | ||
var _b = _a.codeableConcept, codeableConcept = _b === void 0 ? {} : _b, listStyles = _a.listStyles, textStyles = _a.textStyles; | ||
var codings = codeableConcept.coding || []; | ||
var display = codings | ||
.map(function (coding) { | ||
var _a; | ||
return (_a = coding) === null || _a === void 0 ? void 0 : _a.display; | ||
}) | ||
.join(', '); | ||
var code = codings | ||
.map(function (coding) { | ||
var _a; | ||
return (_a = coding) === null || _a === void 0 ? void 0 : _a.code; | ||
}) | ||
.join(', '); | ||
return (core_1.jsx("ul", { css: listStyles }, | ||
core_1.jsx("li", null, display), | ||
core_1.jsx("li", { css: textStyles }, code))); | ||
}; | ||
var DateText = function (date) { | ||
if (!date) { | ||
return; | ||
} | ||
return date.value | ||
.toLocaleString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }) | ||
.split(' ') | ||
.join('-'); | ||
}; | ||
var PeriodSnippet = function (_a) { | ||
var _b = _a.period, period = _b === void 0 ? {} : _b, listStyles = _a.listStyles, textStyles = _a.textStyles; | ||
var _c; | ||
return (core_1.jsx("ul", { css: listStyles }, | ||
core_1.jsx("li", null, DateText((_c = period) === null || _c === void 0 ? void 0 : _c.start)), | ||
core_1.jsx("li", { css: textStyles }))); | ||
}; | ||
var FlagSummaryItem = function (_a) { | ||
var flag = _a.flag, handleClick = _a.handleClick; | ||
var li_styles = core_1.css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n border-top: 1px solid #b0b0b0;\n padding: 0.2rem;\n justify-content: center;\n "], ["\n display: flex;\n border-top: 1px solid #b0b0b0;\n padding: 0.2rem;\n justify-content: center;\n "]))); | ||
var codeable_styles = core_1.css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n flex-grow: 1;\n "], ["\n flex-grow: 1;\n "]))); | ||
var ul_styles = core_1.css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-left: 0.4rem;\n list-style: none;\n "], ["\n padding-left: 0.4rem;\n list-style: none;\n "]))); | ||
var secondary_text_style = core_1.css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), styles_1.SECONDARY_TEXT_COLOUR); | ||
return (core_1.jsx("li", { css: li_styles, onClick: function () { return handleClick; } }, | ||
core_1.jsx("div", null, | ||
core_1.jsx(exclamation_icon_1.default, { status: flag.status === types_1.FlagStatusCode.Active ? 'red' : 'amber', size: "medium" })), | ||
core_1.jsx("div", { css: codeable_styles }, | ||
core_1.jsx(CodeableConceptSnippet, { codeableConcept: flag.code, listStyles: ul_styles, textStyles: secondary_text_style })), | ||
core_1.jsx("div", null, | ||
core_1.jsx(PeriodSnippet, { period: flag.period, listStyles: ul_styles, textStyles: secondary_text_style })))); | ||
}; | ||
var flag_summary_item_1 = __importDefault(require("./molecules/flag-summary-item")); | ||
var titleStyles = core_1.css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin-bottom: 0.5rem;\n"], ["\n margin-bottom: 0.5rem;\n"]))); | ||
var FlagSummary = function (_a) { | ||
var _b = _a.title, title = _b === void 0 ? 'Flag Summary' : _b, _c = _a.flags, flags = _c === void 0 ? [] : _c, handleItemClick = _a.handleItemClick; | ||
var titleStyles = core_1.css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-bottom: 0.5rem;\n "], ["\n margin-bottom: 0.5rem;\n "]))); | ||
var title = _a.title, flags = _a.flags, clickHandler = _a.clickHandler; | ||
return (core_1.jsx("div", { css: styles_1.WIDGET_STYLES }, | ||
core_1.jsx("div", { css: styles_1.CSS_RESET }, | ||
core_1.jsx("h3", { css: titleStyles }, title), | ||
core_1.jsx("ul", null, flags.map(function (flag, index) { return (core_1.jsx(FlagSummaryItem, { key: index, flag: flag, handleClick: function () { return handleItemClick(flag); } })); }))))); | ||
core_1.jsx("ul", null, flags.map(function (flag, index) { return (core_1.jsx(flag_summary_item_1.default, { key: index, flag: flag, clickHandler: clickHandler })); }))))); | ||
}; | ||
exports.default = FlagSummary; | ||
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5; | ||
var templateObject_1; | ||
//# sourceMappingURL=index.js.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
var _1 = __importDefault(require(".")); | ||
var handlClick = function (flag) { }; | ||
var handleClick = function (flag) { }; | ||
describe('FlagSummary', function () { | ||
@@ -17,8 +17,8 @@ var flags = [fixtures_1.FlagOne, fixtures_1.FlagTwo]; | ||
var div = document.createElement('div'); | ||
react_dom_1.default.render(react_1.default.createElement(_1.default, { flags: flags, handleItemClick: handlClick }), div); | ||
react_dom_1.default.render(react_1.default.createElement(_1.default, { title: "Alerts", flags: flags, clickHandler: handleClick }), div); | ||
}); | ||
it('matches snapshot', function () { | ||
expect(enzyme_1.mount(react_1.default.createElement(_1.default, { flags: flags, handleItemClick: handlClick }))).toMatchSnapshot('wrapper mount'); | ||
expect(enzyme_1.mount(react_1.default.createElement(_1.default, { title: "Alerts", flags: flags, clickHandler: handleClick }))).toMatchSnapshot('wrapper mount'); | ||
}); | ||
}); | ||
//# sourceMappingURL=tests.js.map |
{ | ||
"name": "@ltht-react/flag-summary", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "> TODO: description", | ||
@@ -35,2 +35,3 @@ "author": "Jonny Smith <jonny.asmith@gmail.com>", | ||
"@ltht-react/types": "^0.0.2", | ||
"@ltht-react/utils": "^0.0.1", | ||
"emotion": "^10.0.27", | ||
@@ -59,3 +60,3 @@ "react": "^16.12.0" | ||
}, | ||
"gitHead": "30e05758c469666ff8be03e6b338e1bb319eb4d9" | ||
"gitHead": "b3ceaa6d82c5e122831dbd7ec5d37784ec65f957" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24434
39
314
8
1
76
+ Added@ltht-react/utils@^0.0.1
+ Added@ltht-react/utils@0.0.1(transitive)