Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 130f1bd

Browse files
authored
Merge pull request #349 from topcoder-platform/dev
TaaS Intake - v2.01
2 parents 090fd8c + 7e1007a commit 130f1bd

File tree

42 files changed

+885
-285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+885
-285
lines changed

package-lock.json

+31-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"prop-types": "^15.7.2",
7272
"react": "^16.12.0",
7373
"react-avatar": "^3.9.7",
74-
"react-datepicker": "^3.4.1",
74+
"react-datepicker": "^3.8.0",
7575
"react-dom": "^16.12.0",
7676
"react-final-form": "^6.5.2",
7777
"react-final-form-arrays": "^3.1.3",
Loading
+23
Loading

src/components/FormField/index.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const FormField = ({ field }) => {
8282
onBlur={input.onBlur}
8383
onFocus={input.onFocus}
8484
className={meta.error && meta.touched ? "error" : ""}
85+
maxLength={field.maxLength}
8586
/>
8687
)}
8788
{field.type === FORM_FIELD_TYPE.DATE && (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* Information Tooltip
3+
* Icon which reveals a tooltip on mouse hover
4+
*/
5+
import React, { useCallback, useState } from "react";
6+
import PT from "prop-types";
7+
import { usePopper } from "react-popper";
8+
import IconInformationCircle from "../../assets/images/icon-information-circle.svg";
9+
import "./styles.module.scss";
10+
11+
function InformationTooltip({ text, iconSize = "16px" }) {
12+
const [isTooltipShown, setIsTooltipShown] = useState(false);
13+
const [referenceElement, setReferenceElement] = useState(null);
14+
const [popperElement, setPopperElement] = useState(null);
15+
const [arrowElement, setArrowElement] = useState(null);
16+
const { styles, attributes } = usePopper(referenceElement, popperElement, {
17+
placement: "top",
18+
modifiers: [
19+
{
20+
name: "flip",
21+
options: {
22+
fallbackPlacements: ["top"],
23+
},
24+
},
25+
{
26+
name: "offset",
27+
options: {
28+
// use offset to move the tooltip slightly up
29+
offset: [0, 12],
30+
},
31+
},
32+
{
33+
name: "arrow",
34+
// padding should be equal to border-radius of the tooltip
35+
options: { element: arrowElement, padding: 5 },
36+
},
37+
],
38+
});
39+
40+
const showTooltip = useCallback(() => {
41+
setIsTooltipShown(true);
42+
}, []);
43+
44+
const hideTooltip = useCallback(() => {
45+
setIsTooltipShown(false);
46+
}, []);
47+
48+
const iconStyle = {
49+
width: iconSize,
50+
height: iconSize,
51+
};
52+
53+
return (
54+
<div>
55+
<div
56+
style={iconStyle}
57+
ref={setReferenceElement}
58+
onMouseEnter={showTooltip}
59+
onMouseLeave={hideTooltip}
60+
>
61+
<IconInformationCircle styleName="circle" />
62+
</div>
63+
{isTooltipShown && (
64+
<div
65+
styleName="tooltip"
66+
ref={setPopperElement}
67+
style={styles.popper}
68+
{...attributes.popper}
69+
>
70+
<div styleName="tooltip-content">{text}</div>
71+
<div
72+
styleName="tooltip-arrow"
73+
ref={setArrowElement}
74+
style={styles.arrow}
75+
/>
76+
</div>
77+
)}
78+
</div>
79+
);
80+
}
81+
82+
InformationTooltip.propTypes = {
83+
iconSize: PT.string,
84+
text: PT.string,
85+
};
86+
87+
export default InformationTooltip;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@import "styles/include";
2+
3+
.circle {
4+
* {
5+
fill: #aaa;
6+
}
7+
}
8+
9+
.tooltip {
10+
border-radius: 5px;
11+
box-shadow: 0px 5px 25px #c6c6c6;
12+
width: 165px;
13+
z-index: 1000;
14+
}
15+
16+
.tooltip-arrow {
17+
bottom: -9px;
18+
border-style: solid;
19+
border-width: 10px 8px 0 8px;
20+
border-color: #2a2a2a transparent transparent transparent;
21+
height: 0;
22+
width: 0;
23+
}
24+
25+
.tooltip-content {
26+
border-radius: 5px;
27+
@include font-roboto;
28+
font-size: 12px;
29+
line-height: 16px;
30+
font-weight: 400;
31+
color: #fff;
32+
background-color: #2a2a2a;
33+
padding: 10px;
34+
}

src/components/MarkdownEditor/index.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const MarkdownEditor = (props) => {
5353
]}
5454
plugins={[]}
5555
/>
56+
{props.errorMessage && (
57+
<div styleName="message">{props.errorMessage}</div>
58+
)}
5659
</div>
5760
);
5861
};

src/components/MarkdownEditor/styles.module.scss

+16-15
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,6 @@
1212
overflow-y: auto;
1313
background: #fafafb;
1414
}
15-
.message {
16-
@include font-roboto;
17-
18-
width: 100%;
19-
text-align: center;
20-
min-height: 40px;
21-
line-height: 20px;
22-
padding: 9px 10px;
23-
margin: 10px 0 5px;
24-
font-size: 14px;
25-
color: #ff5b52;
26-
border: 1px solid #ffd5d1;
27-
cursor: auto;
28-
outline: none;
29-
}
3015
}
3116
.editor-container {
3217
:global {
@@ -72,3 +57,19 @@
7257
}
7358
}
7459
}
60+
61+
.message {
62+
@include font-roboto;
63+
64+
width: 100%;
65+
text-align: center;
66+
min-height: 40px;
67+
line-height: 20px;
68+
padding: 9px 10px;
69+
margin: 10px 0 5px;
70+
font-size: 14px;
71+
color: #ff5b52;
72+
border: 1px solid #ffd5d1;
73+
cursor: auto;
74+
outline: none;
75+
}

src/components/MonthPicker/index.jsx

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Month Picker
3+
* An styled input component for selecting date by month.
4+
* Compatible with react-final-form
5+
*/
6+
import React from "react";
7+
import PT from "prop-types";
8+
import DatePicker from "react-datepicker";
9+
import "./styles.module.scss";
10+
11+
function getCurrMonthYear() {
12+
const now = new Date();
13+
const year = now.getFullYear();
14+
const month = now.getMonth();
15+
return new Date(`${year}-${month + 1}`);
16+
}
17+
18+
function MonthPicker({ name, value, onChange, onBlur, onFocus }) {
19+
return (
20+
<div styleName="month-picker">
21+
<DatePicker
22+
name={name}
23+
selected={value}
24+
onChange={onChange}
25+
dateFormat="MMM, yyyy"
26+
showMonthYearPicker
27+
showPopperArrow={false}
28+
onBlur={onBlur}
29+
onFocus={onFocus}
30+
popperPlacement="top-end"
31+
showFourColumnMonthYearPicker
32+
minDate={getCurrMonthYear()}
33+
/>
34+
</div>
35+
);
36+
}
37+
38+
MonthPicker.propTypes = {
39+
name: PT.string,
40+
value: PT.any,
41+
onChange: PT.func,
42+
onBlur: PT.func,
43+
};
44+
45+
export default MonthPicker;

0 commit comments

Comments
 (0)