dce-reactkit 1.0.20 → 2.0.0

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 (205) hide show
  1. package/.eslintrc.js +95 -0
  2. package/lib/components/LoadingSpinner.d.ts +7 -0
  3. package/lib/components/LoadingSpinner.js +39 -0
  4. package/lib/components/LoadingSpinner.js.map +1 -0
  5. package/lib/components/Modal.d.ts +69 -0
  6. package/lib/components/Modal.js +311 -0
  7. package/lib/components/Modal.js.map +1 -0
  8. package/lib/helpers/abbreviate.d.ts +9 -0
  9. package/lib/helpers/abbreviate.js +21 -0
  10. package/lib/helpers/abbreviate.js.map +1 -0
  11. package/lib/helpers/avg.d.ts +8 -0
  12. package/lib/helpers/avg.js +24 -0
  13. package/lib/helpers/avg.js.map +1 -0
  14. package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
  15. package/lib/helpers/ceilToNumDecimals.js +15 -0
  16. package/lib/helpers/ceilToNumDecimals.js.map +1 -0
  17. package/lib/helpers/floorToNumDecimals.d.ts +9 -0
  18. package/lib/helpers/floorToNumDecimals.js +15 -0
  19. package/lib/helpers/floorToNumDecimals.js.map +1 -0
  20. package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
  21. package/lib/helpers/forceNumIntoBounds.js +15 -0
  22. package/lib/helpers/forceNumIntoBounds.js.map +1 -0
  23. package/lib/helpers/padDecimalZeros.d.ts +10 -0
  24. package/lib/helpers/padDecimalZeros.js +30 -0
  25. package/lib/helpers/padDecimalZeros.js.map +1 -0
  26. package/lib/helpers/padZerosLeft.d.ts +9 -0
  27. package/lib/helpers/padZerosLeft.js +21 -0
  28. package/lib/helpers/padZerosLeft.js.map +1 -0
  29. package/lib/helpers/roundToNumDecimals.d.ts +9 -0
  30. package/lib/helpers/roundToNumDecimals.js +15 -0
  31. package/lib/helpers/roundToNumDecimals.js.map +1 -0
  32. package/lib/helpers/sum.d.ts +8 -0
  33. package/lib/helpers/sum.js +15 -0
  34. package/lib/helpers/sum.js.map +1 -0
  35. package/lib/helpers/waitMs.d.ts +7 -0
  36. package/lib/helpers/waitMs.js +55 -0
  37. package/lib/helpers/waitMs.js.map +1 -0
  38. package/lib/types/Variant.d.ts +15 -0
  39. package/lib/types/Variant.js +19 -0
  40. package/lib/types/Variant.js.map +1 -0
  41. package/package.json +22 -40
  42. package/src/components/LoadingSpinner.scss +50 -0
  43. package/src/components/LoadingSpinner.tsx +50 -0
  44. package/src/components/Modal.scss +48 -0
  45. package/src/components/Modal.tsx +391 -0
  46. package/src/helpers/abbreviate.tsx +23 -0
  47. package/src/helpers/avg.tsx +22 -0
  48. package/src/helpers/ceilToNumDecimals.tsx +13 -0
  49. package/src/helpers/floorToNumDecimals.tsx +13 -0
  50. package/src/helpers/forceNumIntoBounds.tsx +19 -0
  51. package/src/helpers/padDecimalZeros.tsx +32 -0
  52. package/src/helpers/padZerosLeft.tsx +21 -0
  53. package/src/helpers/roundToNumDecimals.tsx +13 -0
  54. package/src/helpers/sum.tsx +16 -0
  55. package/src/helpers/waitMs.tsx +12 -0
  56. package/src/types/Variant.tsx +16 -0
  57. package/tsconfig.json +24 -0
  58. package/index.js +0 -1
  59. package/lib/Bar.js +0 -169
  60. package/lib/Donut.js +0 -145
  61. package/lib/DownloadButton.js +0 -81
  62. package/lib/Histogram.js +0 -193
  63. package/lib/Scatter.js +0 -162
  64. package/lib/StackedBar.js +0 -243
  65. package/lib/common/chart/Holder/index.js +0 -182
  66. package/lib/common/chart/Holder/style.css +0 -41
  67. package/lib/common/chart/colors.js +0 -12
  68. package/lib/common/csvToString.js +0 -23
  69. package/lib/common/isFloat.js +0 -14
  70. package/lib/common/isInteger.js +0 -24
  71. package/lib/common/math.js +0 -21
  72. package/lib/common/validators.js +0 -18
  73. package/lib/glyph/Adjust.js +0 -13
  74. package/lib/glyph/Angle.js +0 -44
  75. package/lib/glyph/Archive.js +0 -13
  76. package/lib/glyph/Arrow.js +0 -49
  77. package/lib/glyph/ArrowsHorizontal.js +0 -13
  78. package/lib/glyph/ArrowsVertical.js +0 -13
  79. package/lib/glyph/Award.js +0 -13
  80. package/lib/glyph/Ban.js +0 -13
  81. package/lib/glyph/Barcode.js +0 -13
  82. package/lib/glyph/Bed.js +0 -13
  83. package/lib/glyph/Bell.js +0 -35
  84. package/lib/glyph/Bolt.js +0 -13
  85. package/lib/glyph/Bookmark.js +0 -37
  86. package/lib/glyph/Bug.js +0 -13
  87. package/lib/glyph/Calendar.js +0 -13
  88. package/lib/glyph/Check.js +0 -36
  89. package/lib/glyph/Checkbox.js +0 -40
  90. package/lib/glyph/Chevron.js +0 -63
  91. package/lib/glyph/Circle.js +0 -15
  92. package/lib/glyph/Cog.js +0 -13
  93. package/lib/glyph/DoubleAngle.js +0 -45
  94. package/lib/glyph/Download.js +0 -13
  95. package/lib/glyph/Ellipsis.js +0 -36
  96. package/lib/glyph/Envelope.js +0 -13
  97. package/lib/glyph/File.js +0 -37
  98. package/lib/glyph/IdCard.js +0 -13
  99. package/lib/glyph/Menu.js +0 -13
  100. package/lib/glyph/Minus.js +0 -13
  101. package/lib/glyph/Move.js +0 -13
  102. package/lib/glyph/Plus.js +0 -13
  103. package/lib/glyph/Square.js +0 -47
  104. package/lib/glyph/Teacher.js +0 -13
  105. package/lib/glyph/TextAlign.js +0 -53
  106. package/lib/glyph/Times.js +0 -36
  107. package/lib/glyph/WarningTriangle.js +0 -13
  108. package/lib/index.js +0 -1
  109. package/src-old/common/csvToString.js +0 -5
  110. package/src-old/common/isFloat.js +0 -3
  111. package/src-old/common/isInteger.js +0 -14
  112. package/src-old/common/math.js +0 -16
  113. package/src-old/common/validators.js +0 -14
  114. package/src-old/components/Alert.js +0 -79
  115. package/src-old/components/Button.js +0 -64
  116. package/src-old/components/CSV/autoMatch.js +0 -174
  117. package/src-old/components/CSV/getNumCols.js +0 -15
  118. package/src-old/components/CSV/index.js +0 -743
  119. package/src-old/components/Card.js +0 -64
  120. package/src-old/components/Chart/Bar.js +0 -169
  121. package/src-old/components/Chart/Donut.js +0 -160
  122. package/src-old/components/Chart/Histogram.js +0 -189
  123. package/src-old/components/Chart/Scatter.js +0 -162
  124. package/src-old/components/Chart/colors.js +0 -20
  125. package/src-old/components/Checkbox/index.js +0 -106
  126. package/src-old/components/Checkbox/style.css +0 -11
  127. package/src-old/components/DatePicker.js +0 -59
  128. package/src-old/components/DownloadButton.js +0 -72
  129. package/src-old/components/Dropdown.js +0 -120
  130. package/src-old/components/Layout/LeftAddon.js +0 -63
  131. package/src-old/components/Layout/RightAddon.js +0 -64
  132. package/src-old/components/Layout/TwoCol.js +0 -67
  133. package/src-old/components/Modal.js +0 -161
  134. package/src-old/components/PhotoRoster.js +0 -152
  135. package/src-old/components/Pills.js +0 -117
  136. package/src-old/components/Radio.js +0 -94
  137. package/src-old/components/Splash/Error.js +0 -62
  138. package/src-old/components/Splash/Load/index.js +0 -32
  139. package/src-old/components/Splash/Load/style.css +0 -51
  140. package/src-old/components/Stat/General.js +0 -252
  141. package/src-old/components/Stat/helpers/calcAverage.js +0 -20
  142. package/src-old/components/Stat/helpers/calcExtremes.js +0 -27
  143. package/src-old/components/Stat/helpers/calcMedian.js +0 -32
  144. package/src-old/components/Stat/helpers/calcStdDev.js +0 -30
  145. package/src-old/components/Stat/helpers/calcSum.js +0 -8
  146. package/src-old/components/UserProfile/index.js +0 -151
  147. package/src-old/components/UserProfile/style.css +0 -33
  148. package/src-old/components/Well.js +0 -28
  149. package/src-old/components/Wizard/Question/CSV.js +0 -307
  150. package/src-old/components/Wizard/Question/Chooser/Assignment.js +0 -108
  151. package/src-old/components/Wizard/Question/Chooser/Course.js +0 -214
  152. package/src-old/components/Wizard/Question/Chooser/helpers/divideIntoSections.js +0 -16
  153. package/src-old/components/Wizard/Question/Chooser/helpers/genGetItemsPromise.js +0 -20
  154. package/src-old/components/Wizard/Question/Chooser/helpers/preprocessSections.js +0 -36
  155. package/src-old/components/Wizard/Question/Chooser/index.js +0 -306
  156. package/src-old/components/Wizard/Question/Form/Field/CheckableItem.js +0 -155
  157. package/src-old/components/Wizard/Question/Form/Field/Input.js +0 -149
  158. package/src-old/components/Wizard/Question/Form/Field/NumberItem.js +0 -374
  159. package/src-old/components/Wizard/Question/Form/Field/index.js +0 -34
  160. package/src-old/components/Wizard/Question/Form/Field/readme.md +0 -7
  161. package/src-old/components/Wizard/Question/Form/index.js +0 -175
  162. package/src-old/components/Wizard/Question/Form/style.css +0 -3
  163. package/src-old/components/Wizard/Question/OneButton.js +0 -80
  164. package/src-old/components/Wizard/Question/index.js +0 -46
  165. package/src-old/components/Wizard/Question/readme.md +0 -10
  166. package/src-old/components/Wizard/QuestionGroup/AnswerAll.js +0 -126
  167. package/src-old/components/Wizard/QuestionGroup/AnswerAny.js +0 -60
  168. package/src-old/components/Wizard/index.js +0 -233
  169. package/src-old/components/Wizard/style.css +0 -21
  170. package/src-old/glyphs/Adjust.js +0 -13
  171. package/src-old/glyphs/Angle.js +0 -57
  172. package/src-old/glyphs/Archive.js +0 -13
  173. package/src-old/glyphs/Arrow.js +0 -85
  174. package/src-old/glyphs/ArrowsHorizontal.js +0 -13
  175. package/src-old/glyphs/ArrowsVertical.js +0 -13
  176. package/src-old/glyphs/Award.js +0 -13
  177. package/src-old/glyphs/Ban.js +0 -13
  178. package/src-old/glyphs/Barcode.js +0 -13
  179. package/src-old/glyphs/Bed.js +0 -13
  180. package/src-old/glyphs/Bell.js +0 -34
  181. package/src-old/glyphs/Bolt.js +0 -13
  182. package/src-old/glyphs/Bookmark.js +0 -36
  183. package/src-old/glyphs/Bug.js +0 -13
  184. package/src-old/glyphs/Calendar.js +0 -13
  185. package/src-old/glyphs/Check.js +0 -34
  186. package/src-old/glyphs/Checkbox.js +0 -42
  187. package/src-old/glyphs/Chevron.js +0 -88
  188. package/src-old/glyphs/Circle.js +0 -16
  189. package/src-old/glyphs/Cog.js +0 -13
  190. package/src-old/glyphs/DoubleAngle.js +0 -58
  191. package/src-old/glyphs/Download.js +0 -13
  192. package/src-old/glyphs/Ellipsis.js +0 -35
  193. package/src-old/glyphs/Envelope.js +0 -13
  194. package/src-old/glyphs/File.js +0 -40
  195. package/src-old/glyphs/IdCard.js +0 -13
  196. package/src-old/glyphs/Menu.js +0 -13
  197. package/src-old/glyphs/Minus.js +0 -13
  198. package/src-old/glyphs/Move.js +0 -13
  199. package/src-old/glyphs/Plus.js +0 -13
  200. package/src-old/glyphs/Square.js +0 -48
  201. package/src-old/glyphs/Teacher.js +0 -13
  202. package/src-old/glyphs/TextAlign.js +0 -58
  203. package/src-old/glyphs/Times.js +0 -34
  204. package/src-old/glyphs/WarningTriangle.js +0 -13
  205. package/src-old/index.js +0 -1
