Skip to content

Commit 91c6b7e

Browse files
authored
Merge pull request #111 from agh-space-systems-rover/background-ui-improvements
Background image
2 parents c06cbb3 + 35a1541 commit 91c6b7e

3 files changed

Lines changed: 35 additions & 68 deletions

File tree

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
11
.file-input-container {
22
display: flex;
3-
align-items: stretch;
4-
margin: 5px;
5-
height: calc(1em + 10px);
3+
flex: 1;
4+
width: 100%;
5+
min-width: 0;
66
}
77

88
.file-hidden {
99
display: none;
1010
}
1111

12-
.file-main,
13-
.file-clear {
14-
background-color: var(--dark-background);
15-
border: none;
16-
color: var(--strong-foreground);
17-
height: 100%;
18-
display: flex;
19-
align-items: center;
20-
}
21-
2212
.file-main {
2313
flex: 1;
24-
border-top-left-radius: 5px;
25-
border-bottom-left-radius: 5px;
26-
27-
border-right: 1px solid var(--background);
28-
29-
padding: 0 10px;
14+
background-color: var(--dark-background) !important;
3015
min-width: 0;
16+
justify-content: flex-start;
3117
}
3218

3319
.file-main-inner {
@@ -36,32 +22,11 @@
3622
gap: 8px;
3723
width: 100%;
3824
min-width: 0;
25+
padding: 2px 5px 4px 5px;
3926
}
4027

4128
.file-main-text {
4229
overflow: hidden;
4330
text-overflow: ellipsis;
4431
white-space: nowrap;
4532
}
46-
47-
.file-clear {
48-
width: 38px;
49-
justify-content: center;
50-
51-
border-top-right-radius: 5px;
52-
border-bottom-right-radius: 5px;
53-
54-
padding: 0;
55-
}
56-
57-
.file-main:hover:not(:disabled),
58-
.file-clear:hover:not(:disabled) {
59-
filter: brightness(1.08);
60-
}
61-
62-
.file-main:disabled,
63-
.file-clear:disabled {
64-
opacity: 0.45;
65-
cursor: not-allowed;
66-
filter: none;
67-
}

kalman_gs/node_project/src/components/file-input.tsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class FileInput extends Component<Props, State> {
3535
};
3636

3737
private get emptyLabel() {
38-
return this.props.emptyLabel ?? 'Choose image...';
38+
return this.props.emptyLabel ?? 'Choose file...';
3939
}
4040

4141
componentDidUpdate(prevProps: Props) {
@@ -66,9 +66,12 @@ export default class FileInput extends Component<Props, State> {
6666
clear() {
6767
if (!this.ref.current) return;
6868
this.ref.current.value = '';
69-
this.updateLabelFromInput();
7069
this.props.onChange?.(null);
7170
this.props.onClear?.();
71+
this.setState({
72+
label: this.emptyLabel,
73+
hasFiles: false
74+
});
7275
}
7376

7477
render() {
@@ -77,7 +80,7 @@ export default class FileInput extends Component<Props, State> {
7780
const { label, hasFiles } = this.state;
7881

7982
return (
80-
<div className={`${styles['file-input-container']}${className ? ` ${className}` : ''}`} {...props}>
83+
<>
8184
{/* hidden real input */}
8285
<input
8386
ref={this.ref}
@@ -92,29 +95,28 @@ export default class FileInput extends Component<Props, State> {
9295
}}
9396
/>
9497

95-
{/* main button */}
96-
<Button
97-
className={styles['file-main']}
98-
tooltip={hasFiles ? 'Change file' : 'Choose file'}
99-
onClick={() => this.openPicker()}
100-
disabled={disabled}
101-
>
102-
<span className={styles['file-main-inner']}>
103-
<FontAwesomeIcon icon={faUpload} />
104-
<span className={styles['file-main-text']}>{label}</span>
105-
</span>
106-
</Button>
107-
108-
{/* clear button (X) */}
109-
<Button
110-
className={styles['file-clear']}
111-
tooltip='Usuń'
112-
onClick={() => this.clear()}
113-
disabled={(disabled || !hasFiles) && !this.props.canClearEmpty}
114-
>
115-
<FontAwesomeIcon icon={faXmark} />
116-
</Button>
117-
</div>
98+
<div className={`${styles['file-input-container']}${className ? ` ${className}` : ''}`} {...props}>
99+
<Button
100+
className={styles['file-main']}
101+
tooltip={hasFiles ? 'Change file' : 'Choose file'}
102+
onClick={() => this.openPicker()}
103+
disabled={disabled}
104+
>
105+
<span className={styles['file-main-inner']}>
106+
<FontAwesomeIcon icon={faUpload} />
107+
<span className={styles['file-main-text']}>{label}</span>
108+
</span>
109+
</Button>
110+
111+
<Button
112+
tooltip='Remove selected files.'
113+
onClick={() => this.clear()}
114+
disabled={(disabled || !hasFiles) && !this.props.canClearEmpty}
115+
>
116+
<FontAwesomeIcon icon={faXmark} />
117+
</Button>
118+
</div>
119+
</>
118120
);
119121
}
120122
}

kalman_gs/node_project/src/components/settings.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
font-size: 18px;
142142
}
143143

144-
.background-selector{
144+
.background-selector {
145145
display: flex;
146146
flex-direction: column;
147147
margin-top: -5px;

0 commit comments

Comments
 (0)