37 | );
38 | }
39 | }
40 |
41 | export default StatLegend;
42 |
--------------------------------------------------------------------------------
/src/components/common/stat/assets/chevron-right-24-px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tidepool-org/viz/22af47c9516f0cd145df5bbb6be128fdd5105f63/src/components/common/stat/assets/chevron-right-24-px.png
--------------------------------------------------------------------------------
/src/components/common/stat/assets/expand-more-24-px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tidepool-org/viz/22af47c9516f0cd145df5bbb6be128fdd5105f63/src/components/common/stat/assets/expand-more-24-px.png
--------------------------------------------------------------------------------
/src/components/common/stat/assets/info-outline-24-px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tidepool-org/viz/22af47c9516f0cd145df5bbb6be128fdd5105f63/src/components/common/stat/assets/info-outline-24-px.png
--------------------------------------------------------------------------------
/src/components/common/tooltips/CgmSampleIntervalTooltip.css:
--------------------------------------------------------------------------------
1 | .container {
2 | width: 260px;
3 | }
4 |
5 | .row {
6 | composes: smallSize from '../../../styles/typography.css';
7 | line-height: 16px;
8 | color: var(--stat--default);
9 | margin-bottom: 8px;
10 | font-weight: medium;
11 | }
12 |
13 | .title {
14 | composes: row;
15 | font-weight: bold;
16 | }
17 |
18 | .subtitle {
19 | composes: row;
20 | }
21 |
22 | .annotations {
23 | padding-left: 24px;
24 | margin: 0 0 6px;
25 | }
26 |
27 | .annotation {
28 | composes: row;
29 | margin-bottom: 2px;
30 | }
31 |
--------------------------------------------------------------------------------
/src/components/common/tooltips/StatTooltip.css:
--------------------------------------------------------------------------------
1 | .row {
2 | composes: smallSize from '../../../styles/typography.css';
3 | line-height: 16px;
4 | max-width: 180px;
5 | min-width: 160px;
6 | font-weight: medium;
7 | }
8 |
9 | .message {
10 | composes: row;
11 | color: var(--stat--default);
12 | }
13 |
14 | .message p {
15 | margin: 0;
16 | }
17 |
18 | .message a {
19 | pointer-events: all;
20 | }
21 |
22 | .divider {
23 | height: 2px;
24 | margin: 10px -12px;
25 | background-color: var(--stat--default);
26 | }
27 |
28 | .hiddenDivider {
29 | height: 10px;
30 | background-color: transparent;
31 | }
32 |
--------------------------------------------------------------------------------
/src/components/common/tooltips/Tooltip.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .tooltip {
19 | display: block;
20 | composes: defaultSize from '../../../styles/typography.css';
21 | background-color: #FFFFFF;
22 | border: solid;
23 | pointer-events: none;
24 | position: absolute;
25 | border-radius: 4px;
26 | z-index: 1000;
27 | }
28 |
29 | .content {
30 | display: flex;
31 | align-items: center;
32 | justify-content: space-between;
33 | width: 100%;
34 | padding: 10px 12px;
35 | box-sizing: border-box;
36 | }
37 |
38 | .content span {
39 | width: 100%;
40 | }
41 |
42 | .title {
43 | composes: mediumContrastText from '../../../styles/typography.css';
44 | composes: content;
45 | background-color: var(--tooltip-title-bg);
46 | }
47 |
48 | .tail {
49 | width: 0px;
50 | height: 0px;
51 | border-style: solid;
52 | border-color: transparent;
53 | position: absolute;
54 | }
55 |
56 | :export {
57 | tooltipTitleBg: var(--tooltip-title-bg);
58 | }
59 |
--------------------------------------------------------------------------------
/src/components/daily/cbgtooltip/CBGTooltip.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 | @import '../../../styles/colors.css';
18 |
19 | .container {
20 | opacity: 1;
21 | display: flex;
22 | flex-direction: column;
23 | min-width: 80px;
24 | margin: 2px 0;
25 | max-width: 180px;
26 | }
27 |
28 | .row {
29 | composes: smallSize from '../../../styles/typography.css';
30 | display: flex;
31 | flex-direction: row;
32 | justify-content: space-between;
33 | line-height: 20px;
34 | }
35 |
36 | .label {
37 | flex-grow: 1;
38 | }
39 |
40 | .value {
41 | margin-left: 20px;
42 | }
43 |
44 | .units {
45 | min-width: 0.7em;
46 | margin-left: 10px;
47 | }
48 |
49 | .title {
50 | composes: smallSize from '../../../styles/typography.css';
51 | text-align: right;
52 | }
53 |
54 | .bg {
55 | composes: row;
56 | font-weight: bold;
57 | }
58 |
59 | .subType {
60 | composes: row;
61 | color: var(--gray-dark);
62 | }
63 |
64 | .annotation {
65 | composes: subType;
66 | }
67 |
68 | .divider {
69 | height: 3px;
70 | margin: 5px -10px;
71 | }
72 |
--------------------------------------------------------------------------------
/src/components/daily/foodtooltip/FoodTooltip.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 | @import '../../../styles/colors.css';
18 |
19 | .container {
20 | opacity: 1;
21 | display: flex;
22 | flex-direction: column;
23 | min-width: 80px;
24 | margin: 2px 0;
25 | max-width: 180px;
26 | }
27 |
28 | .row {
29 | composes: smallSize from '../../../styles/typography.css';
30 | display: flex;
31 | flex-direction: row;
32 | justify-content: space-between;
33 | line-height: 20px;
34 | }
35 |
36 | .label {
37 | flex-grow: 1;
38 | }
39 |
40 | .value {
41 | margin-left: 20px;
42 | }
43 |
44 | .units {
45 | min-width: 0.7em;
46 | margin-left: 10px;
47 | }
48 |
49 | .title {
50 | composes: smallSize from '../../../styles/typography.css';
51 | text-align: right;
52 | }
53 |
54 | .carb {
55 | composes: row;
56 | font-weight: bold;
57 | }
58 |
59 | .divider {
60 | background-color: var(--bolus);
61 | height: 3px;
62 | margin: 5px -10px;
63 | }
64 |
--------------------------------------------------------------------------------
/src/components/daily/pumpsettingsoverridetooltip/PumpSettingsOverrideTooltip.css:
--------------------------------------------------------------------------------
1 | @import '../../../styles/colors.css';
2 |
3 | .container {
4 | opacity: 1;
5 | display: flex;
6 | flex-direction: column;
7 | min-width: 80px;
8 | margin: 2px 0;
9 | max-width: 250px;
10 | }
11 |
12 | .row {
13 | composes: smallSize from '../../../styles/typography.css';
14 | display: flex;
15 | flex-direction: row;
16 | justify-content: space-between;
17 | line-height: 20px;
18 | }
19 |
20 | .label {
21 | flex-grow: 1;
22 | }
23 |
24 | .boldLabel {
25 | composes: label;
26 | font-weight: bold;
27 | }
28 |
29 | .value {
30 | margin-left: 20px;
31 | }
32 |
33 | .title {
34 | composes: smallSize from '../../../styles/typography.css';
35 | text-align: center;
36 | }
37 |
38 | .target {
39 | composes: row;
40 | }
41 |
42 | .overrideType {
43 | composes: row;
44 | font-weight: normal;
45 | }
46 |
47 | .overrideType div:last-child {
48 | font-weight: bold;
49 | }
50 |
--------------------------------------------------------------------------------
/src/components/daily/smbgtooltip/SMBGTooltip.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 | @import '../../../styles/colors.css';
18 |
19 | .container {
20 | opacity: 1;
21 | display: flex;
22 | flex-direction: column;
23 | min-width: 80px;
24 | margin: 2px 0;
25 | max-width: 180px;
26 | }
27 |
28 | .row {
29 | composes: smallSize from '../../../styles/typography.css';
30 | display: flex;
31 | flex-direction: row;
32 | justify-content: space-between;
33 | line-height: 20px;
34 | }
35 |
36 | .label {
37 | flex-grow: 1;
38 | }
39 |
40 | .value {
41 | margin-left: 20px;
42 | }
43 |
44 | .units {
45 | min-width: 0.7em;
46 | margin-left: 10px;
47 | }
48 |
49 | .title {
50 | composes: smallSize from '../../../styles/typography.css';
51 | text-align: right;
52 | }
53 |
54 | .bg {
55 | composes: row;
56 | font-weight: bold;
57 | }
58 |
59 | .subType {
60 | composes: row;
61 | color: var(--gray-dark);
62 | }
63 |
64 | .confirmBg {
65 | composes: subType;
66 | }
67 |
68 | .source {
69 | composes: subType;
70 | }
71 |
72 | .annotation {
73 | composes: subType;
74 | }
75 |
76 | .divider {
77 | height: 3px;
78 | margin: 5px -10px;
79 | }
80 |
--------------------------------------------------------------------------------
/src/components/settings/README.md:
--------------------------------------------------------------------------------
1 | ## Device settings (i.e., insulin pump settings) utilities
2 |
3 | This directory contains the components required to visualize and also copy device settings
4 |
5 | ### Copy text
6 |
7 | *Aim:*
8 | To enable the easy copy and pasting of the settings while also allowing the user to modify the table that has been copied. To do this we need to remove all styles and have a very simple text representation of the table while still keeping its basic format.
9 |
10 | *In the component:*
11 | We are using `ClipboardButton` and then have built a text representation of the settings that essentially uses a command-line tool `text-table`. This is then embedded in a `
..
` tag as we want to ensure no styles are copied. All of the work is done in `utils/settings/textData.js` to build the table.
12 |
--------------------------------------------------------------------------------
/src/components/settings/common/CollapsibleContainer.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .secondaryLabel {
19 | composes: secondaryText from '../settings.css';
20 | }
21 |
22 | :global(.containerCollapse) {
23 | transition: height 250ms;
24 | }
25 |
--------------------------------------------------------------------------------
/src/components/settings/common/CollapsibleContainer.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 | import PropTypes from 'prop-types';
3 | import React from 'react';
4 | import { Collapse } from 'react-collapse';
5 |
6 | import SingleLineCollapsibleContainerLabel from './SingleLineCollapsibleContainerLabel';
7 | import TwoLineCollapsibleContainerLabel from './TwoLineCollapsibleContainerLabel';
8 |
9 | import styles from './CollapsibleContainer.css';
10 |
11 | const CollapsibleContainer = (props) => {
12 | const { label, labelClass, opened, toggleExpansion } = props;
13 | let renderedLabel = (
14 |
20 | );
21 | const { twoLineLabel, label: { secondary } } = props;
22 | if (twoLineLabel && !_.isEmpty(secondary)) {
23 | renderedLabel = (
24 |
30 | );
31 | }
32 |
33 | return (
34 |
35 | {renderedLabel}
36 |
41 |
{props.children}
42 |
43 |
44 | );
45 | };
46 |
47 | CollapsibleContainer.defaultProps = {
48 | twoLineLabel: true,
49 | };
50 |
51 | CollapsibleContainer.propTypes = {
52 | children: PropTypes.element.isRequired,
53 | label: PropTypes.shape({
54 | main: PropTypes.string.isRequired,
55 | secondary: PropTypes.string.isRequired,
56 | units: PropTypes.string.isRequired,
57 | }).isRequired,
58 | labelClass: PropTypes.string.isRequired,
59 | opened: PropTypes.bool.isRequired,
60 | toggleExpansion: PropTypes.func.isRequired,
61 | twoLineLabel: PropTypes.bool,
62 | };
63 |
64 | export default CollapsibleContainer;
65 |
--------------------------------------------------------------------------------
/src/components/settings/common/Header.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .header {
19 | position: relative;
20 | display: table;
21 | padding-left: 0px;
22 | margin-bottom: 5px;
23 | }
24 | .headerOuter:nth-last-of-type(1) .headerInner{
25 | transition-property: width;
26 | transition-duration: .25s;
27 | overflow: hidden;
28 | }
29 | .headerClosed .headerOuter:nth-last-of-type(1) .headerInner {
30 | width: 0px;
31 | }
32 | .headerExpanded .headerOuter:nth-last-of-type(1) .headerInner {
33 | width: 100%;
34 | }
35 | .headerOuter {
36 | composes: header;
37 | display: inline-block;
38 | font-weight: 300;
39 | overflow: hidden;
40 | }
41 | .headerInner {
42 | composes: header;
43 | display: block;
44 | margin: 5px 5px 5px 0;
45 | white-space: nowrap;
46 | }
47 | .headerOuter:nth-last-of-type(2) {
48 | padding-right: 10px;
49 | }
50 | .headerClosed .headerOuter:nth-last-of-type(2)::after {
51 | content: '›';
52 | font-size: 15px;
53 | font-weight: bold;
54 | position: absolute;
55 | right: 5px;
56 | top: 45%;
57 | transform: translateY(-50%);
58 | }
59 | .headerExpanded .headerOuter:nth-last-of-type(2)::after {
60 | content: '›';
61 | font-size: 15px;
62 | font-weight: bold;
63 | position: absolute;
64 | right: 5px;
65 | top: 55%;
66 | transform: rotate(180deg) translateY(50%);
67 | }
68 |
69 | @media print {
70 |
71 | .headerOuter {
72 | composes: lightText largeSize from '../../../styles/typography.css';
73 | color: var(--text-black);
74 | }
75 |
76 | .headerOuter:first-of-type {
77 | color: var(--text-black);
78 | font-weight: normal;
79 | font-size: 16px;
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/components/settings/common/Header.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import PropTypes from 'prop-types';
19 | import React, { PureComponent } from 'react';
20 |
21 | import styles from './Header.css';
22 |
23 | import i18next from 'i18next';
24 | const t = i18next.t.bind(i18next);
25 |
26 | class Header extends PureComponent {
27 | render() {
28 | return (
29 |
28 | );
29 | };
30 |
31 | SingleLineCollapsibleContainerLabel.propTypes = {
32 | className: PropTypes.string,
33 | isOpened: PropTypes.bool.isRequired,
34 | label: PropTypes.shape({
35 | main: PropTypes.string.isRequired,
36 | secondary: PropTypes.string.isRequired,
37 | units: PropTypes.string,
38 | }).isRequired,
39 | onClick: PropTypes.func.isRequired,
40 | };
41 |
42 | export default SingleLineCollapsibleContainerLabel;
43 |
--------------------------------------------------------------------------------
/src/components/settings/common/Table.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .secondaryLabelAlone {
19 | composes: secondaryLeftPadding from '../settings.css';
20 | font-weight: normal;
21 | }
22 |
23 | .secondaryLabelWithMain {
24 | composes: lightText from '../../../styles/typography.css';
25 | composes: secondaryLeftPadding from '../settings.css';
26 | }
27 |
28 | .tooltipIcon {
29 | position: relative;
30 | margin-right: .75em;
31 | float: right;
32 | }
33 |
34 | .tooltipIcon > img {
35 | width: 14px;
36 | }
37 |
38 | .rowTooltipIcon {
39 | composes: tooltipIcon;
40 | margin-right: 0;
41 | margin-left: .75em;
42 | float: none;
43 | }
44 |
45 | .rowTooltipIcon > img {
46 | width: 14px;
47 | }
48 |
49 | .TableTooltipWrapper {
50 | z-index: 1;
51 | position: relative;
52 | }
53 |
54 | @media print {
55 |
56 | .secondaryLabelWithMain {
57 | composes: lightText largeSize from '../../../styles/typography.css';
58 | color: var(--text-black);
59 | composes: secondaryLeftPadding from '../settings.css';
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/components/settings/common/TwoLineCollapsibleContainerLabel.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .collapsibleLabel {
19 | composes: settingsHeaderDecoration settingsHeaderLayout settingsHeaderText from '../settings.css';
20 | }
21 |
22 | .labelContainer {
23 | composes: defaultSize mediumContrastText from '../../../styles/typography.css';
24 | cursor: pointer;
25 | box-sizing: border-box;
26 | display: flex;
27 | flex-direction: column;
28 | justify-content: space-between;
29 | height: 66px;
30 | min-width: 240px;
31 | padding-top: 10px;
32 | padding-bottom: 10px;
33 | }
34 |
35 | .labelContainer:hover {
36 | color: var(--text-hover);
37 | }
38 |
39 | .norgieLabelContainer {
40 | composes: norgie from './norgie.css';
41 | display: flex;
42 | justify-content: space-between;
43 | align-items: baseline;
44 | }
45 |
46 | .mainText {
47 | composes: boldText from '../../../styles/typography.css';
48 | }
49 |
50 | .secondaryText {
51 | composes: secondaryText from '../settings.css';
52 | }
53 |
54 | .secondaryLabel {
55 | composes: lightText from '../../../styles/typography.css';
56 | }
57 |
58 | @media print {
59 |
60 | .labelContainer {
61 | composes: defaultSize mediumContrastText from '../../../styles/typography.css';
62 | cursor: pointer;
63 | box-sizing: border-box;
64 | display: flex;
65 | flex-direction: row-reverse;
66 | text-overflow: ellipsis;
67 | max-width: 280px;
68 | min-width: 200px;
69 | padding-top: 10px;
70 | padding-bottom: 10px;
71 | height: auto;
72 | }
73 |
74 | .mainText{
75 | composes: mainHeaderText from '../settings.css';
76 | }
77 |
78 | .secondaryText,
79 | .secondaryLabel {
80 | composes: secondaryText from '../settings.css';
81 | }
82 |
83 | }
--------------------------------------------------------------------------------
/src/components/settings/common/TwoLineCollapsibleContainerLabel.js:
--------------------------------------------------------------------------------
1 | import cx from 'classnames';
2 | import PropTypes from 'prop-types';
3 | import React from 'react';
4 |
5 | import norgie from './norgie.css';
6 | import styles from './TwoLineCollapsibleContainerLabel.css';
7 |
8 | const TwoLineCollapsibleContainerLabel = (props) => {
9 | const { className, isOpened, label: { main, secondary, units }, onClick } = props;
10 | const containerClasses = cx({
11 | label: true, // for testing
12 | [styles.collapsibleLabel]: !Boolean(className),
13 | [styles.labelContainer]: true,
14 | [className]: Boolean(className),
15 | });
16 | const norgieContainerClasses = cx({
17 | [styles.norgieLabelContainer]: true,
18 | [norgie.opened]: isOpened,
19 | });
20 | return (
21 |
22 |
{secondary}
23 |
24 |
25 | {main}
26 | {units}
27 |
28 |
29 |
30 | );
31 | };
32 |
33 | TwoLineCollapsibleContainerLabel.propTypes = {
34 | className: PropTypes.string,
35 | isOpened: PropTypes.bool.isRequired,
36 | label: PropTypes.shape({
37 | main: PropTypes.string.isRequired,
38 | secondary: PropTypes.string.isRequired,
39 | units: PropTypes.string.isRequired,
40 | }),
41 | onClick: PropTypes.func.isRequired,
42 | };
43 |
44 | export default TwoLineCollapsibleContainerLabel;
45 |
--------------------------------------------------------------------------------
/src/components/settings/common/norgie.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .norgie {
19 |
20 | }
21 |
22 | .norgie::after {
23 | content: '›';
24 | font-size: 15px;
25 | font-weight: bold;
26 | padding-left: 8px;
27 | margin-right: 16px;
28 | transform: rotate(0deg);
29 |
30 | transition-duration: 0.25s;
31 | transition-property: rotate, transform;
32 | }
33 |
34 | .opened::after {
35 | transform: rotate(90deg) translate(-20%, -15%);
36 | }
37 |
38 | @media print {
39 | .norgie::after {
40 | content: '';
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/components/trends/cbg/CBGDateTraceAnimated.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .border {
19 | stroke: white;
20 | stroke-width: 0.5px;
21 | }
22 |
23 | .veryLow {
24 | composes: border;
25 | composes: bgVeryLow from '../../../styles/diabetes.css';
26 | }
27 |
28 | .low {
29 | composes: border;
30 | composes: bgLow from '../../../styles/diabetes.css';
31 | }
32 |
33 | .target {
34 | composes: border;
35 | composes: bgTarget from '../../../styles/diabetes.css';
36 | }
37 |
38 | .high {
39 | composes: border;
40 | composes: bgHigh from '../../../styles/diabetes.css';
41 | }
42 |
43 | .veryHigh {
44 | composes: border;
45 | composes: bgVeryHigh from '../../../styles/diabetes.css';
46 | }
47 |
--------------------------------------------------------------------------------
/src/components/trends/cbg/CBGDateTraceLabel.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .container {
19 | composes: absolute smallHorizontalPadding from '../../../styles/layout.css';
20 | top: 0px;
21 | z-index: 1;
22 | }
23 |
24 | .dateLabel {
25 | composes: highContrastText noWrap defaultSize from '../../../styles/typography.css';
26 | }
27 |
--------------------------------------------------------------------------------
/src/components/trends/cbg/CBGDateTraceLabel.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import PropTypes from 'prop-types';
19 | import React from 'react';
20 |
21 | import Tooltip from '../../common/tooltips/Tooltip';
22 |
23 | import { utcFormat } from 'd3-time-format';
24 |
25 | import styles from './CBGDateTraceLabel.css';
26 |
27 | const CBGDateTraceLabel = (props) => {
28 | if (!props.focusedDateTrace) {
29 | return null;
30 | }
31 | const { focusedDateTrace: { data: { localDate: date }, position } } = props;
32 | const formattedDate = utcFormat('%A, %B %-d')(Date.parse(date));
33 | return (
34 |
43 | );
44 | };
45 |
46 | CBGDateTraceLabel.propTypes = {
47 | focusedDateTrace: PropTypes.shape({
48 | data: PropTypes.shape({
49 | localDate: PropTypes.string.isRequired,
50 | }),
51 | position: PropTypes.shape({
52 | left: PropTypes.number.isRequired,
53 | yPositions: PropTypes.shape({
54 | top: PropTypes.number.isRequired,
55 | topMargin: PropTypes.number.isRequired,
56 | }),
57 | }),
58 | }),
59 | };
60 |
61 | export default CBGDateTraceLabel;
62 |
--------------------------------------------------------------------------------
/src/components/trends/cbg/CBGDateTracesAnimationContainer.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 | import PropTypes from 'prop-types';
3 | import React from 'react';
4 | import TransitionGroupPlus from 'react-transition-group-plus';
5 |
6 | import CBGDateTraceAnimated from './CBGDateTraceAnimated';
7 |
8 | const CBGDateTracesAnimationContainer = (props) => {
9 | const { bgBounds, bgUnits, data, dates, topMargin, xScale, yScale } = props;
10 | return (
11 |
12 | {_.map(dates, (localDate) => (
13 |
26 | ))}
27 |
28 | );
29 | };
30 |
31 | CBGDateTracesAnimationContainer.propTypes = {
32 | bgBounds: PropTypes.shape({
33 | veryHighThreshold: PropTypes.number.isRequired,
34 | targetUpperBound: PropTypes.number.isRequired,
35 | targetLowerBound: PropTypes.number.isRequired,
36 | veryLowThreshold: PropTypes.number.isRequired,
37 | }).isRequired,
38 | data: PropTypes.object,
39 | dates: PropTypes.arrayOf(PropTypes.string),
40 | focusCbgDateTrace: PropTypes.func.isRequired,
41 | unfocusCbgDateTrace: PropTypes.func.isRequired,
42 | onSelectDate: PropTypes.func.isRequired,
43 | topMargin: PropTypes.number.isRequired,
44 | xScale: PropTypes.func.isRequired,
45 | yScale: PropTypes.func.isRequired,
46 | };
47 |
48 | export default CBGDateTracesAnimationContainer;
49 |
--------------------------------------------------------------------------------
/src/components/trends/cbg/FocusedCBGSliceSegment.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | :export {
19 | stroke: 2;
20 | }
21 |
22 | .segment {
23 | stroke: black;
24 | stroke-width: 2;
25 | pointer-events: none;
26 | fill: transparent;
27 | }
--------------------------------------------------------------------------------
/src/components/trends/cbg/RangeSelect.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .container {
19 | display: flex;
20 | flex-direction: row;
21 | composes: mediumContrastText defaultSize from '../../../styles/typography.css';
22 | padding-top: 15px;
23 | }
24 |
--------------------------------------------------------------------------------
/src/components/trends/common/Background.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .background {
19 | stroke: var(--bkgrnd-lines);
20 | stroke-width: 1px;
21 | fill: var(--bkgrnd);
22 | }
23 |
24 | .threeHrLine {
25 | stroke: var(--bkgrnd-lines);
26 | stroke-width: 1px;
27 | }
--------------------------------------------------------------------------------
/src/components/trends/common/Background.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 | import { range } from 'd3-array';
3 | import PropTypes from 'prop-types';
4 | import React from 'react';
5 |
6 | import * as datetime from '../../../utils/datetime';
7 |
8 | import styles from './Background.css';
9 |
10 | const Background = (props) => {
11 | const { data, margins, svgDimensions, xScale } = props;
12 |
13 | const width = svgDimensions.width - margins.left - margins.right;
14 | const height = svgDimensions.height - margins.top - margins.bottom;
15 |
16 | const lines = props.linesAtThreeHrs ? _.map(data, (val, i) => (
17 |
25 | )) : null;
26 |
27 | return (
28 |
29 |
36 | {lines}
37 |
38 | );
39 | };
40 |
41 | Background.defaultProps = {
42 | data: _.map(range(1, 8), (i) => (i * datetime.THREE_HRS)),
43 | linesAtThreeHrs: false,
44 | };
45 |
46 | Background.propTypes = {
47 | data: PropTypes.arrayOf(PropTypes.number.isRequired).isRequired,
48 | linesAtThreeHrs: PropTypes.bool.isRequired,
49 | margins: PropTypes.shape({
50 | top: PropTypes.number.isRequired,
51 | right: PropTypes.number.isRequired,
52 | bottom: PropTypes.number.isRequired,
53 | left: PropTypes.number.isRequired,
54 | }).isRequired,
55 | svgDimensions: PropTypes.shape({
56 | width: PropTypes.number.isRequired,
57 | height: PropTypes.number.isRequired,
58 | }).isRequired,
59 | xScale: PropTypes.func.isRequired,
60 | };
61 |
62 | export default Background;
63 |
--------------------------------------------------------------------------------
/src/components/trends/common/FocusedRangeLabels.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .container {
19 | composes: absolute smallHorizontalPadding from '../../../styles/layout.css';
20 | top: 0px;
21 | z-index: 1;
22 | }
23 |
24 | .number {
25 | composes: boldText highContrastText noWrap largeSize from '../../../styles/typography.css';
26 | }
27 |
28 | .explainerText {
29 | composes: highContrastText noWrap from '../../../styles/typography.css';
30 | display: block;
31 | }
32 |
33 | .timeLabel {
34 | composes: highContrastText noWrap defaultSize from '../../../styles/typography.css';
35 | }
36 |
--------------------------------------------------------------------------------
/src/components/trends/common/NoData.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .noDataMsg {
19 | composes: mediumContrastText svgMiddleAnchored from '../../../styles/typography.css';
20 | }
--------------------------------------------------------------------------------
/src/components/trends/common/TargetRangeLines.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .targetRangeLine {
19 | pointer-events: none;
20 |
21 | stroke: white;
22 | stroke-dasharray: 9,9;
23 | stroke-width: 2px;
24 | }
--------------------------------------------------------------------------------
/src/components/trends/common/TargetRangeLines.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import PropTypes from 'prop-types';
19 | import React from 'react';
20 |
21 | import styles from './TargetRangeLines.css';
22 |
23 | const TargetRangeLines = (props) => {
24 | const { bgBounds, smbgOpts, xScale, yScale } = props;
25 | const x1 = xScale.range()[0] - smbgOpts.maxR;
26 | const x2 = xScale.range()[1] + smbgOpts.maxR;
27 | return (
28 |
29 |
37 |
45 |
46 | );
47 | };
48 |
49 | TargetRangeLines.propTypes = {
50 | bgBounds: PropTypes.shape({
51 | veryHighThreshold: PropTypes.number.isRequired,
52 | targetUpperBound: PropTypes.number.isRequired,
53 | targetLowerBound: PropTypes.number.isRequired,
54 | veryLowThreshold: PropTypes.number.isRequired,
55 | }),
56 | smbgOpts: PropTypes.shape({
57 | maxR: PropTypes.number.isRequired,
58 | r: PropTypes.number.isRequired,
59 | }).isRequired,
60 | xScale: PropTypes.func.isRequired,
61 | yScale: PropTypes.func.isRequired,
62 | };
63 |
64 | TargetRangeLines.displayName = 'TargetRangeLines';
65 |
66 | export default TargetRangeLines;
67 |
--------------------------------------------------------------------------------
/src/components/trends/common/XAxisLabels.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .text {
19 | composes: axisSize mediumContrastText svgStartAnchored from '../../../styles/typography.css';
20 | }
21 |
22 | .focusedRange {
23 | composes: axisSize boldText mediumContrastText svgStartAnchored from '../../../styles/typography.css';
24 | }
--------------------------------------------------------------------------------
/src/components/trends/common/XAxisLabels.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 | import { range } from 'd3-array';
3 | import PropTypes from 'prop-types';
4 | import React from 'react';
5 |
6 | import { formatClocktimeFromMsPer24, THREE_HRS } from '../../../utils/datetime';
7 |
8 | import styles from './XAxisLabels.css';
9 |
10 | const XAxisLabels = (props) => {
11 | const { data, margins, xOffset, xScale, yOffset } = props;
12 | const yPos = margins.top - yOffset;
13 |
14 | return (
15 |
16 | {_.map(data, (msInDay) => {
17 | const displayTime = formatClocktimeFromMsPer24(msInDay, 'h a');
18 | return (
19 |
25 | {displayTime}
26 |
27 | );
28 | })}
29 |
30 | );
31 | };
32 |
33 | XAxisLabels.defaultProps = {
34 | data: _.map(range(0, 8), (i) => (i * THREE_HRS)),
35 | xOffset: 5,
36 | yOffset: 5,
37 | };
38 |
39 | XAxisLabels.propTypes = {
40 | data: PropTypes.arrayOf(PropTypes.number.isRequired).isRequired,
41 | margins: PropTypes.shape({
42 | top: PropTypes.number.isRequired,
43 | right: PropTypes.number.isRequired,
44 | bottom: PropTypes.number.isRequired,
45 | left: PropTypes.number.isRequired,
46 | }).isRequired,
47 | xOffset: PropTypes.number.isRequired,
48 | xScale: PropTypes.func.isRequired,
49 | yOffset: PropTypes.number.isRequired,
50 | };
51 |
52 | export default XAxisLabels;
53 |
--------------------------------------------------------------------------------
/src/components/trends/common/XAxisTicks.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .tick {
19 | stroke: var(--axis-tick);
20 | }
--------------------------------------------------------------------------------
/src/components/trends/common/XAxisTicks.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 | import { range } from 'd3-array';
3 | import PropTypes from 'prop-types';
4 | import React from 'react';
5 |
6 | import * as datetime from '../../../utils/datetime';
7 |
8 | import styles from './XAxisTicks.css';
9 |
10 | const XAxisTicks = (props) => {
11 | const { data, margins, tickLength, xScale } = props;
12 | return (
13 |
14 | {_.map(data, (msInDay) => (
15 |
23 | ))}
24 |
25 | );
26 | };
27 |
28 | XAxisTicks.defaultProps = {
29 | data: _.map(range(0, 9), (i) => (i * datetime.THREE_HRS)),
30 | tickLength: 15,
31 | };
32 |
33 | XAxisTicks.propTypes = {
34 | data: PropTypes.arrayOf(PropTypes.number.isRequired).isRequired,
35 | margins: PropTypes.shape({
36 | top: PropTypes.number.isRequired,
37 | right: PropTypes.number.isRequired,
38 | bottom: PropTypes.number.isRequired,
39 | left: PropTypes.number.isRequired,
40 | }).isRequired,
41 | tickLength: PropTypes.number.isRequired,
42 | xScale: PropTypes.func.isRequired,
43 | };
44 |
45 | export default XAxisTicks;
46 |
--------------------------------------------------------------------------------
/src/components/trends/common/YAxisLabelsAndTicks.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .text {
19 | composes: axisSize mediumContrastText svgRightAnchored svgVerticalCentered from '../../../styles/typography.css';
20 | }
21 |
22 | .tick {
23 | stroke: var(--axis-tick);
24 | }
--------------------------------------------------------------------------------
/src/components/trends/common/YAxisLabelsAndTicks.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 | import PropTypes from 'prop-types';
3 | import React from 'react';
4 |
5 | import { MGDL_UNITS, MMOLL_UNITS } from '../../../utils/constants';
6 | import { formatBgValue } from '../../../utils/format';
7 |
8 | import styles from './YAxisLabelsAndTicks.css';
9 |
10 | const YAxisLabels = (props) => {
11 | const { bgPrefs, margins, textToTickGap, tickWidth, yScale } = props;
12 | const { bgBounds } = bgPrefs;
13 |
14 | return (
15 |
16 | {_.map(['targetLowerBound', 'targetUpperBound', 'veryHighThreshold', 'veryLowThreshold'],
17 | (boundKey) => (
18 |
19 |
24 | {formatBgValue(bgBounds[boundKey], bgPrefs)}
25 |
26 |
33 |
34 | )
35 | )}
36 |
37 | );
38 | };
39 |
40 | YAxisLabels.defaultProps = {
41 | textToTickGap: 2,
42 | tickWidth: 8,
43 | };
44 |
45 | YAxisLabels.propTypes = {
46 | bgPrefs: PropTypes.shape({
47 | bgBounds: PropTypes.shape({
48 | veryHighThreshold: PropTypes.number.isRequired,
49 | targetUpperBound: PropTypes.number.isRequired,
50 | targetLowerBound: PropTypes.number.isRequired,
51 | veryLowThreshold: PropTypes.number.isRequired,
52 | }),
53 | bgUnits: PropTypes.oneOf([MGDL_UNITS, MMOLL_UNITS]).isRequired,
54 | }),
55 | margins: PropTypes.shape({
56 | top: PropTypes.number.isRequired,
57 | right: PropTypes.number.isRequired,
58 | bottom: PropTypes.number.isRequired,
59 | left: PropTypes.number.isRequired,
60 | }).isRequired,
61 | textToTickGap: PropTypes.number.isRequired,
62 | tickWidth: PropTypes.number.isRequired,
63 | yScale: PropTypes.func.isRequired,
64 | };
65 |
66 | export default YAxisLabels;
67 |
--------------------------------------------------------------------------------
/src/components/trends/common/withDefaultYPosition.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import PropTypes from 'prop-types';
19 | import React from 'react';
20 |
21 | const withDefaultYPosition = (WrappedComponent) => {
22 | const WithDefault = (props) => {
23 | const { bgBounds: { targetLowerBound, targetUpperBound }, yScale } = props;
24 |
25 | // default Y position is the center of the target range
26 | // i.e., 100 mg/dL if target range is 80-120 mg/dL
27 | const defaultY = yScale(targetUpperBound - (targetUpperBound - targetLowerBound) / 2);
28 |
29 | return (
30 |
31 | );
32 | };
33 |
34 | WithDefault.propTypes = {
35 | bgBounds: PropTypes.shape({
36 | targetLowerBound: PropTypes.number.isRequired,
37 | targetUpperBound: PropTypes.number.isRequired,
38 | }).isRequired,
39 | yScale: PropTypes.func.isRequired,
40 | };
41 |
42 | return WithDefault;
43 | };
44 |
45 | export default withDefaultYPosition;
46 |
--------------------------------------------------------------------------------
/src/components/trends/smbg/FocusedSMBGPointLabel.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .container {
19 | composes: absolute smallHorizontalPadding from '../../../styles/layout.css';
20 | top: 0px;
21 | z-index: 1;
22 | }
23 |
24 | .number {
25 | composes: boldText highContrastText noWrap largeSize from '../../../styles/typography.css';
26 | }
27 |
28 | .explainerText {
29 | composes: smallSize noWrap from '../../../styles/typography.css';
30 | display: block;
31 | }
32 |
33 | .detailNumber {
34 | composes: explainerText number;
35 | text-align: center;
36 | }
37 |
38 | .dateTime {
39 | composes: explainerText;
40 | }
41 |
42 | .subType {
43 | composes: explainerText;
44 | font-style: italic;
45 | }
46 |
47 | .tipWrapper {
48 | text-align: right;
49 | }
50 |
--------------------------------------------------------------------------------
/src/components/trends/smbg/SMBGDateLineAnimated.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .smbgPath {
19 | fill: none;
20 | stroke: var(--trends--dark);
21 | stroke-dasharray: 4, 4;
22 | }
23 |
24 | .highlightPath {
25 | stroke-width: 2px;
26 | stroke-dasharray: 4, 0;
27 | }
28 |
--------------------------------------------------------------------------------
/src/components/trends/smbg/SMBGDatePointsAnimated.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .veryLow {
19 | composes: bgVeryLow from '../../../styles/diabetes.css';
20 | }
21 |
22 | .low {
23 | composes: bgLow from '../../../styles/diabetes.css';
24 | }
25 |
26 | .target {
27 | composes: bgTarget from '../../../styles/diabetes.css';
28 | }
29 |
30 | .high {
31 | composes: bgHigh from '../../../styles/diabetes.css';
32 | }
33 |
34 | .veryHigh {
35 | composes: bgVeryHigh from '../../../styles/diabetes.css';
36 | }
37 |
--------------------------------------------------------------------------------
/src/components/trends/smbg/SMBGRangeAnimated.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | @keyframes fadein {
19 | from {
20 | fill-opacity: 0.3;
21 | }
22 | to {
23 | fill-opacity: 0.4;
24 | }
25 | }
26 |
27 | @keyframes fadeout {
28 | from {
29 | fill-opacity: 0.4;
30 | }
31 | to {
32 | fill-opacity: 0.3;
33 | }
34 | }
35 |
36 | .smbgRange {
37 | fill: var(--trends--light);
38 | stroke: none;
39 | }
40 |
41 | .fadeIn {
42 | animation: fadein 0.25s forwards ease-in-out;
43 | }
44 |
45 | .fadeOut {
46 | animation: fadeout 0.25s forwards ease-in-out;
47 | }
48 |
--------------------------------------------------------------------------------
/src/modules/data/index.js:
--------------------------------------------------------------------------------
1 | import DataUtil from '../../utils/DataUtil';
2 |
3 | export {
4 | DataUtil,
5 | };
6 |
--------------------------------------------------------------------------------
/src/modules/print/pdfkitHelpers.js:
--------------------------------------------------------------------------------
1 | /* global self */
2 |
3 | export const waitForData = async doc => new Promise((resolve, reject) => {
4 | const buffers = [];
5 | doc.on('data', buffers.push.bind(buffers));
6 | doc.on('end', async () => {
7 | const pdfBuffer = Buffer.concat(buffers);
8 | const pdfBase64 = pdfBuffer.toString('base64');
9 | resolve(pdfBase64);
10 | });
11 | doc.on('error', reject);
12 | });
13 |
14 | export const base64ToArrayBuffer = base64Str => {
15 | const binaryString = self.atob(base64Str);
16 | const binaryLen = binaryString.length;
17 | const bytes = new Uint8Array(binaryLen);
18 |
19 | for (let i = 0; i < binaryLen; i++) {
20 | const ascii = binaryString.charCodeAt(i);
21 | bytes[i] = ascii;
22 | }
23 |
24 | return bytes;
25 | };
26 |
--------------------------------------------------------------------------------
/src/modules/print/registerStaticFiles.js:
--------------------------------------------------------------------------------
1 | // ref https://github.com/foliojs/pdfkit/blob/65670353f9a3f4ceea2ac0f37cd92f476bfd11ae/examples/webpack/src/registerStaticFiles.js
2 |
3 | // the fs here is not node fs but the provided virtual one
4 | import fs from 'fs';
5 | import forEach from 'lodash/forEach';
6 | // the content file is returned as is (webpack is configured to load *.afm files as asset/source)
7 |
8 | function registerBinaryFiles(ctx) {
9 | forEach(ctx.keys(), key => {
10 | // extracts "./" from beginning of the key
11 | fs.writeFileSync(key.substring(2), ctx(key));
12 | });
13 | }
14 |
15 | function registerAFMFonts(ctx) {
16 | forEach(ctx.keys(), key => {
17 | const match = key.match(/([^/]*\.afm$)/);
18 | if (match) {
19 | // afm files must be stored on data path
20 | fs.writeFileSync(`data/${match[0]}`, ctx(key));
21 | }
22 | });
23 | }
24 |
25 | // register all files found in assets folder (relative to src)
26 | registerBinaryFiles(require.context('/static-assets', true));
27 |
28 | // register AFM fonts distributed with pdfkit
29 | // is good practice to register only required fonts to avoid the bundle size increase too much
30 | registerAFMFonts(require.context('pdfkit/js/data', false, /Helvetica.*\.afm$/));
31 |
--------------------------------------------------------------------------------
/src/modules/print/utils/constants.js:
--------------------------------------------------------------------------------
1 | // DPI here is the coordinate system, not the resolution; sub-dot precision renders crisply!
2 | export const DPI = 72;
3 | export const MARGIN = DPI / 2;
4 | export const HEIGHT = 11 * DPI - (2 * MARGIN);
5 | export const WIDTH = 8.5 * DPI - (2 * MARGIN);
6 | export const MARGINS = {
7 | left: MARGIN,
8 | top: MARGIN,
9 | right: MARGIN,
10 | bottom: MARGIN,
11 | };
12 | export const DEFAULT_FONT_SIZE = 10;
13 | export const LARGE_FONT_SIZE = 12;
14 | export const FOOTER_FONT_SIZE = 8;
15 | export const HEADER_FONT_SIZE = 14;
16 | export const SMALL_FONT_SIZE = 8;
17 | export const EXTRA_SMALL_FONT_SIZE = 6;
18 |
--------------------------------------------------------------------------------
/src/propTypes/index.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import { MGDL_UNITS, MMOLL_UNITS } from '../utils/constants';
3 |
4 | export const bgPrefsPropType = PropTypes.shape({
5 | bgBounds: PropTypes.shape({
6 | veryHighThreshold: PropTypes.number.isRequired,
7 | targetUpperBound: PropTypes.number.isRequired,
8 | targetLowerBound: PropTypes.number.isRequired,
9 | veryLowThreshold: PropTypes.number.isRequired,
10 | }),
11 | bgUnits: PropTypes.oneOf([MGDL_UNITS, MMOLL_UNITS]),
12 | });
13 |
--------------------------------------------------------------------------------
/src/styles/layout.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .absolute {
19 | pointer-events: none;
20 | position: absolute;
21 | }
22 |
23 | .smallHorizontalPadding {
24 | padding: 0px 6px;
25 | }
--------------------------------------------------------------------------------
/src/styles/typography.css:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | .whiteText {
19 | color: white;
20 | fill: white;
21 | }
22 |
23 | .boldText {
24 | font-weight: bold;
25 | }
26 |
27 | .lightText {
28 | font-weight: 300;
29 | }
30 |
31 | .smallSize {
32 | font-size: 12px;
33 | }
34 |
35 | .axisSize {
36 | font-size: 14px;
37 | }
38 |
39 | .defaultSize {
40 | font-size: 14px;
41 | }
42 |
43 | .largeSize {
44 | font-size: 16px;
45 | }
46 |
47 | .extraLargeSize {
48 | font-size: 24px;
49 | }
50 |
51 | .mediumContrastText {
52 | color: var(--text-medium-contrast);
53 | fill: var(--text-medium-contrast);
54 | }
55 |
56 | .highContrastText {
57 | color: var(--text-high-contrast);
58 | fill: var(--text-high-contrast);
59 | }
60 |
61 | .noWrap {
62 | white-space: nowrap;
63 | }
64 |
65 | .svgMiddleAnchored {
66 | text-anchor: middle;
67 | }
68 |
69 | .svgRightAnchored {
70 | text-anchor: end;
71 | }
72 |
73 | .svgStartAnchored {
74 | text-anchor: start;
75 | }
76 |
77 | .svgVerticalCentered {
78 | dominant-baseline: central;
79 | }
80 |
--------------------------------------------------------------------------------
/src/utils/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [
3 | "moment-utc"
4 | ],
5 | "rules": {
6 | "moment-utc/no-moment-without-utc": 2,
7 | "require-jsdoc": "error"
8 | }
9 | }
--------------------------------------------------------------------------------
/src/utils/apidocs/README.md:
--------------------------------------------------------------------------------
1 | ## @tidepool/viz utilities API documentation
2 |
3 | This documentation is generated using [jsdoc2md](https://github.com/jsdoc2md/jsdoc-to-markdown 'jsdoc2md').
4 |
5 | Contents:
6 | - [blood glucose utilities](./bloodglucose.md 'bloodglucose utilities')
7 | - [bolus utilities](./bolus.md 'bolus utilities')
8 | - [datetime utilities](./datetime.md 'datetime utilities')
9 | - [formatting utilities](./format.md 'format utilities')
10 | - [miscellaneous utilities](./misc.md 'misc utilities')
11 |
--------------------------------------------------------------------------------
/src/utils/apidocs/basal.md:
--------------------------------------------------------------------------------
1 |
2 | > @tidepool/viz@0.8.1 apidocs /Users/jebeck/Tidepool/viz
3 | > jsdoc2md "src/utils/basal.js"
4 |
5 | ## Functions
6 |
7 |
89 | ));
90 |
--------------------------------------------------------------------------------
/stories/components/trends/common/Background.js:
--------------------------------------------------------------------------------
1 | import { scaleLinear } from 'd3-scale';
2 | import React from 'react';
3 |
4 | import { storiesOf } from '@storybook/react';
5 |
6 | // eslint-disable-next-line max-len
7 | import Background from '../../../../src/components/trends/common/Background';
8 |
9 | const w = 800;
10 | const h = 450;
11 | const props = {
12 | margins: {
13 | left: 0,
14 | right: 0,
15 | top: 0,
16 | bottom: 0,
17 | },
18 | svgDimensions: {
19 | width: w,
20 | height: h,
21 | },
22 | xScale: scaleLinear().domain([0, 864e5]).range([0, w]),
23 | };
24 |
25 | storiesOf('Background', module)
26 | .add('without lines', () => (
27 |
30 | ))
31 | .add('with lines at three-hour intervals', () => (
32 |
35 | ));
36 |
--------------------------------------------------------------------------------
/stories/fonts.css:
--------------------------------------------------------------------------------
1 | @import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,300italic,400italic,600italic,700italic);
2 |
3 | :root {
4 | font-family: "Basis", "Helvetica Neue", Helvetica, Arial, sans-serif;
5 | }
6 |
--------------------------------------------------------------------------------
/stories/index.js:
--------------------------------------------------------------------------------
1 | require('../src/styles/colors.css');
2 | require('./fonts.css');
3 |
--------------------------------------------------------------------------------
/stories/print/PrescriptionPrintPDF.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 | import { storiesOf } from '@storybook/react';
20 | import PDFDocument from 'pdfkit';
21 |
22 | import { createPrintView } from '../../src/modules/print/index';
23 | import { MARGIN } from '../../src/modules/print/utils/constants';
24 | import PrintView from '../../src/modules/print/PrintView';
25 | import { base64ToArrayBuffer, waitForData } from '../../src/modules/print/pdfkitHelpers';
26 |
27 | import * as profiles from '../../data/patient/profiles';
28 | import { MGDL_UNITS } from '../../src/utils/constants';
29 | import { prescriptionData } from '../../data/print/fixtures';
30 |
31 | /* global window */
32 | /* eslint-disable max-len */
33 |
34 | const stories = storiesOf('Prescription View PDF', module);
35 |
36 | function openPDF({ patient }) {
37 | const doc = new PDFDocument({ autoFirstPage: false, bufferPages: true, margin: MARGIN });
38 |
39 | const opts = {
40 | patient,
41 | };
42 |
43 | const data = {
44 | ...prescriptionData,
45 | bgPrefs: { bgUnits: MGDL_UNITS },
46 | };
47 |
48 | createPrintView('prescription', data, opts, doc).render();
49 | PrintView.renderPageNumbers(doc);
50 |
51 | waitForData(doc)
52 | .then(dataUrl => {
53 | const byte = base64ToArrayBuffer(dataUrl);
54 | const blob = new Blob([byte], { type: 'application/pdf' });
55 | window.open(URL.createObjectURL(blob), '_blank');
56 | })
57 | .catch(error => {
58 | console.log(error);
59 | });
60 |
61 | doc.end();
62 | }
63 |
64 | stories.add('standard account', () => (
65 |
68 | ));
69 |
--------------------------------------------------------------------------------
/storiesDatatypes/components/common/data/Suspend.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 | import { scaleLinear } from 'd3-scale';
20 | import { storiesOf } from '@storybook/react';
21 |
22 | import Suspend from '../../../../src/components/common/data/Suspend';
23 |
24 | import SixHrScaleSVGDecorator, { HEIGHT, xScale } from '../../../helpers/SixHrScaleSVGDecorator';
25 |
26 | const yScale = scaleLinear().domain([0, 15]).range([HEIGHT, 0]);
27 |
28 | import * as suspends from '../../../../data/deviceEvent/fixtures';
29 |
30 | const stories = storiesOf('Suspend', module);
31 | stories.addDecorator(SixHrScaleSVGDecorator);
32 |
33 | stories.add('single automated suspend', () => (
34 |
35 | ), { notes: 'A single automated suspend' });
36 | stories.add('multiple automated suspends', () => (
37 |
38 | ), { notes: 'A set of automated suspends' });
39 |
--------------------------------------------------------------------------------
/storiesDatatypes/components/index.js:
--------------------------------------------------------------------------------
1 | require('../../src/styles/colors.css');
2 | require('../../stories/fonts.css');
3 |
--------------------------------------------------------------------------------
/storiesDatatypes/helpers/SixHrScaleSVGDecorator.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import { scaleLinear } from 'd3-scale';
19 | import React from 'react';
20 |
21 | export const WIDTH = 345;
22 | export const HEIGHT = 145;
23 |
24 | const longestTick = 40;
25 |
26 | const SixHrScaleSVGDecorator = (story) => (
27 |
51 | );
52 |
53 | export const xScale = scaleLinear().domain([0, 216e5]).range([115, WIDTH]);
54 |
55 | export default SixHrScaleSVGDecorator;
56 |
--------------------------------------------------------------------------------
/storybook/main.js:
--------------------------------------------------------------------------------
1 | import custom from './webpack.config.js';
2 |
3 | const config = {
4 | framework: '@storybook/react-webpack5',
5 | stories: ['../stories/**/*.@(js|jsx|mjs|ts|tsx)'],
6 |
7 | addons: [
8 | '@storybook/addon-essentials',
9 | '@storybook/addon-knobs',
10 | ],
11 |
12 | features: {
13 | storyStoreV7: false,
14 | },
15 |
16 | webpackFinal: async (config) => {
17 | delete config.resolve.fallback.fs;
18 |
19 | const finalConfig = {
20 | ...config,
21 | module: { ...config.module, rules: [
22 | ...config.module.rules.filter(rule => {
23 | return rule.test
24 | ? rule.test.toString().indexOf('css') === -1 && rule.test.toString().indexOf('svg') === -1
25 | : true;
26 | }),
27 | ...custom.module.rules,
28 | ] },
29 | resolve: { ...config.resolve,
30 | alias: {
31 | ...config.resolve.alias,
32 | ...custom.resolve.alias,
33 | },
34 | fallback: {
35 | ...config.resolve.fallback,
36 | ...custom.resolve.fallback,
37 | },
38 | },
39 | plugins: [...config.plugins, ...custom.plugins],
40 | devtool: 'inline-source-map',
41 | };
42 |
43 | return finalConfig;
44 | },
45 | };
46 |
47 | export default config;
48 |
--------------------------------------------------------------------------------
/storybook/preview.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import DataUtil from '../src/utils/DataUtil';
4 |
5 | let data;
6 | try {
7 | // eslint-disable-next-line global-require, import/no-unresolved
8 | data = require('../local/rawData.json');
9 | let dataSource = 'the Tidepool API';
10 |
11 | if (data?.data?.current?.data) {
12 | data = _.flatten(_.values(data.data.current.data));
13 | dataSource = 'a Tidepool Web console export';
14 | } else if (data?.[0].dataset) {
15 | data = _.flatten(_.map(data, v => v.data));
16 | dataSource = 'a Tidepool Account Tool export';
17 | }
18 |
19 | console.log(`Loading dataset provided by ${dataSource}`);
20 | } catch (e) {
21 | data = { data: [] };
22 | }
23 |
24 | const patientId = 'abc123';
25 | const dataUtil = new DataUtil();
26 | dataUtil.addData(data, patientId);
27 |
28 | const props = {
29 | dataUtil,
30 | patientId,
31 | };
32 |
33 | const preview = {
34 | decorators: [
35 | (Story) => (
36 |
{Story(props)}
37 | ),
38 | ],
39 | };
40 |
41 | export default preview;
42 |
--------------------------------------------------------------------------------
/storybook/webpack.config.js:
--------------------------------------------------------------------------------
1 | const config = require('../webpack.config.js');
2 |
3 | module.exports = config;
4 |
--------------------------------------------------------------------------------
/storybookDatatypes/main.js:
--------------------------------------------------------------------------------
1 | import custom from './webpack.config.js';
2 |
3 | const config = {
4 | framework: '@storybook/react-webpack5',
5 | stories: ['../storiesDatatypes/components/**/*.@(js|jsx|mjs|ts|tsx)'],
6 |
7 | addons: [
8 | '@storybook/addon-essentials',
9 | ],
10 |
11 | features: {
12 | storyStoreV7: false,
13 | },
14 |
15 | webpackFinal: async (config) => {
16 | delete config.resolve.fallback.fs;
17 |
18 | const finalConfig = {
19 | ...config,
20 | module: { ...config.module, rules: [
21 | ...config.module.rules.filter(rule => {
22 | return rule.test
23 | ? rule.test.toString().indexOf('css') === -1 && rule.test.toString().indexOf('svg') === -1
24 | : true;
25 | }),
26 | ...custom.module.rules,
27 | ] },
28 | resolve: { ...config.resolve,
29 | alias: {
30 | ...config.resolve.alias,
31 | ...custom.resolve.alias,
32 | },
33 | fallback: {
34 | ...config.resolve.fallback,
35 | ...custom.resolve.fallback,
36 | },
37 | },
38 | plugins: [...config.plugins, ...custom.plugins],
39 | };
40 |
41 | return finalConfig;
42 | },
43 | };
44 |
45 | export default config;
46 |
--------------------------------------------------------------------------------
/storybookDatatypes/webpack.config.js:
--------------------------------------------------------------------------------
1 | const config = require('../webpack.config.js');
2 |
3 | module.exports = config;
4 |
--------------------------------------------------------------------------------
/test/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "mocha": true,
4 | "node": true
5 | },
6 | "globals": {
7 | "assert": false,
8 | "expect": false,
9 | "sinon": false
10 | },
11 | "rules": {
12 | "comma-dangle": ["error", "only-multiline"],
13 | "no-multiple-empty-lines": 0,
14 | "no-mixed-operators": 0,
15 | "no-redeclare": 0,
16 | "function-call-argument-newline": 0,
17 | "max-len": 0,
18 | "max-classes-per-file": 0,
19 | "no-unused-vars": 0,
20 | "no-import-assign": 0,
21 | "function-paren-newline": 0,
22 | "import/first": 0,
23 | "import/no-useless-path-segments": 0,
24 | "indent": 0,
25 | "lodash/prefer-lodash-method": ["error", {
26 | "ignoreMethods": ["find", "split", "trim", "replace"]
27 | }],
28 | "no-prototype-builtins": 0,
29 | "no-unused-expressions": 0,
30 | "no-useless-escape": 0,
31 | "object-property-newline": 0,
32 | "operator-assignment": 0,
33 | "react/jsx-curly-brace-presence": 0,
34 | "react/jsx-props-no-spreading": 0,
35 | "react/function-component-definition": 0,
36 | "space-unary-ops": 0
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/test/components/common/stat/BgBarLabel.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import _ from 'lodash';
3 | import { mount } from 'enzyme';
4 |
5 | import BgBarLabel from '../../../../src/components/common/stat/BgBarLabel';
6 |
7 | describe('BgBarLabel', () => {
8 | let wrapper;
9 |
10 | const defaultProps = {
11 | barWidth: 4,
12 | domain: {
13 | x: [0, 1],
14 | y: [0, 1],
15 | },
16 | scale: {
17 | x: val => val,
18 | y: val => val,
19 | },
20 | style: {},
21 | text: () => 'text!',
22 | width: 80,
23 | };
24 |
25 | const props = overrides => _.assign({}, defaultProps, overrides);
26 |
27 | beforeEach(() => {
28 | wrapper = mount();
29 | });
30 |
31 | it('should render the text prop', () => {
32 | expect(wrapper.find('VictoryLabel')).to.have.length(1);
33 | expect(wrapper.find('VictoryLabel').text()).to.equal('text!');
34 | });
35 |
36 | it('should render the text element with the styles provided in the style prop', () => {
37 | wrapper.setProps(props({ style: { fill: 'mauve', fontSize: '40px' } }));
38 | expect(wrapper.find('VictoryLabel').props().style.fill).to.equal('mauve');
39 | expect(wrapper.find('VictoryLabel').props().style.fontSize).to.equal('40px');
40 | });
41 | });
42 |
--------------------------------------------------------------------------------
/test/components/common/stat/HoverBarLabel.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { mount } from 'enzyme';
3 | import _ from 'lodash';
4 |
5 | import HoverBarLabel from '../../../../src/components/common/stat/HoverBarLabel';
6 |
7 | describe('HoverBarLabel', () => {
8 | let wrapper;
9 |
10 | const defaultProps = {
11 | barWidth: 30,
12 | isDisabled: () => false,
13 | domain: {
14 | x: [0, 1],
15 | y: [0, 1],
16 | },
17 | style: {},
18 | scale: {
19 | x: val => val,
20 | y: val => val,
21 | },
22 | text: () => ['text!', 'suffix!'],
23 | tooltipText: () => 'tooltip!',
24 | };
25 |
26 | const props = overrides => _.assign({}, defaultProps, overrides);
27 |
28 | beforeEach(() => {
29 | wrapper = mount();
30 | });
31 |
32 | it('should render the a text prop for the value and suffix text', () => {
33 | expect(wrapper.find('VictoryLabel')).to.have.length(2);
34 | expect(wrapper.find('VictoryLabel').at(0).text()).to.equal('text!');
35 | expect(wrapper.find('VictoryLabel').at(1).text()).to.equal('suffix!');
36 | });
37 |
38 | it('should render the text element with the styles provided in the style prop', () => {
39 | wrapper.setProps(props({ style: { fill: 'mauve', fontSize: '40px' } }));
40 | expect(wrapper.find('VictoryLabel').at(0).props().style.fill).to.equal('mauve');
41 | expect(wrapper.find('VictoryLabel').at(0).props().style.fontSize).to.equal('40px');
42 | });
43 |
44 | it('should render the tooltip text', () => {
45 | expect(wrapper.find('VictoryTooltip')).to.have.length(1);
46 | expect(wrapper.find('VictoryTooltip').props().text()).to.equal('tooltip!');
47 | });
48 |
49 | it('should render the text element with the styles provided in the style prop', () => {
50 | wrapper.setProps(props({ style: { fill: 'mauve', fontSize: '40px' } }));
51 | expect(wrapper.find('VictoryTooltip').props().style.fill).to.equal('mauve');
52 | });
53 |
54 | it('should enforce the tooltip fontsize to the minimum of half the bar width or 12', () => {
55 | wrapper.setProps(props({ barWidth: 30 }));
56 | expect(wrapper.find('VictoryTooltip').props().style.fontSize).to.equal(12);
57 |
58 | wrapper.setProps(props({ barWidth: 20 }));
59 | expect(wrapper.find('VictoryTooltip').props().style.fontSize).to.equal(10);
60 | });
61 | });
62 |
--------------------------------------------------------------------------------
/test/components/common/stat/StatLegend.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { shallow } from 'enzyme';
3 |
4 | import { formatClassesAsSelector } from '../../../helpers/cssmodules';
5 | import StatLegend from '../../../../src/components/common/stat/StatLegend';
6 | import styles from '../../../../src/components/common/stat/StatLegend.css';
7 | import colors from '../../../../src/styles/colors.css';
8 |
9 | describe('StatLegend', () => {
10 | let wrapper;
11 |
12 | const defaultProps = {
13 | items: [
14 | {
15 | id: 'basal',
16 | legendTitle: 'Basal',
17 | },
18 | {
19 | id: 'bolus',
20 | legendTitle: 'Bolus',
21 | },
22 | ],
23 | };
24 |
25 | beforeEach(() => {
26 | wrapper = shallow();
27 | });
28 |
29 | it('should render legend item titles', () => {
30 | const items = wrapper.find(formatClassesAsSelector(styles.StatLegendItem));
31 | expect(items).to.have.length(2);
32 | expect(items.at(0).text()).to.equal('Basal');
33 | expect(items.at(1).text()).to.equal('Bolus');
34 | });
35 |
36 | it('should render legend item borders in proper color based on id', () => {
37 | const items = wrapper.find(formatClassesAsSelector(styles.StatLegendItem));
38 | expect(items.at(0).props().style.borderBottomColor).to.equal(colors.basal);
39 | expect(items.at(1).props().style.borderBottomColor).to.equal(colors.bolus);
40 | });
41 | });
42 |
--------------------------------------------------------------------------------
/test/components/common/tooltip/StatTooltip.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { mount } from 'enzyme';
3 | import _ from 'lodash';
4 |
5 | import { formatClassesAsSelector } from '../../../helpers/cssmodules';
6 | import StatTooltip from '../../../../src/components/common/tooltips/StatTooltip';
7 | import styles from '../../../../src/components/common/tooltips/StatTooltip.css';
8 |
9 | describe('StatTooltip', () => {
10 | let wrapper;
11 |
12 | const defaultProps = {
13 | position: {
14 | top: 0,
15 | left: 0,
16 | },
17 | annotations: [
18 | 'message 1',
19 | 'message 2',
20 | ],
21 | };
22 |
23 | beforeEach(() => {
24 | wrapper = mount();
25 | });
26 |
27 | it('should render a tooltip', () => {
28 | expect(wrapper.find('Tooltip')).to.have.length(1);
29 | });
30 |
31 | it('should render text messages', () => {
32 | const messages = wrapper.find(formatClassesAsSelector(styles.message)).hostNodes();
33 | expect(messages).to.have.length(2);
34 | expect(messages.at(0).text()).to.equal('message 1');
35 | expect(messages.at(1).text()).to.equal('message 2');
36 | });
37 |
38 | it('should render markdown messages', () => {
39 | wrapper.setProps(_.assign({}, defaultProps, {
40 | annotations: [
41 | 'Some _italic_ text',
42 | 'Some **bold** text',
43 | 'a [link](http://www.example.com)',
44 | ],
45 | }));
46 | const messages = wrapper.find(formatClassesAsSelector(styles.message)).hostNodes();
47 | expect(messages.at(0).html()).to.include('italic');
48 | expect(messages.at(1).html()).to.include('bold');
49 | expect(messages.at(2).html()).to.include('link');
50 | });
51 |
52 | it('should render a divider between messages', () => {
53 | const dividers = () => wrapper.find(formatClassesAsSelector(styles.divider));
54 | expect(dividers()).to.have.length(1);
55 | wrapper.setProps(_.assign({}, defaultProps, {
56 | annotations: [
57 | 'message 1',
58 | 'message 2',
59 | 'message 3',
60 | 'message 4',
61 | ],
62 | }));
63 | expect(dividers()).to.have.length(3);
64 | });
65 | });
66 |
--------------------------------------------------------------------------------
/test/components/settings/common/Header.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 | import { shallow } from 'enzyme';
20 |
21 | import Header from '../../../../src/components/settings/common/Header';
22 |
23 | describe('Header', () => {
24 | it('should render the device upload date', () => {
25 | const wrapper = shallow(
26 |
31 | );
32 | expect(wrapper.find('span').text()).to.equal('Active at Upload on Jul 12th 2016');
33 | });
34 | });
35 |
--------------------------------------------------------------------------------
/test/components/settings/common/SingleLineCollapsibleContainerLabel.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 | import { shallow } from 'enzyme';
20 |
21 | import SingleLineCollapsibleContainerLabel
22 | from '../../../../src/components/settings/common/SingleLineCollapsibleContainerLabel';
23 |
24 | describe('SingleLineCollapsibleContainerLabel', () => {
25 | it('should render a label with a click handler', () => {
26 | const clicker = sinon.stub();
27 | expect(clicker.callCount).to.equal(0);
28 | const wrapper = shallow(
29 |
34 | );
35 | wrapper.simulate('click');
36 | expect(clicker.callCount).to.equal(1);
37 | });
38 | });
39 |
--------------------------------------------------------------------------------
/test/components/settings/common/TwoLineCollapsibleContainerLabel.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 | import { shallow } from 'enzyme';
20 |
21 | import TwoLineCollapsibleContainerLabel
22 | from '../../../../src/components/settings/common/TwoLineCollapsibleContainerLabel';
23 |
24 | describe('TwoLineCollapsibleContainerLabel', () => {
25 | it('should render a label with a click handler', () => {
26 | const clicker = sinon.stub();
27 | expect(clicker.callCount).to.equal(0);
28 | const wrapper = shallow(
29 |
34 | );
35 | wrapper.simulate('click');
36 | expect(clicker.callCount).to.equal(1);
37 | });
38 | });
39 |
--------------------------------------------------------------------------------
/test/components/trends/cbg/CBGDateTraceLabel.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 | import { mount } from 'enzyme';
20 |
21 | import { formatClassesAsSelector } from '../../../helpers/cssmodules';
22 |
23 | import CBGDateTraceLabel from '../../../../src/components/trends/cbg/CBGDateTraceLabel';
24 | import styles from '../../../../src/components/trends/cbg/CBGDateTraceLabel.css';
25 |
26 | describe('CBGDateTraceLabel', () => {
27 | const props = {
28 | focusedDateTrace: {
29 | data: {
30 | localDate: '2017-01-01',
31 | },
32 | position: {
33 | left: 10,
34 | yPositions: {
35 | top: 100,
36 | topMargin: 50,
37 | },
38 | },
39 | },
40 | };
41 |
42 | describe('with no date trace currently focused', () => {
43 | it('should render nothing', () => {
44 | const wrapper = mount();
45 | expect(wrapper.html()).to.be.null;
46 | });
47 | });
48 |
49 | describe('with a date trace focused', () => {
50 | it('should render a date label', () => {
51 | const wrapper = mount();
52 | const label = wrapper.find(formatClassesAsSelector(styles.dateLabel));
53 | expect(label).to.have.length(1);
54 | expect(label.text()).to.equal('Sunday, January 1');
55 | });
56 | });
57 | });
58 |
--------------------------------------------------------------------------------
/test/components/trends/cbg/CBGDateTracesAnimationContainer.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import _ from 'lodash';
19 | import React from 'react';
20 | import TransitionGroupPlus from 'react-transition-group-plus';
21 | import { shallow } from 'enzyme';
22 |
23 | import bgBounds from '../../../helpers/bgBounds';
24 | import CBGDateTraceAnimated from '../../../../src/components/trends/cbg/CBGDateTraceAnimated';
25 |
26 | import CBGDateTracesAnimationContainer
27 | from '../../../../src/components/trends/cbg/CBGDateTracesAnimationContainer';
28 |
29 | describe('CBGDateTracesAnimationContainer', () => {
30 | const props = {
31 | bgBounds,
32 | data: {
33 | '2016-12-25': [],
34 | '2017-01-01': [],
35 | },
36 | dates: ['2016-12-25', '2017-01-01'],
37 | xScale: sinon.stub(),
38 | yScale: sinon.stub(),
39 | };
40 |
41 | it('should render a TransitionGroupPlus even if there are no dates or data', () => {
42 | const noDataProps = _.assign({}, props, { data: {}, dates: [] });
43 | const wrapper = shallow();
44 | expect(wrapper.find(TransitionGroupPlus)).to.have.length(1);
45 | expect(wrapper.find(CBGDateTraceAnimated)).to.have.length(0);
46 | });
47 |
48 | it('should render a TransitionGroupPlus and a CBGDateTraceAnimated for each date', () => {
49 | const wrapper = shallow();
50 | expect(wrapper.find(TransitionGroupPlus)).to.have.length(1);
51 | expect(wrapper.find(CBGDateTraceAnimated)).to.have.length(2);
52 | });
53 | });
54 |
--------------------------------------------------------------------------------
/test/components/trends/cbg/FocusedCBGSliceSegment.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 | import { shallow } from 'enzyme';
20 |
21 | import FocusedCBGSliceSegment from '../../../../src/components/trends/cbg/FocusedCBGSliceSegment';
22 |
23 | describe('FocusedCBGSliceSegment', () => {
24 | const focusedSlice = {
25 | position: {
26 | left: 10,
27 | yPositions: {
28 | upperQuantile: 90,
29 | thirdQuartile: 75,
30 | },
31 | },
32 | };
33 | const focusedSliceKeys = ['thirdQuartile', 'upperQuantile'];
34 |
35 | it('renders nothing if there\'s no `focusedSlice` in props', () => {
36 | const wrapper = shallow();
37 | expect(wrapper.html()).to.be.null;
38 | });
39 |
40 | it('renders nothing if there\'s no `focusedSliceKeys` in props', () => {
41 | const wrapper = shallow();
42 | expect(wrapper.html()).to.be.null;
43 | });
44 |
45 | it('renders a single rect when `focusedSlice` and `focusedSliceKeys`', () => {
46 | const props = { focusedSlice, focusedSliceKeys };
47 | const wrapper = shallow();
48 | expect(wrapper.find('rect').length).to.equal(1);
49 | });
50 | });
51 |
--------------------------------------------------------------------------------
/test/components/trends/cbg/RangeSelect.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 |
20 | import { mount } from 'enzyme';
21 | import LabeledCheckbox from '../../../../src/components/common/controls/LabeledCheckbox';
22 | import RangeSelect from '../../../../src/components/trends/cbg/RangeSelect';
23 |
24 | describe('RangeSelect', () => {
25 | const props = {
26 | currentPatientInViewId: 'a1b2c3',
27 | displayFlags: {
28 | cbg100Enabled: false,
29 | cbg80Enabled: true,
30 | cbg50Enabled: true,
31 | cbgMedianEnabled: true,
32 | },
33 | updateCbgRange: sinon.spy(),
34 | };
35 |
36 | const wrapper = mount(
37 |
38 | );
39 |
40 | it('should render four LabeledCheckboxes', () => {
41 | expect(wrapper.find(LabeledCheckbox).length).to.equal(4);
42 | expect(wrapper.find('input[type="checkbox"]').length).to.equal(4);
43 | });
44 |
45 | it('clicking on the first checkbox should turn on 100%', () => {
46 | wrapper.find('input[type="checkbox"]').at(0).simulate('change');
47 | expect(props.updateCbgRange.callCount).to.equal(1);
48 | expect(props.updateCbgRange.calledWith('cbg100Enabled', true)).to.be.true;
49 | });
50 |
51 | it('clicking on the second checkbox should turn off 80%', () => {
52 | wrapper.find('input[type="checkbox"]').at(1).simulate('change');
53 | expect(props.updateCbgRange.callCount).to.equal(2);
54 | expect(props.updateCbgRange.calledWith('cbg80Enabled', false)).to.be.true;
55 | });
56 | });
57 |
--------------------------------------------------------------------------------
/test/components/trends/common/XAxisLabels.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 |
20 | import { mount } from 'enzyme';
21 |
22 | import * as scales from '../../../helpers/scales';
23 | const {
24 | trendsHeight,
25 | trendsWidth,
26 | trendsXScale: xScale,
27 | } = scales.trends;
28 | import SVGContainer from '../../../helpers/SVGContainer';
29 |
30 | import { TWENTY_FOUR_HRS } from '../../../../src/utils/datetime';
31 |
32 | import XAxisLabels from '../../../../src/components/trends/common/XAxisLabels';
33 |
34 | describe('XAxisLabels', () => {
35 | let wrapper;
36 | const props = {
37 | margins: {
38 | top: 0,
39 | right: 0,
40 | bottom: 0,
41 | left: 0,
42 | },
43 | xOffset: 0,
44 | xScale,
45 | };
46 |
47 | before(() => {
48 | wrapper = mount(
49 |
50 |
51 |
52 | );
53 | });
54 |
55 | it('should render eight text labels at three hour intervals', () => {
56 | const labels = wrapper.find('text');
57 | expect(labels).to.have.length(8);
58 | // Enzyme forEach cannot be replaced by _.forEach
59 | // eslint-disable-next-line lodash/prefer-lodash-method
60 | labels.forEach((label, i) => {
61 | expect(label.prop('x')).to.equal(xScale(i * (TWENTY_FOUR_HRS / 8)));
62 | });
63 | });
64 | });
65 |
--------------------------------------------------------------------------------
/test/components/trends/common/XAxisTicks.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 |
20 | import { mount } from 'enzyme';
21 |
22 | import * as scales from '../../../helpers/scales';
23 | const {
24 | trendsHeight,
25 | trendsWidth,
26 | trendsXScale: xScale,
27 | } = scales.trends;
28 | import SVGContainer from '../../../helpers/SVGContainer';
29 |
30 | import { TWENTY_FOUR_HRS } from '../../../../src/utils/datetime';
31 |
32 | import XAxisTicks from '../../../../src/components/trends/common/XAxisTicks';
33 |
34 | describe('XAxisTicks', () => {
35 | let wrapper;
36 | const props = {
37 | margins: {
38 | top: 0,
39 | right: 0,
40 | bottom: 0,
41 | left: 0,
42 | },
43 | xOffset: 0,
44 | xScale,
45 | };
46 |
47 | before(() => {
48 | wrapper = mount(
49 |
50 |
51 |
52 | );
53 | });
54 |
55 | it('should render nine tick lines at three hour intervals', () => {
56 | const ticks = wrapper.find('line');
57 | expect(ticks).to.have.length(9);
58 | // Enzyme forEach cannot be replaced by _.forEach
59 | // eslint-disable-next-line lodash/prefer-lodash-method
60 | ticks.forEach((tick, i) => {
61 | expect(tick.prop('x1')).to.equal(xScale(i * (TWENTY_FOUR_HRS / 8)));
62 | expect(tick.prop('x2')).to.equal(xScale(i * (TWENTY_FOUR_HRS / 8)));
63 | });
64 | });
65 | });
66 |
--------------------------------------------------------------------------------
/test/components/trends/common/withDefaultYPosition.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 | import { shallow } from 'enzyme';
20 |
21 | import bgBounds from '../../../helpers/bgBounds';
22 | import DummyComponent from '../../../helpers/DummyComponent';
23 | import * as scales from '../../../helpers/scales';
24 | const {
25 | trendsYScale: yScale,
26 | } = scales.trends;
27 |
28 | import withDefaultYPosition from '../../../../src/components/trends/common/withDefaultYPosition';
29 |
30 | describe('withDefaultYPosition', () => {
31 | const props = {
32 | bgBounds,
33 | yScale,
34 | foo: 'bar',
35 | };
36 | const ToRender = withDefaultYPosition(DummyComponent);
37 | let wrapper;
38 | before(() => {
39 | wrapper = shallow();
40 | });
41 |
42 | it('should render the DummyComponent with an additional defaultY prop', () => {
43 | const dummy = wrapper.find(DummyComponent);
44 | expect(dummy.length).to.equal(1);
45 | const { targetLowerBound, targetUpperBound } = bgBounds;
46 | expect(dummy.prop('defaultY'))
47 | .to.equal(yScale(targetUpperBound - (targetUpperBound - targetLowerBound) / 2));
48 | });
49 |
50 | it('should also pass through all other props', () => {
51 | const dummy = wrapper.find(DummyComponent);
52 | expect(dummy.prop('bgBounds')).to.deep.equal(bgBounds);
53 | expect(dummy.prop('yScale')).to.equal(yScale);
54 | expect(dummy.prop('foo')).to.equal('bar');
55 | });
56 | });
57 |
--------------------------------------------------------------------------------
/test/helpers/DummyComponent.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import React from 'react';
19 |
20 | const DummyComponent = () => ();
21 |
22 | export default DummyComponent;
23 |
--------------------------------------------------------------------------------
/test/helpers/SVGContainer.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import PropTypes from 'prop-types';
19 | import React from 'react';
20 |
21 | const SVGContainer = (props) => {
22 | const { children, dimensions: { width, height } } = props;
23 |
24 | return (
25 |
26 |
29 |
30 | );
31 | };
32 |
33 | SVGContainer.propTypes = {
34 | children: PropTypes.object.isRequired,
35 | dimensions: PropTypes.shape({
36 | width: PropTypes.number.isRequired,
37 | height: PropTypes.number.isRequired,
38 | }).isRequired,
39 | };
40 |
41 | export default SVGContainer;
42 |
--------------------------------------------------------------------------------
/test/helpers/bgBounds.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | export default {
19 | veryHighThreshold: 300,
20 | targetUpperBound: 180,
21 | targetLowerBound: 70,
22 | veryLowThreshold: 55,
23 | };
24 |
--------------------------------------------------------------------------------
/test/helpers/bgConversion.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import { MGDL_PER_MMOLL } from '../../src/utils/constants';
19 |
20 | export const toMmolL = (val) => (val / MGDL_PER_MMOLL);
21 |
--------------------------------------------------------------------------------
/test/helpers/cssmodules.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | export function formatClassesAsSelector(classesStr) {
19 | return `.${classesStr}`.replace(/\s/g, '.');
20 | }
21 |
--------------------------------------------------------------------------------
/test/helpers/scales.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2016, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import { scaleLinear } from 'd3-scale';
19 |
20 | const trendsWidth = 864;
21 | const trendsHeight = 360;
22 |
23 | const trendsXScale = scaleLinear()
24 | .domain([0, 864e5])
25 | .range([0, trendsWidth]);
26 |
27 | const trendsYScale = scaleLinear()
28 | .domain([40, 400])
29 | .range([trendsHeight, 0])
30 | .clamp(true);
31 |
32 | const trends = { trendsWidth, trendsHeight, trendsXScale, trendsYScale };
33 |
34 | const detailWidth = 864;
35 | const detailHeight = 100;
36 |
37 | const detailXScale = scaleLinear()
38 | .domain([0, 864e5])
39 | .range([0, detailWidth]);
40 |
41 | const detailBasalScale = scaleLinear()
42 | .domain([0, 5])
43 | .range([detailHeight, 0]);
44 |
45 | const detailBolusScale = scaleLinear()
46 | .domain([0, 15])
47 | .range([detailHeight, 0]);
48 |
49 | const detail = { detailWidth, detailHeight, detailXScale, detailBasalScale, detailBolusScale };
50 |
51 | export { detail, trends };
52 |
--------------------------------------------------------------------------------
/test/propTypes/index.test.js:
--------------------------------------------------------------------------------
1 | import * as propTypes from '../../src/propTypes';
2 |
3 | describe('common propTypes', () => {
4 | it('should export `bgPrefsPropType` definition', () => {
5 | expect(propTypes.bgPrefsPropType).to.be.a('function');
6 | });
7 | });
8 |
--------------------------------------------------------------------------------
/test/styles/colors.test.js:
--------------------------------------------------------------------------------
1 | import colors from '../../src/styles/colors.css';
2 | import _ from 'lodash';
3 |
4 | describe('colors', () => {
5 | it('should export all required colors', () => {
6 | expect(_.toLower(colors.bolus)).to.equal('#7cd0f0');
7 | expect(_.toLower(colors.bolusAutomated)).to.equal('#00b2c3');
8 | expect(_.toLower(colors.basal)).to.equal('#19a0d7');
9 | expect(_.toLower(colors.basalAutomated)).to.equal('#00b2c3');
10 | expect(_.toLower(colors.sleep)).to.equal('#4457d9');
11 | expect(_.toLower(colors.physicalActivity)).to.equal('#758cff');
12 | expect(_.toLower(colors.preprandial)).to.equal('#4457d9');
13 | expect(_.toLower(colors.statDark)).to.equal('#27385b');
14 | expect(_.toLower(colors.statDefault)).to.equal('#727375');
15 | expect(_.toLower(colors.statDisabled)).to.equal('#e7e9ee');
16 | expect(_.toLower(colors.veryLow)).to.equal('#fb5951');
17 | expect(_.toLower(colors.low)).to.equal('#ff8b7c');
18 | expect(_.toLower(colors.target)).to.equal('#76d3a6');
19 | expect(_.toLower(colors.high)).to.equal('#bb9ae7');
20 | expect(_.toLower(colors.veryHigh)).to.equal('#8c65d6');
21 | expect(_.toLower(colors.insulin)).to.equal('#0096d1');
22 | expect(_.toLower(colors.white)).to.equal('#ffffff');
23 | expect(_.toLower(colors.axis)).to.equal('#e7e9ee');
24 | expect(_.toLower(colors.muted)).to.equal('#c1c9d6');
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/test/utils/misc.test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * == BSD2 LICENSE ==
3 | * Copyright (c) 2017, Tidepool Project
4 | *
5 | * This program is free software; you can redistribute it and/or modify it under
6 | * the terms of the associated License, which is identical to the BSD 2-Clause
7 | * License as published by the Open Source Initiative at opensource.org.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the License for more details.
12 | *
13 | * You should have received a copy of the License along with this program; if
14 | * not, you can obtain one from Tidepool Project at tidepool.org.
15 | * == BSD2 LICENSE ==
16 | */
17 |
18 | import * as patients from '../../data/patient/profiles';
19 | import * as misc from '../../src/utils/misc';
20 |
21 | describe('misc utility functions', () => {
22 | describe('getPatientFullName', () => {
23 | const {
24 | standard,
25 | fakeChildAcct,
26 | } = patients;
27 |
28 | it('should be a function', () => {
29 | assert.isFunction(misc.getPatientFullName);
30 | });
31 |
32 | it('returns patient name', () => {
33 | expect(misc.getPatientFullName(standard)).to.equal(standard.profile.fullName);
34 | });
35 |
36 | it('returns child name when isOtherPerson', () => {
37 | expect(misc.getPatientFullName(fakeChildAcct))
38 | .to.equal(fakeChildAcct.profile.patient.fullName);
39 | });
40 | });
41 | });
42 |
--------------------------------------------------------------------------------
/test/utils/print/plotly.test.js:
--------------------------------------------------------------------------------
1 | import * as plotlyUtils from '../../../src/utils/print/plotly';
2 | import { createAGPData } from '../../../data/print/fixtures';
3 | import { BGM_DATA_KEY, CGM_DATA_KEY } from '../../../src/utils/constants';
4 |
5 | describe('generateAGPFigureDefinitions', () => {
6 | it('generate agp svg image figures for each section for cbg data', async () => {
7 | const images = await plotlyUtils.generateAGPFigureDefinitions(createAGPData(CGM_DATA_KEY));
8 | expect(images.percentInRanges).to.be.an('object');
9 | expect(images.percentInRanges).to.have.property('data');
10 | expect(images.percentInRanges).to.have.property('layout');
11 | expect(images.ambulatoryGlucoseProfile).to.be.an('object');
12 | expect(images.ambulatoryGlucoseProfile).to.have.property('data');
13 | expect(images.ambulatoryGlucoseProfile).to.have.property('layout');
14 | expect(images.dailyGlucoseProfiles).to.be.an('array').and.have.lengthOf(2);
15 | expect(images.dailyGlucoseProfiles[0]).to.be.an('object');
16 | expect(images.dailyGlucoseProfiles[0]).to.have.property('data');
17 | expect(images.dailyGlucoseProfiles[0]).to.have.property('layout');
18 | expect(images.dailyGlucoseProfiles[1]).to.be.an('object');
19 | expect(images.dailyGlucoseProfiles[1]).to.have.property('data');
20 | expect(images.dailyGlucoseProfiles[1]).to.have.property('layout');
21 | });
22 |
23 | it('generate agp svg image figures for each section for smbg data', async () => {
24 | const images = await plotlyUtils.generateAGPFigureDefinitions(createAGPData(BGM_DATA_KEY));
25 | expect(images.percentInRanges).to.be.an('object');
26 | expect(images.percentInRanges).to.have.property('data');
27 | expect(images.percentInRanges).to.have.property('layout');
28 | expect(images.ambulatoryGlucoseProfile).to.be.an('object');
29 | expect(images.ambulatoryGlucoseProfile).to.have.property('data');
30 | expect(images.ambulatoryGlucoseProfile).to.have.property('layout');
31 | expect(images.dailyGlucoseProfiles).to.be.an('array').and.have.lengthOf(2);
32 | expect(images.dailyGlucoseProfiles[0]).to.be.an('object');
33 | expect(images.dailyGlucoseProfiles[0]).to.have.property('data');
34 | expect(images.dailyGlucoseProfiles[0]).to.have.property('layout');
35 | expect(images.dailyGlucoseProfiles[1]).to.be.an('object');
36 | expect(images.dailyGlucoseProfiles[1]).to.have.property('data');
37 | expect(images.dailyGlucoseProfiles[1]).to.have.property('layout');
38 | });
39 | });
40 |
--------------------------------------------------------------------------------