Skip to content

Commit f33a5b6

Browse files
authored
Merge pull request #6 from JelteMX/feature/progress_colors
Feature/progress colors
2 parents 0007b12 + 82e249b commit f33a5b6

10 files changed

+72
-9
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ Verification can be done in two ways:
8484

8585
### 5. UI
8686

87-
![configuration5](/assets/configuration5.jpg)
87+
![configuration5](/assets/configuration5.png)
8888

8989
- For various icons you can either use the standard Bootstrap Gylphicon (the classname will be prefixed with `glyphicon glyphicon-`) or a built-in icon.
90+
- You can switch the type label, previews off
91+
- You can switch off the progress bar once it has been uploaded.
92+
- For the progress bar you can set different colors, depending on the status
9093

9194
### 6. Texts
9295

assets/configuration5.jpg

-168 KB
Binary file not shown.

assets/configuration5.png

86.2 KB
Loading

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "filedropper",
33
"widgetName": "FileDropper",
4-
"version": "1.1.1",
4+
"version": "1.2.0",
55
"description": "Drop files in your Mendix Application",
66
"copyright": "Mendix 2019",
77
"author": "Jelte Lagendijk",

src/FileDropper.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { FileDropperFile } from "./store/fileDropperFile";
1818

1919
import { savePostMethod } from "./util/data";
2020

21-
import { UIProps } from "./components/FileList";
21+
import { UIProps, UIProgressBarColors } from "./components/FileList";
2222
import { getTexts } from "./util/texts";
2323
import { validateProps, ValidationMessage, ValidateExtraProps } from "./util/validation";
2424

@@ -138,13 +138,21 @@ class FileDropperContainer extends Component<FileDropperContainerProps, {}> {
138138
const errorButtonStyle =
139139
uiErrorButtonStyle === "glyphicon" && uiErrorButtonGlyph !== "" ? uiErrorButtonGlyph : null;
140140

141+
const uiProgressBarColors: UIProgressBarColors = {
142+
primary: this.props.uiPbColorStrokeNormal,
143+
error: this.props.uiPbColorError,
144+
success: this.props.uiPbColorSuccess,
145+
trail: this.props.uiPbColorTrail
146+
};
147+
141148
const ui: UIProps = {
142149
deleteButtonStyle,
143150
saveButtonStyle,
144151
errorButtonStyle,
145152
uiShowPreviewLabel,
146153
uiShowImagePreviews,
147-
uiHideProgressOnComplete
154+
uiHideProgressOnComplete,
155+
uiProgressBarColors
148156
};
149157

150158
return <FileDropper store={this.store} uiProps={ui} />;

src/FileDropper.webmodeler.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, ReactNode, createElement } from "react";
22
import { FileDropperContainerProps } from "../typings/FileDropperProps";
33
import { getTexts } from "./util/texts";
4-
import { UIProps, FileList } from "./components/FileList";
4+
import { UIProps, FileList, UIProgressBarColors } from "./components/FileList";
55
import { classes } from "./util/classes";
66
import { FileDropZone } from "./components/FileDropZone";
77
import { Alerts } from "./components/Alerts";
@@ -82,13 +82,21 @@ export class preview extends Component<FileDropperContainerProps> {
8282
const errorButtonStyle =
8383
uiErrorButtonStyle === "glyphicon" && uiErrorButtonGlyph !== "" ? uiErrorButtonGlyph : null;
8484

85+
const uiProgressBarColors: UIProgressBarColors = {
86+
primary: props.uiPbColorStrokeNormal,
87+
error: props.uiPbColorError,
88+
success: props.uiPbColorSuccess,
89+
trail: props.uiPbColorTrail
90+
};
91+
8592
return {
8693
deleteButtonStyle,
8794
saveButtonStyle,
8895
errorButtonStyle,
8996
uiShowPreviewLabel,
9097
uiShowImagePreviews,
91-
uiHideProgressOnComplete
98+
uiHideProgressOnComplete,
99+
uiProgressBarColors
92100
};
93101
}
94102

src/FileDropper.xml

