orc-shared 5.10.2-dev.4 → 5.99.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/dist/components/AppFrame/About.js +13 -13
  2. package/dist/components/AppFrame/Anchor.js +7 -7
  3. package/dist/components/AppFrame/AppFrame.js +3 -3
  4. package/dist/components/AppFrame/Help.js +4 -4
  5. package/dist/components/AppFrame/MenuItem.js +17 -26
  6. package/dist/components/AppFrame/Preferences.js +14 -14
  7. package/dist/components/AppFrame/Sidebar.js +6 -6
  8. package/dist/components/AppFrame/Topbar.js +6 -6
  9. package/dist/components/ApplicationModuleLoader.js +3 -2
  10. package/dist/components/Authenticate.js +29 -22
  11. package/dist/components/DropMenu/Menu.js +9 -9
  12. package/dist/components/ErrorPlaceholder.js +8 -24
  13. package/dist/components/Form/Field.js +4 -4
  14. package/dist/components/Form/Inputs/Button.js +2 -2
  15. package/dist/components/{IconButton.js → Form/Inputs/MultiSelector.js} +33 -31
  16. package/dist/components/Form/Inputs/index.js +1 -1
  17. package/dist/components/InternetExplorerWarningMessage.js +15 -15
  18. package/dist/components/LoadingIcon.js +38 -17
  19. package/dist/components/MaterialUI/DataDisplay/Modal.js +3 -3
  20. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  21. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +4 -4
  22. package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  23. package/dist/components/MaterialUI/DataDisplay/Table.js +2 -1
  24. package/dist/components/MaterialUI/DataDisplay/TableProps.js +3 -1
  25. package/dist/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  26. package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  27. package/dist/components/MaterialUI/Inputs/DatePicker.js +1 -1
  28. package/dist/components/MaterialUI/Inputs/InputBase.js +20 -188
  29. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  30. package/dist/components/MaterialUI/Inputs/Select.js +10 -0
  31. package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
  32. package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
  33. package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
  34. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -1
  35. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +27 -42
  36. package/dist/components/MaterialUI/Surfaces/Paper.js +1 -1
  37. package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +3 -2
  38. package/dist/components/MaterialUI/muiThemes.js +2 -0
  39. package/dist/components/Provision.js +30 -13
  40. package/dist/components/Routing/SegmentPage.js +115 -56
  41. package/dist/components/Scope/ScopeNode.js +62 -57
  42. package/dist/components/Sidepanel.js +59 -23
  43. package/dist/components/Spritesheet.js +35 -17
  44. package/dist/components/Text.js +1 -60
  45. package/dist/components/ToastList.js +95 -64
  46. package/dist/components/Treeview/Branch.js +82 -20
  47. package/dist/components/Treeview/Label.js +108 -31
  48. package/dist/components/Treeview/Leaf.js +56 -12
  49. package/dist/components/Treeview/Node.js +22 -9
  50. package/dist/components/Treeview/index.js +7 -1
  51. package/dist/components/Treeview/settings.js +17 -6
  52. package/dist/utils/index.js +0 -4
  53. package/dist/utils/testUtils.js +1 -12
  54. package/dist/{components/Modal/Background.js → utils/toastHelper.js} +11 -14
  55. package/package.json +2 -2
  56. package/src/components/AppFrame/About.js +13 -13
  57. package/src/components/AppFrame/Anchor.js +7 -7
  58. package/src/components/AppFrame/AppFrame.js +3 -3
  59. package/src/components/AppFrame/Help.js +4 -4
  60. package/src/components/AppFrame/MenuItem.js +15 -23
  61. package/src/components/AppFrame/Preferences.js +14 -14
  62. package/src/components/AppFrame/Sidebar.js +6 -6
  63. package/src/components/AppFrame/Topbar.js +6 -6
  64. package/src/components/ApplicationModuleLoader.js +2 -2
  65. package/src/components/ApplicationModuleLoader.test.js +15 -28
  66. package/src/components/Authenticate.js +21 -23
  67. package/src/components/Authenticate.test.js +19 -27
  68. package/src/components/DropMenu/Menu.js +9 -9
  69. package/src/components/ErrorPlaceholder.js +4 -21
  70. package/src/components/ErrorPlaceholder.test.js +7 -14
  71. package/src/components/Form/Field.js +4 -4
  72. package/src/components/Form/InputField.test.js +2 -1
  73. package/src/components/Form/Inputs/Button.js +2 -2
  74. package/src/components/Form/Inputs/MultiSelector.js +23 -0
  75. package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
  76. package/src/components/Form/Inputs/index.js +1 -1
  77. package/src/components/InternetExplorerWarningMessage.js +15 -15
  78. package/src/components/Loader.test.js +50 -59
  79. package/src/components/LoadingIcon.js +27 -14
  80. package/src/components/LoadingIcon.test.js +11 -15
  81. package/src/components/MaterialUI/DataDisplay/Modal.js +3 -3
  82. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  83. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +3 -3
  84. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +0 -74
  85. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +6 -18
  86. package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  87. package/src/components/MaterialUI/DataDisplay/Table.js +6 -1
  88. package/src/components/MaterialUI/DataDisplay/Table.test.js +21 -1
  89. package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
  90. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +20 -2
  91. package/src/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  92. package/src/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  93. package/src/components/MaterialUI/Inputs/DatePicker.js +1 -1
  94. package/src/components/MaterialUI/Inputs/InputBase.js +31 -214
  95. package/src/components/MaterialUI/Inputs/InputBase.test.js +1 -460
  96. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  97. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +1 -1
  98. package/src/components/MaterialUI/Inputs/Select.js +7 -0
  99. package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
  100. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  101. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  102. package/src/components/MaterialUI/Inputs/Switch.js +1 -1
  103. package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
  104. package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
  105. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -2
  106. package/src/components/MaterialUI/ScopeSelector/TreeItem.js +8 -31
  107. package/src/components/MaterialUI/Surfaces/Paper.js +1 -1
  108. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -1
  109. package/src/components/MaterialUI/muiThemes.js +3 -0
  110. package/src/components/Navigation/Navigation.test.js +0 -5
  111. package/src/components/Navigation/useNavigationState.test.js +79 -222
  112. package/src/components/Provision.js +36 -42
  113. package/src/components/Provision.test.js +10 -26
  114. package/src/components/Routing/SegmentPage.js +68 -52
  115. package/src/components/Routing/SegmentPage.test.js +4 -12
  116. package/src/components/Scope/ScopeNode.js +44 -55
  117. package/src/components/Scope/ScopeNode.test.js +84 -163
  118. package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
  119. package/src/components/Sidepanel.js +38 -32
  120. package/src/components/Sidepanel.test.js +54 -27
  121. package/src/components/Spritesheet.js +23 -21
  122. package/src/components/Spritesheet.test.js +10 -10
  123. package/src/components/Text.js +0 -49
  124. package/src/components/ToastList.js +79 -90
  125. package/src/components/ToastList.test.js +29 -103
  126. package/src/components/Treeview/Branch.js +65 -47
  127. package/src/components/Treeview/Branch.test.js +2 -43
  128. package/src/components/Treeview/Label.js +68 -54
  129. package/src/components/Treeview/Label.test.js +55 -63
  130. package/src/components/Treeview/Leaf.js +41 -22
  131. package/src/components/Treeview/Leaf.test.js +1 -15
  132. package/src/components/Treeview/Node.js +16 -9
  133. package/src/components/Treeview/Node.test.js +269 -200
  134. package/src/components/Treeview/Treeview.test.js +248 -248
  135. package/src/components/Treeview/index.js +6 -0
  136. package/src/components/Treeview/settings.js +10 -6
  137. package/src/utils/index.js +0 -4
  138. package/src/utils/testUtils.js +0 -10
  139. package/src/utils/testUtils.test.js +0 -68
  140. package/src/utils/toastHelper.js +8 -0
  141. package/src/utils/toastHelper.test.js +41 -0
  142. package/dist/components/Button.js +0 -70
  143. package/dist/components/CategoryList.js +0 -197
  144. package/dist/components/Checkbox.js +0 -103
  145. package/dist/components/Icon.js +0 -69
  146. package/dist/components/Input.js +0 -101
  147. package/dist/components/List/DataCell.js +0 -129
  148. package/dist/components/List/HeadCell.js +0 -125
  149. package/dist/components/List/HeadRow.js +0 -73
  150. package/dist/components/List/List.js +0 -274
  151. package/dist/components/List/Row.js +0 -109
  152. package/dist/components/List/enhanceColumnDefs.js +0 -111
  153. package/dist/components/List/index.js +0 -59
  154. package/dist/components/Modal/Dialog.js +0 -75
  155. package/dist/components/Modal/Wrapper.js +0 -69
  156. package/dist/components/Modal/index.js +0 -86
  157. package/dist/components/MultiSelector.js +0 -187
  158. package/dist/components/Navigation/Bar.js +0 -293
  159. package/dist/components/Navigation/Tab.js +0 -182
  160. package/dist/components/Placeholder.js +0 -114
  161. package/dist/components/Scope/Selector.js +0 -123
  162. package/dist/components/Selector.js +0 -185
  163. package/dist/components/Switch.js +0 -128
  164. package/dist/components/Toolbar.js +0 -227
  165. package/dist/components/Tooltip.js +0 -66
  166. package/dist/getTheme.js +0 -158
  167. package/dist/getThemeOverrides.js +0 -93
  168. package/dist/hocs/withAuthentication.js +0 -72
  169. package/dist/utils/styledPropFuncs.js +0 -88
  170. package/src/components/Button.js +0 -90
  171. package/src/components/Button.test.js +0 -49
  172. package/src/components/CategoryList.js +0 -140
  173. package/src/components/CategoryList.test.js +0 -667
  174. package/src/components/Checkbox.js +0 -63
  175. package/src/components/Checkbox.test.js +0 -122
  176. package/src/components/Icon.js +0 -18
  177. package/src/components/IconButton.js +0 -30
  178. package/src/components/IconButton.test.js +0 -61
  179. package/src/components/Input.js +0 -35
  180. package/src/components/Input.test.js +0 -34
  181. package/src/components/List/DataCell.js +0 -77
  182. package/src/components/List/DataCell.test.js +0 -357
  183. package/src/components/List/HeadCell.js +0 -105
  184. package/src/components/List/HeadCell.test.js +0 -331
  185. package/src/components/List/HeadRow.js +0 -21
  186. package/src/components/List/HeadRow.test.js +0 -27
  187. package/src/components/List/List.js +0 -162
  188. package/src/components/List/List.test.js +0 -705
  189. package/src/components/List/Row.js +0 -72
  190. package/src/components/List/Row.test.js +0 -194
  191. package/src/components/List/enhanceColumnDefs.js +0 -54
  192. package/src/components/List/enhanceColumnDefs.test.js +0 -179
  193. package/src/components/List/index.js +0 -6
  194. package/src/components/Modal/Background.js +0 -10
  195. package/src/components/Modal/Dialog.js +0 -27
  196. package/src/components/Modal/Dialog.test.js +0 -20
  197. package/src/components/Modal/Modal.test.js +0 -52
  198. package/src/components/Modal/Wrapper.js +0 -32
  199. package/src/components/Modal/Wrapper.test.js +0 -55
  200. package/src/components/Modal/index.js +0 -22
  201. package/src/components/MultiSelector.js +0 -104
  202. package/src/components/MultiSelector.test.js +0 -348
  203. package/src/components/Navigation/Bar.js +0 -212
  204. package/src/components/Navigation/Bar.test.js +0 -552
  205. package/src/components/Navigation/Tab.js +0 -156
  206. package/src/components/Navigation/Tab.test.js +0 -404
  207. package/src/components/Placeholder.js +0 -61
  208. package/src/components/Placeholder.test.js +0 -106
  209. package/src/components/Scope/Selector.js +0 -70
  210. package/src/components/Scope/Selector.test.js +0 -138
  211. package/src/components/Selector.js +0 -191
  212. package/src/components/Selector.test.js +0 -157
  213. package/src/components/Switch.js +0 -112
  214. package/src/components/Switch.test.js +0 -130
  215. package/src/components/Text.test.js +0 -132
  216. package/src/components/Toolbar.js +0 -178
  217. package/src/components/Toolbar.test.js +0 -478
  218. package/src/components/Tooltip.js +0 -51
  219. package/src/components/Tooltip.test.js +0 -21
  220. package/src/getTheme.js +0 -103
  221. package/src/getTheme.test.js +0 -92
  222. package/src/getThemeOverrides.js +0 -27
  223. package/src/hocs/withAuthentication.js +0 -18
  224. package/src/hocs/withAuthentication.test.js +0 -120
  225. package/src/utils/styledPropFuncs.js +0 -20
  226. package/src/utils/styledPropFuncs.test.js +0 -166
