Skip to content

Commit 147053f

Browse files
committed
issue topcoder-platform#8: fix upload component
1 parent ccacf20 commit 147053f

File tree

2 files changed

+58
-38
lines changed

2 files changed

+58
-38
lines changed

src/shared/components/GUIKit/PhotoVideoPicker/index.jsx

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ function PhotoVideoPicker({
2121
inputOptions,
2222
file,
2323
}) {
24+
const renderUpload = () => (
25+
<React.Fragment>
26+
<p styleName="infoText hide-mobile">
27+
{infoText}
28+
</p>
29+
<button styleName="btn hide-mobile" type="button">{btnText}</button>
30+
</React.Fragment>
31+
);
32+
2433
return (
2534
<React.Fragment>
2635
<Dropzone
@@ -66,7 +75,7 @@ function PhotoVideoPicker({
6675
<React.Fragment>
6776

6877
<section
69-
styleName={cn('container', { hasError: !!errorMsg, hasFile: !!file && !!file.length })}
78+
styleName={cn('container', { hasError: !!errorMsg, hasFile: !!file && !!file.length, 'hide-mobile': file.length === 3 })}
7079
{...getRootProps()}
7180
className={cn(className, getRootProps().className)}
7281
>
@@ -76,44 +85,48 @@ function PhotoVideoPicker({
7685
})}
7786
/>
7887
{
79-
file && file.length ? (
80-
<div styleName="photo-list hide-mobile">
81-
{file.map((fileInfo, index) => (
82-
<div
83-
styleName="photo-item"
84-
key={fileInfo.name}
85-
><PhotoVideoItem notSelectable file={fileInfo} />
86-
<button
87-
type="button"
88-
styleName="btn-delete"
89-
onClick={(e) => {
90-
e.stopPropagation();
91-
e.preventDefault();
92-
const newFile = [...file];
93-
newFile.splice(index, 1);
94-
onFilePick(newFile);
95-
}}
96-
><BtnDeletePhoto />
97-
</button>
98-
</div>
99-
))}
100-
</div>
101-
) : (
102-
<React.Fragment>
103-
<p styleName="infoText hide-mobile">
104-
{infoText}
105-
</p>
106-
<button styleName="btn hide-mobile" type="button">{btnText}</button>
107-
</React.Fragment>
108-
)
109-
}
88+
file && file.length ? (
89+
<div styleName="photo-list hide-mobile">
90+
{file.map((fileInfo, index) => (
91+
<div
92+
styleName="photo-item"
93+
key={fileInfo.name}
94+
><PhotoVideoItem notSelectable file={fileInfo} />
95+
<button
96+
type="button"
97+
styleName="btn-delete"
98+
onClick={(e) => {
99+
e.stopPropagation();
100+
e.preventDefault();
101+
const newFile = [...file];
102+
newFile.splice(index, 1);
103+
onFilePick(newFile);
104+
}}
105+
><BtnDeletePhoto />
106+
</button>
107+
</div>
108+
))}
109+
{
110+
file.length < 3 && (
111+
<div styleName="photo-item browse-button">
112+
{renderUpload()}
113+
</div>
114+
)
115+
}
116+
</div>
117+
) : renderUpload()
118+
}
110119

111-
<React.Fragment>
112-
<p styleName="infoText hide-desktop show-mobile">
113-
{infoTextMobile}
114-
</p>
115-
<button styleName="btn hide-desktop show-mobile" type="button">{btnText}</button>
116-
</React.Fragment>
120+
{
121+
(file || []).length < 3 && (
122+
<React.Fragment>
123+
<p styleName="infoText hide-desktop show-mobile">
124+
{infoTextMobile}
125+
</p>
126+
<button styleName="btn hide-desktop show-mobile" type="button">{btnText}</button>
127+
</React.Fragment>
128+
)
129+
}
117130
</section>
118131

119132
</React.Fragment>

src/shared/components/GUIKit/PhotoVideoPicker/styles.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@
103103
justify-content: center;
104104
position: relative;
105105

106+
&.browse-button {
107+
display: flex;
108+
flex-direction: column;
109+
width: 100%;
110+
padding: 0 10px;
111+
}
112+
106113
@media (max-width: 768px) {
107114
height: 100px;
108115
border: none;

0 commit comments

Comments
 (0)