orc-shared 5.10.1-dev.8 → 5.10.1-dev.9

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 (133) hide show
  1. package/dist/components/Authenticate.js +41 -17
  2. package/dist/components/ErrorPlaceholder.js +8 -24
  3. package/dist/components/{Icon.js → Form/Inputs/MultiSelector.js} +33 -20
  4. package/dist/components/Form/Inputs/index.js +1 -1
  5. package/dist/components/LoadingIcon.js +6 -16
  6. package/dist/components/MaterialUI/Inputs/Select.js +10 -0
  7. package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
  8. package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
  9. package/dist/components/Provision.js +30 -13
  10. package/dist/components/Routing/SegmentPage.js +115 -56
  11. package/dist/components/Scope/ScopeNode.js +68 -45
  12. package/dist/components/Sidepanel.js +57 -23
  13. package/dist/components/Spritesheet.js +33 -17
  14. package/dist/components/Text.js +1 -60
  15. package/dist/components/Treeview/Branch.js +82 -20
  16. package/dist/components/Treeview/Label.js +108 -31
  17. package/dist/components/Treeview/Leaf.js +56 -12
  18. package/dist/components/Treeview/Node.js +22 -9
  19. package/dist/components/Treeview/index.js +7 -1
  20. package/dist/components/Treeview/settings.js +7 -5
  21. package/dist/utils/index.js +0 -4
  22. package/dist/utils/testUtils.js +1 -12
  23. package/package.json +1 -1
  24. package/src/components/ApplicationModuleLoader.test.js +14 -27
  25. package/src/components/Authenticate.js +29 -21
  26. package/src/components/Authenticate.test.js +18 -27
  27. package/src/components/ErrorPlaceholder.js +4 -21
  28. package/src/components/ErrorPlaceholder.test.js +7 -14
  29. package/src/components/Form/InputField.test.js +2 -1
  30. package/src/components/Form/Inputs/MultiSelector.js +23 -0
  31. package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
  32. package/src/components/Form/Inputs/index.js +1 -1
  33. package/src/components/Loader.test.js +21 -33
  34. package/src/components/LoadingIcon.js +2 -15
  35. package/src/components/LoadingIcon.test.js +2 -20
  36. package/src/components/MaterialUI/DataDisplay/Table.test.js +1 -1
  37. package/src/components/MaterialUI/Inputs/Select.js +7 -0
  38. package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
  39. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  40. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  41. package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
  42. package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
  43. package/src/components/Navigation/Navigation.test.js +0 -5
  44. package/src/components/Navigation/useNavigationState.test.js +79 -222
  45. package/src/components/Provision.js +36 -42
  46. package/src/components/Provision.test.js +10 -26
  47. package/src/components/Routing/SegmentPage.js +68 -52
  48. package/src/components/Routing/SegmentPage.test.js +4 -12
  49. package/src/components/Scope/ScopeNode.js +61 -54
  50. package/src/components/Scope/ScopeNode.test.js +61 -154
  51. package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
  52. package/src/components/Sidepanel.js +38 -32
  53. package/src/components/Sidepanel.test.js +49 -27
  54. package/src/components/Spritesheet.js +23 -21
  55. package/src/components/Spritesheet.test.js +10 -10
  56. package/src/components/Text.js +0 -49
  57. package/src/components/Treeview/Branch.js +63 -45
  58. package/src/components/Treeview/Branch.test.js +21 -24
  59. package/src/components/Treeview/Label.js +66 -52
  60. package/src/components/Treeview/Label.test.js +42 -60
  61. package/src/components/Treeview/Leaf.js +41 -22
  62. package/src/components/Treeview/Leaf.test.js +15 -10
  63. package/src/components/Treeview/Node.js +16 -9
  64. package/src/components/Treeview/Node.test.js +269 -200
  65. package/src/components/Treeview/Treeview.test.js +248 -248
  66. package/src/components/Treeview/index.js +6 -0
  67. package/src/components/Treeview/settings.js +7 -6
  68. package/src/utils/index.js +0 -4
  69. package/src/utils/testUtils.js +0 -10
  70. package/src/utils/testUtils.test.js +0 -68
  71. package/dist/components/Button.js +0 -70
  72. package/dist/components/Checkbox.js +0 -103
  73. package/dist/components/IconButton.js +0 -80
  74. package/dist/components/Input.js +0 -101
  75. package/dist/components/Modal/Background.js +0 -55
  76. package/dist/components/Modal/Dialog.js +0 -75
  77. package/dist/components/Modal/Wrapper.js +0 -69
  78. package/dist/components/Modal/index.js +0 -86
  79. package/dist/components/MultiSelector.js +0 -187
  80. package/dist/components/Navigation/Bar.js +0 -293
  81. package/dist/components/Navigation/Tab.js +0 -182
  82. package/dist/components/Placeholder.js +0 -114
  83. package/dist/components/Scope/Selector.js +0 -123
  84. package/dist/components/Selector.js +0 -185
  85. package/dist/components/Switch.js +0 -128
  86. package/dist/components/Toolbar.js +0 -227
  87. package/dist/components/Tooltip.js +0 -66
  88. package/dist/getTheme.js +0 -153
  89. package/dist/getThemeOverrides.js +0 -93
  90. package/dist/hocs/withAuthentication.js +0 -72
  91. package/dist/utils/styledPropFuncs.js +0 -88
  92. package/src/components/Button.js +0 -90
  93. package/src/components/Button.test.js +0 -49
  94. package/src/components/Checkbox.js +0 -63
  95. package/src/components/Checkbox.test.js +0 -122
  96. package/src/components/Icon.js +0 -18
  97. package/src/components/IconButton.js +0 -30
  98. package/src/components/IconButton.test.js +0 -61
  99. package/src/components/Input.js +0 -35
  100. package/src/components/Input.test.js +0 -34
  101. package/src/components/Modal/Background.js +0 -10
  102. package/src/components/Modal/Dialog.js +0 -27
  103. package/src/components/Modal/Dialog.test.js +0 -20
  104. package/src/components/Modal/Modal.test.js +0 -52
  105. package/src/components/Modal/Wrapper.js +0 -32
  106. package/src/components/Modal/Wrapper.test.js +0 -55
  107. package/src/components/Modal/index.js +0 -22
  108. package/src/components/MultiSelector.js +0 -104
  109. package/src/components/MultiSelector.test.js +0 -348
  110. package/src/components/Navigation/Bar.js +0 -212
  111. package/src/components/Navigation/Bar.test.js +0 -552
  112. package/src/components/Navigation/Tab.js +0 -156
  113. package/src/components/Navigation/Tab.test.js +0 -404
  114. package/src/components/Placeholder.js +0 -61
  115. package/src/components/Placeholder.test.js +0 -106
  116. package/src/components/Scope/Selector.js +0 -70
  117. package/src/components/Scope/Selector.test.js +0 -138
  118. package/src/components/Selector.js +0 -191
  119. package/src/components/Selector.test.js +0 -157
  120. package/src/components/Switch.js +0 -112
  121. package/src/components/Switch.test.js +0 -130
  122. package/src/components/Text.test.js +0 -132
  123. package/src/components/Toolbar.js +0 -178
  124. package/src/components/Toolbar.test.js +0 -478
  125. package/src/components/Tooltip.js +0 -51
  126. package/src/components/Tooltip.test.js +0 -21
  127. package/src/getTheme.js +0 -98
  128. package/src/getTheme.test.js +0 -92
  129. package/src/getThemeOverrides.js +0 -27
  130. package/src/hocs/withAuthentication.js +0 -18
  131. package/src/hocs/withAuthentication.test.js +0 -120
  132. package/src/utils/styledPropFuncs.js +0 -20
  133. package/src/utils/styledPropFuncs.test.js +0 -166