@@ -1,12 +1,10 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
- import transition from "styled-transition-group";
4
- import { TransitionGroup } from "react-transition-group";
5
2
  import ReactDOM from "react-dom";
6
- import { shade } from "polished";
7
- import { getThemeProp } from "../utils";
8
- import Text from "./Text";
9
- import Icon from "./Icon";
3
+ import { FormattedMessage } from "react-intl";
4
+ import { makeStyles } from "@material-ui/core/styles";
5
+ import Icon from "./MaterialUI/DataDisplay/Icon";
6
+ import { getToastColor } from "../utils/toastHelper";
7
+ import { CSSTransition, TransitionGroup } from "react-transition-group";
10
8
 
11
9
  const portal = document.getElementById("toast") || document.createElement("div");
12
10
  /* istanbul ignore else */
@@ -15,100 +13,91 @@ if (!portal.parent) {
15
13
  document.body.appendChild(portal);
16
14
  }
17
15
 
18
- const toastTransitionTime = 300;
16
+ const useStyles = makeStyles(theme => ({
17
+ toastBox: props => {
18
+ const toastColor = getToastColor(theme, props.toastType);
19
19
 
20
- export const ToastBox = transition.div`
21
- display: flex;
22
- width: 390px;
23
- margin-top: 10px;
24
- padding: 17px;
25
- border-radius: 5px;
26
- font-size: 14px;
27
- color: white;
28
- background-color: ${getThemeProp(["colors", "toasts", props => props.type], "#999")};
29
- z-index: 10000;
20
+ return {
21
+ display: "flex",
22
+ width: theme.spacing(39),
23
+ marginTop: theme.spacing(1),
24
+ padding: theme.spacing(1.7),
25
+ borderRadius: theme.spacing(0.5),
26
+ fontSize: theme.spacing(1.4),
27
+ color: "white",
28
+ backgroundColor: toastColor,
29
+ zIndex: 10000,
30
30
 
31
- & > * {
32
- margin-top: auto;
33
- margin-bottom: auto;
34
- }
35
-
36
- &:enter {
37
- transform: translateX(200%);
38
- }
39
- &:enter-active {
40
- transform: translateX(0);
41
- transition: transform ${toastTransitionTime}ms ease-out;
42
- }
43
- &:exit {
44
- transform-origin: top;
45
- transform: scale(1,1);
46
- }
47
- &:exit ~ & {
48
- transform: translateY(0);
49
- }
50
- &:exit-active {
51
- transform: scale(1, 0.001);
52
- transition: transform ${toastTransitionTime}ms ease-out;
53
- }
54
- &:exit-active ~ & {
55
- transition: transform ${toastTransitionTime}ms ease-out;
56
- transform: translateY(-100%);
57
- }
58
- `;
59
- ToastBox.defaultProps = {
60
- timeout: toastTransitionTime,
61
- unmountOnExit: true,
62
- };
63
-
64
- export const ToastIcon = styled(Icon).attrs(props => ({
65
- id: getThemeProp(["icons", "toast", props => props.type], "bubble-chat-2")(props),
66
- }))`
67
- font-size: 20px;
68
- margin-right: 16px;
69
- stroke-width: 2px;
70
- `;
31
+ "& > *": {
32
+ marginTop: "auto",
33
+ marginBottom: "auto",
34
+ },
71
35
 
72
- export const CloseIcon = styled(Icon).attrs(props => ({
73
- id: getThemeProp(["icons", "close"], "close")(props),
74
- }))`
75
- position: absolute;
76
- top: 8px;
77
- right: 8px;
78
- font-size: 10px;
79
- padding: 2px;
80
- border-radius: 2px;
81
- stroke-width: 2px;
36
+ "&.enter": {
37
+ transform: "translateX(200%)",
38
+ },
39
+ "&.enter-active": {
40
+ transform: "translateX(0)",
41
+ transition: "transform 300ms ease-out",
42
+ },
43
+ "&.exit": {
44
+ transformOrigin: "top",
45
+ transform: "scale(1,1)",
46
+ },
47
+ "&.exit ~ &": {
48
+ transform: "translateY(0)",
49
+ },
50
+ "&.exit-active": {
51
+ transform: "scale(1, 0.001)",
52
+ transition: "transform 300ms ease-out",
53
+ },
54
+ "&.exit-active ~ &": {
55
+ transition: "transform 300ms ease-out",
56
+ transform: "translateY(-100%)",
57
+ },
58
+ };
59
+ },
60
+ listWrapper: {
61
+ position: "absolute",
62
+ top: theme.spacing(4),
63
+ right: theme.spacing(1.6),
64
+ display: "flex",
65
+ flexDirection: "column",
66
+ },
67
+ closeIcon: {
68
+ padding: theme.spacing(0.2),
69
+ borderRadius: theme.spacing(0.2),
70
+ strokeWidth: theme.spacing(0.2),
71
+ cursor: "pointer",
72
+ marginLeft: "auto",
73
+ fontSize: theme.spacing(2),
74
+ },
75
+ }));
82
76
 
83
- &:hover {
84
- background-color: ${getThemeProp(["colors", "toasts", props => props.type], "#999999", color => shade(0.3, color))};
85
- }
86
- `;
77
+ export const Toast = ({ message = "[No message]", type = "", closeFunc, ...props }) => {
78
+ const classes = useStyles({ toastType: type });
87
79
 
88
- export const Toast = ({ message = "[No message]", type = "", closeFunc, ...props }) => (
89
- <ToastBox type={type} in={props.in}>
90
- <ToastIcon type={type} />
91
- <Text message={message} />
92
- {closeFunc ? <CloseIcon onClick={closeFunc} type={type} /> : null}
93
- </ToastBox>
94
- );
80
+ return (
81
+ <CSSTransition in={props.in} timeout={300} unmountOnExit>
82
+ <div className={classes.toastBox}>
83
+ <span>{typeof message === "string" ? message : <FormattedMessage {...message} />}</span>
84
+ {closeFunc ? <Icon id="close" className={classes.closeIcon} onClick={closeFunc} /> : null}
85
+ </div>
86
+ </CSSTransition>
87
+ );
88
+ };
95
89
 
96
- const ListWrapper = styled(TransitionGroup)`
97
- position: absolute;
98
- top: 40px;
99
- right: 16px;
100
- display: flex;
101
- flex-direction: column;
102
- `;
90
+ export const ToastList = ({ toasts }) => {
91
+ const classes = useStyles();
103
92
 
104
- export const ToastList = ({ toasts }) =>
105
- ReactDOM.createPortal(
106
- <ListWrapper>
93
+ return ReactDOM.createPortal(
94
+ <TransitionGroup className={classes.listWrapper}>
107
95
  {toasts.map((props, idx) => (
108
96
  <Toast key={"toast" + idx} {...props} />
109
97
  ))}
110
- </ListWrapper>,
98
+ </TransitionGroup>,
111
99
  portal,
112
100
  );
101
+ };
113
102
 
114
103
  export default ToastList;
@@ -3,10 +3,9 @@ import ReactDOM from "react-dom";
3
3
  import { Provider } from "react-redux";
4
4
  import { IntlProvider } from "react-intl";
5
5
  import { Ignore } from "unexpected-reaction";
6
- import { ThemeProvider } from "styled-components";
7
- import { shade } from "polished";
8
- import Icon from "./Icon";
9
- import FullToastList, { Toast, ToastBox, ToastIcon, CloseIcon } from "./ToastList";
6
+ import Icon from "./MaterialUI/DataDisplay/Icon";
7
+ import FullToastList, { Toast } from "./ToastList";
8
+ import { CSSTransition } from "react-transition-group";
10
9
 
11
10
  class RenderToast extends React.Component {
12
11
  render() {
@@ -47,10 +46,11 @@ describe("ToastList", () => {
47
46
  return expect(
48
47
  toastRoot,
49
48
  "to contain",
50
- <ToastBox in>
51
- <Ignore />
52
- [No message]
53
- </ToastBox>,
49
+ <CSSTransition in>
50
+ <div>
51
+ <span>[No message]</span>
52
+ </div>
53
+ </CSSTransition>,
54
54
  );
55
55
  });
56
56
  });
@@ -70,10 +70,11 @@ describe("Toast", () => {
70
70
  </Provider>,
71
71
  "when mounted",
72
72
  "to satisfy",
73
- <ToastBox in>
74
- <Ignore />
75
- this is a toast
76
- </ToastBox>,
73
+ <CSSTransition in>
74
+ <div>
75
+ <span>this is a toast</span>
76
+ </div>
77
+ </CSSTransition>,
77
78
  ));
78
79
 
79
80
  it("shows a translated message", () =>
@@ -91,10 +92,11 @@ describe("Toast", () => {
91
92
  </Provider>,
92
93
  "when mounted",
93
94
  "to satisfy",
94
- <ToastBox in>
95
- <Ignore />
96
- This is a toast
97
- </ToastBox>,
95
+ <CSSTransition in>
96
+ <div>
97
+ <span>This is a toast</span>
98
+ </div>
99
+ </CSSTransition>,
98
100
  ));
99
101
 
100
102
  it("shows an icon", () =>
@@ -110,10 +112,11 @@ describe("Toast", () => {
110
112
  </Provider>,
111
113
  "when mounted",
112
114
  "to satisfy",
113
- <ToastBox in>
114
- <ToastIcon type="confirm" />
115
- <Ignore />
116
- </ToastBox>,
115
+ <CSSTransition in>
116
+ <div>
117
+ <Ignore />
118
+ </div>
119
+ </CSSTransition>,
117
120
  ));
118
121
 
119
122
  it("shows a close icon if a close function is given", () =>
@@ -129,88 +132,11 @@ describe("Toast", () => {
129
132
  </Provider>,
130
133
  "when mounted",
131
134
  "to satisfy",
132
- <ToastBox in>
133
- <Ignore />
134
- <Ignore />
135
- <CloseIcon onClick={expect.it("to be a function")} />
136
- </ToastBox>,
135
+ <CSSTransition in>
136
+ <div>
137
+ <Ignore />
138
+ <Icon id="close" onClick={expect.it("to be a function")} />
139
+ </div>
140
+ </CSSTransition>,
137
141
  ));
138
-
139
- describe("with types", () => {
140
- let theme;
141
- beforeEach(() => {
142
- theme = {
143
- colors: {
144
- toasts: {
145
- test: "#ff0000",
146
- },
147
- },
148
- icons: {
149
- toast: {
150
- test: "test-icon",
151
- },
152
- },
153
- };
154
- });
155
-
156
- it("renders a default type", () =>
157
- expect(
158
- <Provider
159
- store={{
160
- subscribe: () => {},
161
- dispatch: () => {},
162
- getState: () => ({}),
163
- }}
164
- >
165
- <ThemeProvider theme={theme}>
166
- <Toast in />
167
- </ThemeProvider>
168
- </Provider>,
169
- "when mounted",
170
- "to have style rules satisfying",
171
- "to contain",
172
- "background-color: #999;",
173
- ).and("when mounted", "to contain", <Icon id="bubble-chat-2" />));
174
-
175
- it("renders a set type", () =>
176
- expect(
177
- <Provider
178
- store={{
179
- subscribe: () => {},
180
- dispatch: () => {},
181
- getState: () => ({}),
182
- }}
183
- >
184
- <ThemeProvider theme={theme}>
185
- <Toast in type="test" />
186
- </ThemeProvider>
187
- </Provider>,
188
- "when mounted",
189
- "to have style rules satisfying",
190
- "to contain",
191
- "background-color: #ff0000;",
192
- ).and("when mounted", "to contain", <Icon id="test-icon" />));
193
-
194
- it("darkens close icon background on hover", () =>
195
- expect(
196
- <ThemeProvider theme={theme}>
197
- <CloseIcon type="" />
198
- </ThemeProvider>,
199
- "when mounted",
200
- "to have style rules satisfying",
201
- "to contain",
202
- ":hover {background-color: " + shade(0.3, "#999") + ";}",
203
- ));
204
-
205
- it("darkens close icon background on hover with set type", () =>
206
- expect(
207
- <ThemeProvider theme={theme}>
208
- <CloseIcon type="test" />
209
- </ThemeProvider>,
210
- "when mounted",
211
- "to have style rules satisfying",
212
- "to contain",
213
- ":hover {background-color: " + shade(0.3, "#ff0000") + ";}",
214
- ));
215
- });
216
142
  });
@@ -1,47 +1,65 @@
1
- import styled, { css } from "styled-components";
2
- import { ifFlag, getThemeProp } from "../../utils";
3
- import { branchIndent, branchLength, branchHeight } from "./settings";
4
-
5
- const baseBranch = css`
6
- margin: 0;
7
- font-size: 13px;
8
- list-style-type: none;
9
- border-width: 0;
10
- border-style: solid;
11
- border-color: #666;
12
- position: relative;
13
- `;
14
-
15
- export const Branch = styled.ul`
16
- ${baseBranch}
17
-
18
- margin-left: ${branchIndent}px;
19
- padding: 0;
20
- padding-left: ${branchLength}px;
21
- border-left-width: 1px;
22
-
23
- &:last-child::after {
24
- /* blocker - hides lowest part of vertical branch */
25
- content: " ";
26
- background-color: ${ifFlag("dark", getThemeProp(["colors", "bgDark"], "#333333"), "#fff")};
27
- position: absolute;
28
- left: -${props => branchIndent(props) + branchLength(props) + 2}px;
29
- bottom: 0;
30
- top: -${branchHeight}px;
31
- width: 1px;
32
- }
33
- `;
34
-
35
- export const Wrapper = styled.ul`
36
- ${baseBranch}
37
-
38
- overflow-y: auto;
39
- overflow-x: hidden;
40
- margin-left: 0;
41
- padding: ${props => branchLength(props) - 5}px;
42
-
43
- & > ${Branch} {
44
- /* First Branch immediately under Wrapper needs margin adjusted to look right */
45
- margin-left: ${props => 1.5 * branchIndent(props)}px;
46
- }
47
- `;
1
+ import React from "react";
2
+ import { makeStyles } from "@material-ui/core/styles";
3
+ import { branchIndentSpacing, branchLengthSpacing, branchHeightSpacing } from "./settings";
4
+ import classNames from "classnames";
5
+
6
+ const useStyles = makeStyles(theme => {
7
+ const base = {
8
+ margin: 0,
9
+ fontSize: theme.spacing(1.3),
10
+ listStyleType: "none",
11
+ borderWidth: 0,
12
+ borderStyle: "solid",
13
+ borderColor: "#666",
14
+ position: "relative",
15
+ };
16
+
17
+ return {
18
+ branch: props => ({
19
+ ...base,
20
+ marginLeft: `${theme.spacing(branchIndentSpacing)}`,
21
+ padding: "0",
22
+ paddingLeft: `${theme.spacing(branchLengthSpacing)}`,
23
+ borderLeftWidth: theme.spacing(0.1),
24
+
25
+ "&:last-child::after": {
26
+ /* blocker - hides lowest part of vertical branch */
27
+ content: '""',
28
+ backgroundColor: props.dark ? theme.palette.grey.dark : "#fff",
29
+ position: "absolute",
30
+ left: `-${theme.spacing(branchIndentSpacing + branchLengthSpacing + 0.2)}`,
31
+ bottom: 0,
32
+ top: `-${theme.spacing(branchHeightSpacing)}`,
33
+ width: theme.spacing(0.1),
34
+ },
35
+ }),
36
+ wrapper: {
37
+ ...base,
38
+ overflowY: "auto",
39
+ overflowX: "hidden",
40
+ marginLeft: 0,
41
+ padding: `${theme.spacing(branchLengthSpacing - 0.5)}`,
42
+
43
+ "& > $branch": {
44
+ /* First Branch immediately under Wrapper needs margin adjusted to look right */
45
+ marginLeft: `${theme.spacing(branchIndentSpacing * 1.5)}`,
46
+ },
47
+ },
48
+ };
49
+ });
50
+
51
+ export const Branch = ({ dark, branchClassName, children }) => {
52
+ const classes = useStyles({ dark });
53
+
54
+ return (
55
+ <ul className={classNames(classes.branch, branchClassName)} data-qa="branch">
56
+ {children}
57
+ </ul>
58
+ );
59
+ };
60
+
61
+ export const Wrapper = ({ children }) => {
62
+ const classes = useStyles();
63
+
64
+ return <ul className={classes.wrapper}>{children}</ul>;
65
+ };
@@ -1,49 +1,8 @@
1
1
  import React from "react";
2
- import { Branch, Wrapper } from "./Branch";
2
+ import { Branch } from "./Branch";
3
3
 
4
4
  describe("Branch", () => {
5
5
  it("renders a <ul>", () => expect(<Branch />, "when mounted", "to satisfy", <ul />));
6
6
 
7
- it("sets styling for showing a branch structure", () =>
8
- expect(
9
- <Branch
10
- theme={{
11
- treeSettings: {
12
- branchIndent: 10,
13
- branchLength: 12,
14
- branchHeight: 14,
15
- },
16
- }}
17
- />,
18
- "when mounted",
19
- "to have style rules satisfying",
20
- expect
21
- .it("to contain", "margin-left: 10px;")
22
- .and("to contain", "padding-left: 12px;")
23
- .and("to match", /:last-child::after {[^}]*left: -24px;[^}]*}/)
24
- .and("to match", /:last-child::after {[^}]*top: -14px;[^}]*}/),
25
- ));
26
- });
27
-
28
- describe("Wrapper", () => {
29
- it("renders a <ul>", () => expect(<Wrapper />, "when mounted", "to satisfy", <ul />));
30
-
31
- it("sets styling for showing the root of a tree structure", () =>
32
- expect(
33
- <Wrapper
34
- theme={{
35
- treeSettings: {
36
- branchIndent: 10,
37
- branchLength: 12,
38
- branchHeight: 14,
39
- },
40
- }}
41
- />,
42
- "when mounted",
43
- "to have style rules satisfying",
44
- expect
45
- .it("to contain", "margin-left: 0;")
46
- .and("to contain", "padding: 7px;")
47
- .and("to contain", "> ." + Branch.styledComponentId + " {margin-left: 15px;}"),
48
- ));
7
+ it("renders a dark <ul>", () => expect(<Branch dark />, "when mounted", "to satisfy", <ul />));
49
8
  });
@@ -1,54 +1,68 @@
1
- import styled, { css } from "styled-components";
2
- import Icon from "../Icon";
3
- import { getThemeProp, ifFlag } from "../../utils";
4
- import { branchLength } from "./settings";
5
-
6
- export const Indicator = styled(Icon).attrs(props => ({
7
- id: ifFlag(
8
- "open",
9
- getThemeProp(["icons", "indicators", "down"], "chevron-down"),
10
- getThemeProp(["icons", "indicators", "right"], "chevron-right"),
11
- )(props),
12
- }))`
13
- font-size: 10px;
14
- padding: 10px 0 10px 10px;
15
- cursor: pointer;
16
- flex: 0 0 auto;
17
- color: ${ifFlag(
18
- "open",
19
- ifFlag("dark", getThemeProp(["colors", "textLight"], "#cccccc"), getThemeProp(["colors", "text"], "#333333")),
20
- getThemeProp(["colors", "application", "base"], "#ffffff"),
21
- )};
22
- `;
23
-
24
- export const BeforeIndicator = styled.div`
25
- background-color: #666;
26
- margin-left: -${props => branchLength(props) + 1}px;
27
- width: ${props => branchLength(props) + 1}px;
28
- height: 1px;
29
- z-index: 99;
30
- position: absolute;
31
- `;
32
-
33
- export const NonIndicator = styled.div`
34
- height: 1px;
35
- width: ${props => branchLength(props) + 21}px;
36
- margin: auto 0 auto -${props => branchLength(props) + 1}px;
37
- background-color: #666;
38
- align-self: stretch;
39
- flex: 0 0 auto;
40
- z-index: 99;
41
- `;
42
-
43
- export const Label = styled.div`
44
- cursor: pointer;
45
- flex-grow: 1;
46
- width: 100%;
47
- ${ifFlag(
48
- "isSelectedNode",
49
- css`
50
- background-color: #222;
51
- border: 1px solid ${getThemeProp(["colors", "application", "base"], "#0F4E66")};
52
- `,
53
- )};
54
- `;
1
+ import React from "react";
2
+ import { makeStyles } from "@material-ui/core/styles";
3
+ import Icon from "../MaterialUI/DataDisplay/Icon";
4
+ import { branchLengthSpacing } from "./settings";
5
+ import classNames from "classnames";
6
+
7
+ const useStyles = makeStyles(theme => ({
8
+ beforeIndicator: {
9
+ backgroundColor: "#666",
10
+ marginLeft: `-${theme.spacing(branchLengthSpacing + 0.1)}`,
11
+ width: `${theme.spacing(branchLengthSpacing + 0.1)}`,
12
+ height: theme.spacing(0.1),
13
+ zIndex: 99,
14
+ position: "absolute",
15
+ },
16
+ nonIndicator: {
17
+ height: theme.spacing(0.1),
18
+ width: `${theme.spacing(branchLengthSpacing + 2.1)}`,
19
+ margin: `auto 0 auto -${theme.spacing(branchLengthSpacing + 0.1)}`,
20
+ backgroundColor: "#666",
21
+ alignSelf: "stretch",
22
+ flex: "0 0 auto",
23
+ zIndex: 99,
24
+ },
25
+ label: props => ({
26
+ cursor: "pointer",
27
+ flexGrow: 1,
28
+ width: "100%",
29
+ backgroundColor: props.isSelectedNode ? "#222" : undefined,
30
+ border: props.isSelectedNode ? `1px solid ${theme.palette.grey.borders}` : undefined,
31
+ }),
32
+ indicator: props => ({
33
+ fontSize: theme.spacing(1),
34
+ padding: theme.spacing(1, 0, 1, 1),
35
+ cursor: "pointer",
36
+ flex: "0 0 auto",
37
+ color: props.open
38
+ ? props.dark
39
+ ? theme.palette.primary.light
40
+ : theme.palette.text.primary
41
+ : theme.palette.primary.main,
42
+ }),
43
+ }));
44
+
45
+ export const BeforeIndicator = ({ children }) => {
46
+ const classes = useStyles();
47
+
48
+ return <div className={classes.beforeIndicator}>{children}</div>;
49
+ };
50
+
51
+ export const NonIndicator = ({ children }) => {
52
+ const classes = useStyles();
53
+
54
+ return <div className={classes.nonIndicator}>{children}</div>;
55
+ };
56
+
57
+ export const Label = ({ isSelectedNode, labelClassName, children }) => {
58
+ const classes = useStyles({ isSelectedNode });
59
+
60
+ return <div className={classNames(classes.label, labelClassName)}>{children}</div>;
61
+ };
62
+
63
+ export const Indicator = ({ open, dark, onClick }) => {
64
+ const classes = useStyles({ open, dark });
65
+ const iconId = open ? "dropdown-chevron-down" : "dropdown-chevron-right";
66
+
67
+ return <Icon id={iconId} className={classes.indicator} onClick={onClick} data-qa="indicator" />;
68
+ };