+18
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,28 @@ Note: Only non-persistent entities are accepted.
213213
<caption>Show image previews</caption>
214214
<description>Show previews of images. The widget will determine by itself, based on the Mime type, whether or not it can show a preview. It does this by analyzing the file and if it determines it is a 'image/*' file, show a base64 encoded version of the image.</description>
215215
</property>
216+
</propertyGroup>
217+
<propertyGroup caption="Progress Bar">
216218
<property key="uiHideProgressOnComplete" type="boolean" defaultValue="true">
217219
<caption>Hide progress bar on complete</caption>
218220
<description>When uploading to Mendix is complete, hide the progress bar</description>
219221
</property>
222+
<property key="uiPbColorStrokeNormal" type="string" required="true" defaultValue="#2387AA">
223+
<caption>Primary color</caption>
224+
<description>Default is '#2387AA'</description>
225+
</property>
226+
<property key="uiPbColorTrail" type="string" required="true" defaultValue="#C8F5FF">
227+
<caption>Trail color</caption>
228+
<description>Default is '#C8F5FF'</description>
229+
</property>
230+
<property key="uiPbColorError" type="string" required="true" defaultValue="#FF0000">
231+
<caption>Error color</caption>
232+
<description>Default is '#FF0000'</description>
233+
</property>
234+
<property key="uiPbColorSuccess" type="string" required="true" defaultValue="#32A778">
235+
<caption>Success color</caption>
236+
<description>Default is '#32A778'</description>
237+
</property>
220238
</propertyGroup>
221239
</propertyGroup>
222240

src/components/FileList.tsx

+23-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ import { IFileDropperFile } from "../store/fileDropperFile";
1111
import { classes } from "../util/classes";
1212
import { CancellablePromise } from "mobx/lib/api/flow";
1313

14+
export interface UIProgressBarColors {
15+
primary: string;
16+
trail: string;
17+
error: string;
18+
success: string;
19+
}
20+
1421
export interface UIProps {
1522
deleteButtonStyle: null | string;
1623
saveButtonStyle: null | string;
1724
errorButtonStyle: null | string;
1825
uiShowPreviewLabel: boolean;
1926
uiShowImagePreviews: boolean;
2027
uiHideProgressOnComplete: boolean;
28+
uiProgressBarColors: UIProgressBarColors;
2129
}
2230
export interface FileListProps {
2331
uiProps?: UIProps;
@@ -170,14 +178,27 @@ export class FileList extends Component<FileListProps, {}> {
170178
}
171179

172180
private renderProgress(file: IFileDropperFile): ReactNode {
173-
const strokeColor = file.status === "error" ? "#F00" : "#a5a5a5";
181+
const { uiProps } = this.props;
182+
const standardColor = "#a5a5a5";
183+
const strokeColor =
184+
file.status === "error"
185+
? uiProps?.uiProgressBarColors.error || "#F00"
186+
: file.status === "saved"
187+
? uiProps?.uiProgressBarColors.success || standardColor
188+
: uiProps?.uiProgressBarColors.primary || standardColor;
189+
const trailColor = uiProps?.uiProgressBarColors.trail || "a5a5a5";
174190
const percent = file.status === "error" ? 0 : file.loadProgress;
175191
if (this.props.uiProps && this.props.uiProps.uiHideProgressOnComplete && file.status === "saved") {
176192
return null;
177193
}
178194
return (
179195
<div className={classes("item-progress")}>
180-
<ProgressLine className={classes("item-progress__bar")} percent={percent} strokeColor={strokeColor} />
196+
<ProgressLine
197+
className={classes("item-progress__bar")}
198+
percent={percent}
199+
strokeColor={strokeColor}
200+
trailColor={trailColor}
201+
/>
181202
<div className={classes("item-progress__text")}>{percent}%</div>
182203
</div>
183204
);

src/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="FileDropper" version="1.1.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="FileDropper" version="1.2.0" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="FileDropper.xml"/>
66
</widgetFiles>

typings/FileDropperProps.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ export interface FileDropperContainerProps extends CommonProps {
6565
uiErrorButtonGlyph: string;
6666
uiShowPreviewLabel: boolean;
6767
uiShowImagePreviews: boolean;
68+
6869
uiHideProgressOnComplete: boolean;
70+
uiPbColorStrokeNormal: string;
71+
uiPbColorTrail: string;
72+
uiPbColorError: string;
73+
uiPbColorSuccess: string;
6974

7075
textDropZone: string;
7176
textDropZoneMaximum: string;

0 commit comments

Comments
 (0)