@@ -1,67 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import boostrap components
5
- import { Row, Col } from 'reactstrap';
6
- // Import bootstrap stylesheet
7
- import 'bootstrap/dist/css/bootstrap.min.css';
8
-
9
- /*
10
- Looks like:
11
- |'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''|
12
- | ........................................................................... |
13
- | | Left Column (first child) | | Right Column (second child) | |
14
- | ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
15
- |'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
16
- */
17
-
18
- class TwoCol extends Component {
19
- render() {
20
- const {
21
- col1Align,
22
- col2Align,
23
- children,
24
- } = this.props;
25
-
26
- const leftChild = (children.length > 0 ? children[0] : {});
27
- const rightChild = (children.length > 1 ? children[1] : {});
28
-
29
- return (
30
- <Row>
31
- <Col className={`text-${col1Align}`}>
32
- {leftChild}
33
- </Col>
34
- <Col className={`text-${col2Align}`}>
35
- {rightChild}
36
- </Col>
37
- </Row>
38
- );
39
- }
40
- }
41
-
42
- TwoCol.propTypes = {
43
- // Text alignment for the left column
44
- col1Align: PropTypes.oneOf([
45
- 'left',
46
- 'right',
47
- 'center',
48
- ]),
49
- // Text alignment for the right column
50
- col2Align: PropTypes.oneOf([
51
- 'left',
52
- 'right',
53
- 'center',
54
- ]),
55
- /* Must have two children: first child is the item on the left that fills up
56
- * the ret of the space, the second child is the item that's added on the
57
- * right
58
- */
59
- children: PropTypes.arrayOf(PropTypes.node).isRequired,
60
- };
61
-
62
- TwoCol.defaultProps = {
63
- col1Align: 'left',
64
- col2Align: 'right',
65
- };
66
-
67
- export default TwoCol;
@@ -1,161 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import bootstrap components
5
- import {
6
- Modal as BootstrapModal,
7
- ModalHeader,
8
- ModalBody,
9
- ModalFooter,
10
- } from 'reactstrap';
11
- // Import bootstrap stylesheet
12
- import 'bootstrap/dist/css/bootstrap.min.css';
13
-
14
- import Button from './Button';
15
-
16
- class Modal extends Component {
17
- constructor(props) {
18
- super(props);
19
-
20
- // Initialize state
21
- // Only show the modal if there's some content to display
22
- this.state = {
23
- isOpen: !!(
24
- props.body
25
- || props.title
26
- || props.buttons
27
- || props.footerMessage
28
- ),
29
- };
30
-
31
- this.toggle = this.toggle.bind(this);
32
- }
33
-
34
- toggle() {
35
- // Deconstruct state
36
- const { isOpen } = this.state;
37
-
38
- // Toggle state
39
- this.setState({
40
- isOpen: !isOpen,
41
- });
42
- }
43
-
44
- render() {
45
- // Deconstruct properties
46
- const {
47
- title,
48
- body,
49
- footerMessage,
50
- buttons,
51
- allowClose,
52
- onClose,
53
- children,
54
- } = this.props;
55
-
56
- // Get footer text
57
- let footerMessageText;
58
- if (footerMessage && typeof footerMessage === 'string') {
59
- footerMessageText = footerMessage;
60
- }
61
-
62
- // Deconstruct state
63
- const { isOpen } = this.state;
64
-
65
- // Choose backdrop
66
- const backdrop = (allowClose ? true : 'static');
67
-
68
- // Create buttons
69
- const buttonComponents = buttons.map((buttonProperties) => {
70
- const {
71
- text,
72
- color,
73
- onClick,
74
- } = buttonProperties;
75
-
76
- return (
77
- <Button
78
- key={text}
79
- text={text}
80
- color={color}
81
- className="mr-1"
82
- onClick={() => {
83
- this.toggle();
84
- if (onClick) {
85
- onClick();
86
- }
87
- }}
88
- />
89
- );
90
- });
91
-
92
- return (
93
- <BootstrapModal
94
- isOpen={isOpen}
95
- toggle={this.toggle}
96
- onClosed={onClose}
97
- backdrop={backdrop}
98
- >
99
- {title && (
100
- <ModalHeader
101
- toggle={allowClose ? this.toggle : undefined}
102
- >
103
- {title || 'Notice:'}
104
- </ModalHeader>
105
- )}
106
- {(body || children) && (
107
- <ModalBody>
108
- {body || children}
109
- </ModalBody>
110
- )}
111
- {(buttonComponents.length > 0 || footerMessageText) && (
112
- <ModalFooter>
113
- <span className="mr-auto">{footerMessageText}</span>
114
- {buttonComponents}
115
- </ModalFooter>
116
- )}
117
- </BootstrapModal>
118
- );
119
- }
120
- }
121
-
122
- Modal.propTypes = {
123
- /* The title of the modal */
124
- title: PropTypes.string,
125
- /* The text body of the modal */
126
- body: PropTypes.string,
127
- /* The body of the modal (if no text body) */
128
- children: PropTypes.oneOfType([
129
- PropTypes.arrayOf(PropTypes.node),
130
- PropTypes.node,
131
- ]),
132
- /* A message to show on the left side of the footer */
133
- footerMessage: PropTypes.oneOfType([
134
- PropTypes.string,
135
- PropTypes.node,
136
- ]),
137
- /* Buttons to show in the modal */
138
- buttons: PropTypes.arrayOf(
139
- PropTypes.shape({
140
- text: PropTypes.string.isRequired,
141
- color: PropTypes.string,
142
- onClick: PropTypes.func,
143
- })
144
- ),
145
- /* If true, the modal is allowed to be closed */
146
- allowClose: PropTypes.bool,
147
- /* Handler for when the modal is closed */
148
- onClose: PropTypes.func,
149
- };
150
-
151
- Modal.defaultProps = {
152
- title: null,
153
- body: null,
154
- children: null,
155
- footerMessage: null,
156
- buttons: [],
157
- allowClose: false,
158
- onClose: null,
159
- };
160
-
161
- export default Modal;
@@ -1,152 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
- import initCACCL from 'caccl/client/cached';
4
- import CACCLInstance from 'caccl/APIInstanceClass';
5
-
6
- // Import other components
7
- import LoadSplash from './Splash/Load';
8
- import ErrorSplash from './Splash/Error';
9
- import UserProfile from './UserProfile';
10
-
11
- const STATUS = {
12
- LOADING: 'loading',
13
- ERROR: 'err',
14
- DISPLAYING: 'displaying',
15
- };
16
-
17
- class Roster extends Component {
18
- constructor(props) {
19
- super(props);
20
-
21
- // Deconstruct props
22
- const {
23
- users,
24
- courseId,
25
- filter,
26
- api,
27
- } = props;
28
-
29
- // Pull list of users (if not included)
30
- if (users) {
31
- this.state = {
32
- users,
33
- status: STATUS.DISPLAYING,
34
- };
35
- } else if (courseId) {
36
- // Pull users from course
37
- this.state = {
38
- status: STATUS.LOADING,
39
- };
40
- api.course.listStudents({
41
- courseId,
42
- includeAvatar: true,
43
- includeEmail: true,
44
- })
45
- .then((enrollments) => {
46
- let loadedUsers = enrollments;
47
- if (filter) {
48
- loadedUsers = loadedUsers.filter(filter);
49
- }
50
- this.setState({
51
- users: loadedUsers,
52
- status: STATUS.DISPLAYING,
53
- });
54
- })
55
- .catch((err) => {
56
- this.setState({
57
- err,
58
- status: STATUS.ERROR,
59
- });
60
- });
61
- } else {
62
- // No context to pull from
63
- this.state = {
64
- status: STATUS.ERROR,
65
- err: 'No course selected',
66
- };
67
- }
68
- }
69
-
70
- render() {
71
- // Deconstruct state
72
- const {
73
- color,
74
- size,
75
- users,
76
- loadMessage,
77
- err,
78
- status,
79
- } = this.state;
80
-
81
- // Render loader
82
- if (status === STATUS.LOADING) {
83
- return (
84
- <LoadSplash
85
- message={loadMessage}
86
- />
87
- );
88
- }
89
-
90
- // Render error
91
- if (status === STATUS.ERROR) {
92
- return (
93
- <ErrorSplash
94
- err={err}
95
- allowClose
96
- />
97
- );
98
- }
99
-
100
- // Displaying
101
- const profiles = users.map((user) => {
102
- return (
103
- <UserProfile
104
- key={user.id}
105
- user={user}
106
- color={color}
107
- size={size}
108
- marginRight="5px"
109
- marginLeft="5px"
110
- marginBottom="5px"
111
- />
112
- );
113
- });
114
- return (
115
- <div
116
- className="text-center"
117
- >
118
- {profiles}
119
- </div>
120
- );
121
- }
122
- }
123
-
124
- Roster.propTypes = {
125
- /* Array of Canvas users */
126
- users: PropTypes.shape({
127
- name: PropTypes.string.isRequired,
128
- email: PropTypes.string.isRequired,
129
- avatar_url: PropTypes.string.isRequired,
130
- sis_user_id: PropTypes.string.isRequired,
131
- }),
132
- /* The course to pull users from (only valid when users is not included) */
133
- courseId: PropTypes.oneOfType([
134
- PropTypes.string,
135
- PropTypes.number,
136
- ]),
137
- /* Filter function to apply to users (when pulled from course) */
138
- filter: PropTypes.func,
139
- /* CACCL instance to use to get the list of assignment */
140
- api: PropTypes.instanceOf(CACCLInstance),
141
- };
142
-
143
- const { api } = initCACCL();
144
-
145
- Roster.defaultProps = {
146
- api,
147
- users: null,
148
- courseId: null,
149
- filter: null,
150
- };
151
-
152
- export default Roster;
@@ -1,117 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import bootstrap components
5
- import {
6
- Nav,
7
- NavItem,
8
- NavLink,
9
- } from 'reactstrap';
10
- // Import bootstrap stylesheet
11
- import 'bootstrap/dist/css/bootstrap.min.css';
12
-
13
- class Pills extends Component {
14
- constructor(props) {
15
- super(props);
16
-
17
- // Deconstruct props
18
- const { initialActiveIndex } = this.props;
19
-
20
- // Initialize state
21
- this.state = {
22
- activeItem: initialActiveIndex,
23
- };
24
-
25
- // Bind functions
26
- this.itemClicked = this.itemClicked.bind(this);
27
- }
28
-
29
- itemClicked(index) {
30
- // Deconstruct props
31
- const { updateActiveOnClick } = this.props;
32
-
33
- // Update active pill
34
- if (updateActiveOnClick) {
35
- this.setState({
36
- activeItem: index,
37
- });
38
- }
39
-
40
- // Call handler
41
- const { items } = this.props;
42
- const { onClick } = items[index];
43
- if (onClick) {
44
- onClick(items[index], index);
45
- }
46
- }
47
-
48
- render() {
49
- // Extract properties
50
- const { items } = this.props;
51
-
52
- // Deconstruct state
53
- const { activeItem } = this.state;
54
-
55
- const itemElements = items.map((item, index) => {
56
- // Deconstruct item
57
- const {
58
- text,
59
- active,
60
- disabled,
61
- } = item;
62
-
63
- return (
64
- <NavItem
65
- color="secondary"
66
- >
67
- <NavLink
68
- href="#"
69
- onClick={() => { this.itemClicked(index); }}
70
- active={(
71
- activeItem !== null
72
- ? activeItem === index
73
- : active
74
- )}
75
- disabled={disabled}
76
- >
77
- {text}
78
- </NavLink>
79
- </NavItem>
80
- );
81
- });
82
-
83
- return (
84
- <Nav pills>
85
- {itemElements}
86
- </Nav>
87
- );
88
- }
89
- }
90
-
91
- Pills.propTypes = {
92
- /* The items to show as pills */
93
- items: PropTypes.arrayOf(
94
- PropTypes.shape({
95
- /* The label text of the item */
96
- text: PropTypes.string.isRequired,
97
- /* If true, item is marked active (ignored if activeItem is defined) */
98
- active: PropTypes.bool,
99
- /* If true, item is disabled */
100
- disabled: PropTypes.bool,
101
- /* Handler to call when clicked (called with item, index as args) */
102
- onClick: PropTypes.func,
103
- })
104
- ),
105
- /* If true, when an item is clicked, it is made active */
106
- updateActiveOnClick: PropTypes.bool,
107
- /* The index of the initial active item */
108
- initialActiveIndex: PropTypes.number,
109
- };
110
-
111
- Pills.defaultProps = {
112
- items: null,
113
- updateActiveOnClick: false,
114
- initialActiveIndex: null,
115
- };
116
-
117
- export default Pills;
@@ -1,94 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import bootstrap components
5
- import { Button, ButtonGroup } from 'reactstrap';
6
- // Import bootstrap stylesheet
7
- import 'bootstrap/dist/css/bootstrap.min.css';
8
-
9
- /* Same properties as button component, plus:
10
- * - onChange: (index, optionText) function
11
- */
12
-
13
- class Radio extends Component {
14
- constructor(props) {
15
- super(props);
16
-
17
- // state.selected:
18
- // - null (none selected)
19
- // - number (index of selected radio)
20
- const { initialSelectedIndex } = this.props;
21
- this.state = {
22
- selected: initialSelectedIndex,
23
- };
24
-
25
- // Bind functions
26
- this.onRadioBtnClick = this.onRadioBtnClick.bind(this);
27
- }
28
-
29
- onRadioBtnClick(selected) {
30
- // Set this radio button as selected
31
- this.setState({ selected });
32
-
33
- // Deconstruct properties
34
- const {
35
- onChange,
36
- items,
37
- } = this.props;
38
-
39
- if (onChange) {
40
- onChange(items[selected], selected);
41
- }
42
- }
43
-
44
- render() {
45
- // Deconstruct properties
46
- const {
47
- items,
48
- color,
49
- } = this.props;
50
-
51
- // Deconstruct state
52
- const { selected } = this.state;
53
-
54
- const buttons = items.map((text, index) => {
55
- return (
56
- <Button
57
- key={text}
58
- onClick={() => {
59
- return this.onRadioBtnClick(index);
60
- }}
61
- active={selected === index}
62
- color={color}
63
- >
64
- {text}
65
- </Button>
66
- );
67
- });
68
-
69
- return (
70
- <ButtonGroup>
71
- {buttons}
72
- </ButtonGroup>
73
- );
74
- }
75
- }
76
-
77
- Radio.propTypes = {
78
- /* Array of item labels to choose from */
79
- items: PropTypes.arrayOf(PropTypes.string).isRequired,
80
- /* Handler to call when radio is changed. Called with option, index. */
81
- onChange: PropTypes.func,
82
- /* The initial item index to select */
83
- initialSelectedIndex: PropTypes.number,
84
- /* Bootstrap color of the buttons */
85
- color: PropTypes.string,
86
- };
87
-
88
- Radio.defaultProps = {
89
- onChange: null,
90
- initialSelectedIndex: 0,
91
- color: 'secondary',
92
- };
93
-
94
- export default Radio;
@@ -1,62 +0,0 @@
1
- import React, { Component } from 'react';
2
-
3
- // Import other components
4
- import Alert from '../Alert';
5
- import Modal from '../Modal';
6
-
7
- // Import glyphs
8
- import WarningTriangle from '../../glyphs/WarningTriangle';
9
-
10
- class ErrorSplash extends Component {
11
- render() {
12
- const {
13
- title,
14
- body,
15
- err,
16
- buttons,
17
- allowClose,
18
- } = this.props;
19
-
20
- // Construct message
21
- let message;
22
- if (body) {
23
- message = body;
24
- } else if (err && err.message) {
25
- ({ message } = err);
26
- } else if (err && typeof err === 'string') {
27
- message = err;
28
- } else {
29
- message = 'An unknown error occurred. If this issue keeps happening, please contact an admin.';
30
- }
31
-
32
- // Construct error code message
33
- const codeMessage = ((err && err.code) && (
34
- <div>
35
- Error code:&nbsp;
36
- <strong>{err.code}</strong>
37
- </div>
38
- ));
39
-
40
- return (
41
- <div>
42
- <Modal
43
- title={title || 'Oops!'}
44
- body={message}
45
- footerMessage={codeMessage}
46
- buttons={buttons}
47
- allowClose={allowClose}
48
- />
49
- <Alert color="warning" centered>
50
- <div>
51
- <WarningTriangle />
52
- <strong>Oops!</strong>
53
- </div>
54
- {message}
55
- {codeMessage}
56
- </Alert>
57
- </div>
58
- );
59
- }
60
- }
61
-
62
- export default ErrorSplash;
@@ -1,32 +0,0 @@
1
- import React, { Component } from 'react';
2
-
3
- // Import glyphs
4
- import Circle from '../../../glyphs/Circle';
5
-
6
- // Import custom styles
7
- import './style.css';
8
-
9
- class LoadSplash extends Component {
10
- render() {
11
- // Deconstruct props
12
- const { message } = this.props;
13
-
14
- return (
15
- <div className="container">
16
- {message && (
17
- <h3>
18
- {message}
19
- </h3>
20
- )}
21
- <div>
22
- <Circle className="circle-1" />
23
- <Circle className="circle-2" />
24
- <Circle className="circle-3" />
25
- <Circle className="circle-4" />
26
- </div>
27
- </div>
28
- );
29
- }
30
- }
31
-
32
- export default LoadSplash;