@@ -1,12 +1,13 @@
1
1
  import React from "react";
2
- import { Provider } from "react-redux";
3
- import { MemoryRouter } from "react-router-dom";
4
2
  import Immutable from "immutable";
5
3
  import { mount } from "enzyme";
4
+ import { ScopeIcon } from "../MaterialUI/ScopeSelector/TreeItem";
6
5
  import sinon from "sinon";
7
- import Icon from "../Icon";
8
- import { ScopeIcon, ContentLabel, ScopeNode, ScopeText } from "./ScopeNode";
6
+ import { ScopeNode } from "./ScopeNode";
9
7
  import { TestWrapper } from "../../utils/testUtils";
8
+ import { createMuiTheme } from "../../utils/testUtils";
9
+
10
+ const theme = createMuiTheme();
10
11
 
11
12
  describe("ScopeNode", () => {
12
13
  let closeSelector, store;
@@ -24,103 +25,97 @@ describe("ScopeNode", () => {
24
25
 
25
26
  it("displays an icon and a label for a scope", () =>
26
27
  expect(
27
- <Provider store={store}>
28
- <MemoryRouter>
29
- <ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
30
- </MemoryRouter>
31
- </Provider>,
28
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
29
+ <ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
30
+ </TestWrapper>,
32
31
  "when mounted",
33
32
  "to satisfy",
34
- <ContentLabel id="selectorNodeScopeId" onClick={closeSelector}>
35
- <ScopeIcon type="test" />
36
- <ScopeText>A scope</ScopeText>
37
- </ContentLabel>,
33
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
34
+ <div id="selectorNodeScopeId" onClick={closeSelector}>
35
+ <ScopeIcon type="test" />
36
+ <div>A scope</div>
37
+ </div>
38
+ </TestWrapper>,
38
39
  ));
39
40
 
40
41
  it("displays an icon and a label for the global scope", () =>
41
42
  expect(
42
- <Provider store={store}>
43
- <MemoryRouter>
44
- <ScopeNode name="A scope" type="Global" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
45
- </MemoryRouter>
46
- </Provider>,
43
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
44
+ <ScopeNode name="A scope" type="Global" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
45
+ </TestWrapper>,
47
46
  "when mounted",
48
47
  "to satisfy",
49
- <ContentLabel id="selectorNodeScopeId" onClick={closeSelector} isGlobal={true}>
50
- <ScopeIcon type="Global" />
51
- <ScopeText>A scope</ScopeText>
52
- </ContentLabel>,
48
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
49
+ <div id="selectorNodeScopeId" onClick={closeSelector}>
50
+ <ScopeIcon type="Global" />
51
+ <div>A scope</div>
52
+ </div>
53
+ </TestWrapper>,
53
54
  ));
54
55
 
55
56
  it("displays an icon and a label for an unauthorized scope", () =>
56
57
  expect(
57
- <Provider store={store}>
58
- <MemoryRouter>
59
- <ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} />
60
- </MemoryRouter>
61
- </Provider>,
58
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
59
+ <ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} />
60
+ </TestWrapper>,
62
61
  "when mounted",
63
62
  "to satisfy",
64
- <ContentLabel id="selectorNodeScopeId">
65
- <ScopeIcon type="test" />
66
- <ScopeText>A scope</ScopeText>
67
- </ContentLabel>,
63
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
64
+ <div id="selectorNodeScopeId">
65
+ <ScopeIcon type="test" />
66
+ <div>A scope</div>
67
+ </div>
68
+ </TestWrapper>,
68
69
  ));
69
70
 
70
71
  it("displays an icon and a the fallback id for a scope when name is undefined", () =>
71
72
  expect(
72
- <Provider store={store}>
73
- <MemoryRouter>
74
- <ScopeNode type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
75
- </MemoryRouter>
76
- </Provider>,
73
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
74
+ <ScopeNode type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
75
+ </TestWrapper>,
77
76
  "when mounted",
78
77
  "to satisfy",
79
- <ContentLabel id="selectorNodeScopeId" onClick={closeSelector}>
80
- <ScopeIcon type="test" />
81
- <ScopeText>ScopeId</ScopeText>
82
- </ContentLabel>,
78
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
79
+ <div id="selectorNodeScopeId" onClick={closeSelector}>
80
+ <ScopeIcon type="test" />
81
+ <div>ScopeId</div>
82
+ </div>
83
+ </TestWrapper>,
83
84
  ));
84
85
 
85
86
  it("displays an icon and a the fallback id for a scope when name is null", () =>
86
87
  expect(
87
- <Provider store={store}>
88
- <MemoryRouter>
89
- <ScopeNode name={null} type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
90
- </MemoryRouter>
91
- </Provider>,
88
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
89
+ <ScopeNode name={null} type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
90
+ </TestWrapper>,
92
91
  "when mounted",
93
92
  "to satisfy",
94
- <ContentLabel id="selectorNodeScopeId" onClick={closeSelector}>
95
- <ScopeIcon type="test" />
96
- <ScopeText>ScopeId</ScopeText>
97
- </ContentLabel>,
93
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
94
+ <div id="selectorNodeScopeId" onClick={closeSelector}>
95
+ <ScopeIcon type="test" />
96
+ <div>ScopeId</div>
97
+ </div>
98
+ </TestWrapper>,
98
99
  ));
99
100
 
100
101
  it("handles virtual scopes", () =>
101
102
  expect(
102
- <Provider store={store}>
103
- <MemoryRouter>
104
- <ScopeNode
105
- name="A scope"
106
- type="Virtual"
107
- id="ScopeId"
108
- isAuthorizedScope={true}
109
- closeSelector={closeSelector}
110
- />
111
- </MemoryRouter>
112
- </Provider>,
103
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
104
+ <ScopeNode name="A scope" type="Virtual" id="ScopeId" isAuthorizedScope={true} closeSelector={closeSelector} />
105
+ </TestWrapper>,
113
106
  "when mounted",
114
107
  "to satisfy",
115
- <ContentLabel id="selectorNodeScopeId">
116
- <ScopeIcon type="Virtual" />
117
- <ScopeText>A scope</ScopeText>
118
- </ContentLabel>,
108
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
109
+ <div id="selectorNodeScopeId">
110
+ <ScopeIcon type="Virtual" />
111
+ <div>A scope</div>
112
+ </div>
113
+ </TestWrapper>,
119
114
  ));
120
115
 
121
116
  it("Call onScopeSelect on Node click if scope type is not virtual", () => {
122
117
  const component = (
123
- <TestWrapper provider={{ store }} memoryRouter>
118
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
124
119
  <ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
125
120
  </TestWrapper>
126
121
  );
@@ -133,7 +128,7 @@ describe("ScopeNode", () => {
133
128
  preventDefault: preventDefaultSpy,
134
129
  };
135
130
 
136
- const node = mountedComponent.find(ContentLabel);
131
+ const node = mountedComponent.find("[data-qa='content-label']");
137
132
 
138
133
  node.invoke("onClick")(event);
139
134
 
@@ -141,91 +136,3 @@ describe("ScopeNode", () => {
141
136
  expect(closeSelector, "to have a call satisfying", { args: [event] });
142
137
  });
143
138
  });
144
-
145
- describe("ContentLabel", () => {
146
- let onClick;
147
- beforeEach(() => {
148
- onClick = () => {};
149
- });
150
-
151
- it("sets css for authorized Global scope", () =>
152
- expect(
153
- <ContentLabel id="selectorNodeScopeId" isGlobal={true} onClick={onClick} />,
154
- "when mounted",
155
- "to have style rules satisfying",
156
- expect
157
- .it("to contain", "text-transform: uppercase;")
158
- .and("to contain", ":hover {background-color: #222;}")
159
- .and("not to contain", "color: #999999")
160
- .and("not to contain", "cursor: default;"),
161
- ));
162
-
163
- it("sets css for unauthorized Global scope", () =>
164
- expect(
165
- <ContentLabel id="selectorNodeScopeId" isGlobal={true} />,
166
- "when mounted",
167
- "to have style rules satisfying",
168
- expect
169
- .it("to contain", "text-transform: uppercase;")
170
- .and("not to contain", ":hover {background-color: #222;}")
171
- .and("to contain", "color: #999999")
172
- .and("to contain", "cursor: default;"),
173
- ));
174
-
175
- it("sets css for a not-clickable and a non-global scope", () =>
176
- expect(
177
- <ContentLabel isGlobal={false} />,
178
- "when mounted",
179
- "to have style rules satisfying",
180
- expect
181
- .it("not to contain", "text-transform: uppercase;")
182
- .and("not to contain", ":hover {background-color: #222;}")
183
- .and("to contain", "color: #999999")
184
- .and("to contain", "cursor: default;"),
185
- ));
186
-
187
- it("sets css for a clickable and a non-global scope", () =>
188
- expect(
189
- <ContentLabel isGlobal={false} onClick={onClick} />,
190
- "when mounted",
191
- "to have style rules satisfying",
192
- expect
193
- .it("not to contain", "text-transform: uppercase;")
194
- .and("to contain", ":hover {background-color: #222;}")
195
- .and("not to contain", "color: #999999")
196
- .and("not to contain", "cursor: default;"),
197
- ));
198
- });
199
-
200
- describe("ScopeIcon", () => {
201
- let theme;
202
- beforeEach(() => {
203
- theme = {
204
- icons: {
205
- scopeTypes: {
206
- Test: "test-icon",
207
- },
208
- },
209
- colors: {
210
- scopeTypes: {
211
- Test: "#00ff00",
212
- },
213
- },
214
- };
215
- });
216
-
217
- it("renders an icon with id based on scope type", () =>
218
- expect(<ScopeIcon theme={theme} type="Test" />, "when mounted", "to satisfy", <Icon id="test-icon" />));
219
-
220
- it("renders in a color based on scope type", () =>
221
- expect(
222
- <ScopeIcon theme={theme} type="Test" />,
223
- "when mounted",
224
- "to have style rules satisfying",
225
- "to contain",
226
- "color: #00ff00;",
227
- ));
228
-
229
- it("by default renders a cross", () =>
230
- expect(<ScopeIcon theme={theme} type="N/A" />, "when mounted", "to satisfy", <Icon id="cross" />));
231
- });
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import Immutable from "immutable";
3
3
  import { Provider } from "react-redux";
4
- import { ThemeProvider } from "styled-components";
5
4
  import ScopeExtendedConfigurationLoader from "./ScopeExtendedConfigurationLoader";
6
5
  import { mount } from "enzyme";
7
6
  import { getScopeExtendedConfiguration } from "../actions/scopes";
@@ -58,9 +57,7 @@ describe("ScopeExtendedConfigurationLoader", () => {
58
57
 
59
58
  const component = (
60
59
  <Provider store={theStore}>
61
- <ThemeProvider theme={{}}>
62
- <ScopeExtendedConfigurationLoader />
63
- </ThemeProvider>
60
+ <ScopeExtendedConfigurationLoader />
64
61
  </Provider>
65
62
  );
66
63
 
@@ -1,40 +1,46 @@
1
1
  import React from "react";
2
2
  import ReactDOM from "react-dom";
3
- import transition from "styled-transition-group";
4
-
5
- const getProp = propName => props => props[propName];
6
-
7
- const panelWidth = getProp("width");
3
+ import { CSSTransition } from "react-transition-group";
4
+ import { makeStyles } from "@material-ui/core/styles";
5
+ import classNames from "classnames";
8
6
 
9
7
  const getModalRoot = () => document.getElementById("modal");
10
8
 
11
- export const PanelDrawer = transition.div`
12
- position: absolute;
13
- top: 0;
14
- bottom: 0;
15
- right: 0;
16
- width: ${panelWidth};
17
-
18
- transition: transform ${getProp("timeout")}ms ease-out;
19
-
20
- &:enter {
21
- transform: translateX(${panelWidth});
22
- }
23
- &:enter-active {
24
- transform: translateX(0);
25
- }
26
- &:exit {
27
- transform: translateX(0);
28
- }
29
- &:exit-active {
30
- transform: translateX(${panelWidth});
31
- }
32
- `;
33
- PanelDrawer.defaultProps = {
34
- timeout: 1000,
35
- unmountOnExit: true,
9
+ const useStyles = makeStyles({
10
+ panel: props => ({
11
+ position: "absolute",
12
+ top: 0,
13
+ bottom: 0,
14
+ right: 0,
15
+ width: props.width,
16
+
17
+ "&.enter": {
18
+ transform: `translateX(${props.width})`,
19
+ },
20
+ "&.enter-active": {
21
+ transform: "translateX(0)",
22
+ transition: `transform ${props.timeout}ms ease-out`,
23
+ },
24
+ "&.exit": {
25
+ transform: "translateX(0)",
26
+ },
27
+ "&.exit-active": {
28
+ transform: `translateX(${props.width})`,
29
+ transition: `transform ${props.timeout}ms ease-out`,
30
+ },
31
+ }),
32
+ });
33
+
34
+ const Sidepanel = ({ in: inProp, width = "300px", timeout = 1000, children, className }) => {
35
+ const classes = useStyles({ width, timeout });
36
+
37
+ const panel = (
38
+ <CSSTransition in={inProp} timeout={timeout} unmountOnExit>
39
+ <div className={classNames(classes.panel, className)}>{children}</div>
40
+ </CSSTransition>
41
+ );
42
+
43
+ return ReactDOM.createPortal(panel, getModalRoot());
36
44
  };
37
45
 
38
- const Sidepanel = props => ReactDOM.createPortal(<PanelDrawer {...props} />, getModalRoot());
39
-
40
46
  export default Sidepanel;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import ReactDOM from "react-dom";
3
- import Sidepanel, { PanelDrawer } from "./Sidepanel";
3
+ import Sidepanel from "./Sidepanel";
4
4
 
5
5
  class RenderSidepanel extends React.Component {
6
6
  render() {
@@ -32,7 +32,7 @@ describe("Sidepanel", () => {
32
32
  document.body.removeChild(modalRoot);
33
33
  });
34
34
 
35
- it("renders a PanelDrawer in a portal", () => {
35
+ it("renders sidepanel in a portal", () => {
36
36
  ReactDOM.render(
37
37
  <RenderSidepanel in>
38
38
  <div id="inner">Foo</div>
@@ -42,32 +42,54 @@ describe("Sidepanel", () => {
42
42
  return expect(modalRoot, "queried for first", "div#inner", "to be a", "DOMElement");
43
43
  });
44
44
 
45
- describe("PanelDrawer", () => {
46
- it("sets the width it is given", () =>
47
- expect(
48
- <PanelDrawer in width="25vw" />,
49
- "when mounted",
50
- "to have style rules satisfying",
51
- "to contain",
52
- "width: 25vw;",
53
- ));
45
+ it("sets the width it is given", () => {
46
+ ReactDOM.render(
47
+ <Sidepanel in width="25vw">
48
+ <div id="inner">Foo</div>
49
+ </Sidepanel>,
50
+ appRoot,
51
+ );
52
+ return expect(
53
+ modalRoot,
54
+ "queried for first",
55
+ "div#modal > div",
56
+ "to have style rules satisfying",
57
+ "to contain",
58
+ "width: 25vw",
59
+ );
60
+ });
54
61
 
55
- it("sets transition according to timeout", () =>
56
- expect(
57
- <PanelDrawer in timeout={300} />,
58
- "when mounted",
59
- "to have style rules satisfying",
60
- "to contain",
61
- "transition: transform 300ms",
62
- ));
62
+ it("sets transition according to timeout", () => {
63
+ ReactDOM.render(
64
+ <Sidepanel in timeout={300}>
65
+ <div id="inner">Foo</div>
66
+ </Sidepanel>,
67
+ appRoot,
68
+ );
69
+ return expect(
70
+ modalRoot,
71
+ "queried for first",
72
+ "div#modal > div",
73
+ "to have style rules satisfying",
74
+ "to contain",
75
+ "transition: transform 300ms",
76
+ );
77
+ });
63
78
 
64
- it("sets default transition", () =>
65
- expect(
66
- <PanelDrawer in />,
67
- "when mounted",
68
- "to have style rules satisfying",
69
- "to contain",
70
- "transition: transform 1000ms",
71
- ));
79
+ it("sets default transition", () => {
80
+ ReactDOM.render(
81
+ <Sidepanel in>
82
+ <div id="inner">Foo</div>
83
+ </Sidepanel>,
84
+ appRoot,
85
+ );
86
+ return expect(
87
+ modalRoot,
88
+ "queried for first",
89
+ "div#modal > div",
90
+ "to have style rules satisfying",
91
+ "to contain",
92
+ "transition: transform 1000ms",
93
+ );
72
94
  });
73
95
  });
@@ -1,35 +1,37 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
- import Icon from "./Icon";
2
+ import { makeStyles } from "@material-ui/core";
3
+ import Icon from "./MaterialUI/DataDisplay/Icon";
4
4
 
5
- export const Wrapper = styled.div`
6
- display: flex;
7
- flex-wrap: wrap;
8
- justify-content: space-around;
9
- overflow-y: auto;
10
- height: 100%;
11
- `;
12
-
13
- export const IconBlock = styled.div`
14
- flex: 0 0 30%;
15
- border: 1px solid #999;
16
- margin: 5px;
17
- padding: 5px 10px;
18
- font-size: 24px;
19
- `;
5
+ const useStyles = makeStyles({
6
+ wrapper: {
7
+ display: "flex",
8
+ flexWrap: "wrap",
9
+ justifyContent: "space-around",
10
+ overflowY: "auto",
11
+ height: "100%",
12
+ },
13
+ iconBlock: {
14
+ flex: "0 0 30%",
15
+ border: "1px solid #999",
16
+ margin: "5px",
17
+ padding: "5px 10px",
18
+ fontSize: "24px",
19
+ },
20
+ });
20
21
 
21
22
  const arrify = thing => [].slice.call(thing);
22
23
 
23
24
  const SpriteSheet = () => {
25
+ const classes = useStyles();
24
26
  const iconIds = arrify(document.querySelectorAll('symbol[id^="icon-"]')).map(elm => elm.id.replace(/^icon-/, ""));
25
27
  return (
26
- <Wrapper>
28
+ <div className={classes.wrapper}>
27
29
  {iconIds.map(id => (
28
- <IconBlock key={id}>
30
+ <div className={classes.iconBlock} key={id}>
29
31
  <Icon id={id} /> {id}
30
- </IconBlock>
32
+ </div>
31
33
  ))}
32
- </Wrapper>
34
+ </div>
33
35
  );
34
36
  };
35
37
 
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import Spritesheet, { Wrapper, IconBlock } from "./Spritesheet";
3
- import Icon from "./Icon";
2
+ import Spritesheet from "./Spritesheet";
3
+ import Icon from "./MaterialUI/DataDisplay/Icon";
4
4
 
5
5
  describe("Spritesheet", () => {
6
6
  beforeEach(() => {
@@ -19,16 +19,16 @@ describe("Spritesheet", () => {
19
19
  <Spritesheet />,
20
20
  "when mounted",
21
21
  "to satisfy",
22
- <Wrapper>
23
- <IconBlock>
22
+ <div>
23
+ <div>
24
24
  <Icon id="test-1" /> {"test-1"}
25
- </IconBlock>
26
- <IconBlock>
25
+ </div>
26
+ <div>
27
27
  <Icon id="test-2" /> {"test-2"}
28
- </IconBlock>
29
- <IconBlock>
28
+ </div>
29
+ <div>
30
30
  <Icon id="test-3" /> {"test-3"}
31
- </IconBlock>
32
- </Wrapper>,
31
+ </div>
32
+ </div>,
33
33
  ));
34
34
  });
@@ -1,50 +1,4 @@
1
- import React from "react";
2
1
  import pt from "prop-types";
3
- import styled, { keyframes } from "styled-components";
4
- import { getThemeProp } from "../utils";
5
- import withErrorBoundary from "../hocs/withErrorBoundary";
6
- import useLabelMessage from "../hooks/useLabelMessage";
7
-
8
- const fadeCycle = keyframes`
9
- 0% {
10
- opacity: 0.3;
11
- }
12
- 100% {
13
- opacity: 0.7;
14
- }
15
- `;
16
-
17
- export const Placeholder = styled.span`
18
- display: inline-block;
19
- height: 1em;
20
- width: 6em;
21
- border-radius: 0.5em;
22
- background-color: ${getThemeProp(["colors", "textMedium"], "#999999")};
23
- animation: ${fadeCycle} 3s infinite alternate;
24
- `;
25
-
26
- const Text = ({ message: rawMessage, error }) => {
27
- const [labelMessage, missingValues] = useLabelMessage(rawMessage);
28
-
29
- if (error || (!rawMessage && rawMessage !== "")) {
30
- return (
31
- <span
32
- style={{
33
- color: "red",
34
- backgroundColor: "white",
35
- fontWeight: "bold",
36
- }}
37
- >
38
- Errored: {error && error.message ? error.message : "No message provided"}
39
- </span>
40
- );
41
- }
42
-
43
- if (missingValues) {
44
- return <Placeholder />;
45
- }
46
- return labelMessage;
47
- };
48
2
 
49
3
  export const ptLabel = pt.oneOfType([
50
4
  pt.string,
@@ -53,6 +7,3 @@ export const ptLabel = pt.oneOfType([
53
7
  defaultMessage: pt.string.isRequired,
54
8
  }),
55
9
  ]);
56
- Text.propTypes = { message: ptLabel };
57
-
58
- export default withErrorBoundary("Text")(Text);