Skip to content

Commit f3905e3

Browse files
committed
Improve file size limit component UI and positioning
- Redesign FileSizeLimitInput with compact horizontal layout - Move file size controls to bottom of each media section for better UX flow - Reduce component footprint with smaller margins and inline design - Fix theme integration using CSS variables instead of props.theme - Remove unused description prop and simplify component interface - Improve visual hierarchy: toggle → formats → size limits
1 parent a8439d9 commit f3905e3

2 files changed

Lines changed: 74 additions & 64 deletions

File tree

src/components/relay-settings/sections/MediaSection/MediaSection.tsx

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,21 @@ export const MediaSection: React.FC<MediaSectionProps> = ({
9494
onChange={photos.onToggle}
9595
mode={mode}
9696
/>
97+
<MediaTypeList
98+
formats={imageFormats}
99+
selectedFormats={photos.selected}
100+
onChange={photos.onChange}
101+
isActive={photos.isActive}
102+
mode={mode}
103+
/>
97104
<FileSizeLimitInput
98105
label="Maximum Photo Size"
99106
value={photos.maxSizeMB}
100107
onChange={photos.onMaxSizeChange}
101108
min={1}
102109
max={1000}
103-
description="Set the maximum file size limit for photo uploads"
104110
disabled={!photos.isActive}
105111
/>
106-
<MediaTypeList
107-
formats={imageFormats}
108-
selectedFormats={photos.selected}
109-
onChange={photos.onChange}
110-
isActive={photos.isActive}
111-
mode={mode}
112-
/>
113112
</S.Card>
114113
</CollapsibleSection>
115114

@@ -120,22 +119,21 @@ export const MediaSection: React.FC<MediaSectionProps> = ({
120119
onChange={videos.onToggle}
121120
mode={mode}
122121
/>
122+
<MediaTypeList
123+
formats={videoFormats}
124+
selectedFormats={videos.selected}
125+
onChange={videos.onChange}
126+
isActive={videos.isActive}
127+
mode={mode}
128+
/>
123129
<FileSizeLimitInput
124130
label="Maximum Video Size"
125131
value={videos.maxSizeMB}
126132
onChange={videos.onMaxSizeChange}
127133
min={1}
128134
max={5000}
129-
description="Set the maximum file size limit for video uploads"
130135
disabled={!videos.isActive}
131136
/>
132-
<MediaTypeList
133-
formats={videoFormats}
134-
selectedFormats={videos.selected}
135-
onChange={videos.onChange}
136-
isActive={videos.isActive}
137-
mode={mode}
138-
/>
139137
</S.Card>
140138
</CollapsibleSection>
141139

@@ -146,22 +144,21 @@ export const MediaSection: React.FC<MediaSectionProps> = ({
146144
onChange={audio.onToggle}
147145
mode={mode}
148146
/>
147+
<MediaTypeList
148+
formats={audioFormats}
149+
selectedFormats={audio.selected}
150+
onChange={audio.onChange}
151+
isActive={audio.isActive}
152+
mode={mode}
153+
/>
149154
<FileSizeLimitInput
150155
label="Maximum Audio Size"
151156
value={audio.maxSizeMB}
152157
onChange={audio.onMaxSizeChange}
153158
min={1}
154159
max={500}
155-
description="Set the maximum file size limit for audio uploads"
156160
disabled={!audio.isActive}
157161
/>
158-
<MediaTypeList
159-
formats={audioFormats}
160-
selectedFormats={audio.selected}
161-
onChange={audio.onChange}
162-
isActive={audio.isActive}
163-
mode={mode}
164-
/>
165162
</S.Card>
166163
</CollapsibleSection>
167164
</>

src/components/relay-settings/sections/MediaSection/components/FileSizeLimitInput.tsx

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,74 @@
11
// src/components/relay-settings/sections/MediaSection/components/FileSizeLimitInput.tsx
22

33
import React from 'react';
4-
import { BaseForm } from '@app/components/common/forms/BaseForm/BaseForm';
5-
import { InputNumber, Space } from 'antd';
4+
import { InputNumber } from 'antd';
65
import styled from 'styled-components';
76

87
const StyledContainer = styled.div`
9-
margin: 16px 0;
10-
padding: 12px;
11-
background: var(--secondary-background-color);
12-
border-radius: 8px;
8+
margin: 8px 0;
9+
padding: 8px 12px;
10+
background: var(--additional-background-color);
11+
border-radius: 6px;
1312
border: 1px solid var(--border-color);
13+
display: flex;
14+
align-items: center;
15+
justify-content: space-between;
16+
gap: 12px;
1417
`;
1518

1619
const StyledLabel = styled.div`
17-
font-size: 14px;
20+
font-size: 13px;
1821
font-weight: 500;
1922
color: var(--text-main-color);
20-
margin-bottom: 8px;
21-
`;
22-
23-
const StyledDescription = styled.div`
24-
font-size: 12px;
25-
color: var(--text-light-color);
26-
margin-bottom: 12px;
23+
flex: 1;
24+
min-width: 0;
2725
`;
2826

2927
const StyledInputWrapper = styled.div`
28+
display: flex;
29+
align-items: center;
30+
gap: 6px;
31+
3032
.ant-input-number {
31-
width: 120px;
33+
width: 80px;
34+
height: 28px;
3235
background: var(--background-color);
3336
border-color: var(--border-color);
34-
color: var(--text-main-color);
37+
border-radius: 4px;
3538
3639
&:hover {
3740
border-color: var(--primary-color);
3841
}
3942
40-
&:focus {
43+
&:focus-within {
4144
border-color: var(--primary-color);
42-
box-shadow: 0 0 0 2px var(--primary-color)20;
45+
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
46+
}
47+
48+
.ant-input-number-input {
49+
color: var(--text-main-color);
50+
font-size: 12px;
51+
height: 26px;
52+
line-height: 26px;
53+
}
54+
55+
&.ant-input-number-disabled {
56+
background: var(--secondary-background-color);
57+
border-color: var(--border-color);
58+
opacity: 0.6;
59+
60+
.ant-input-number-input {
61+
color: var(--text-light-color);
62+
}
4363
}
44-
}
45-
46-
.ant-input-number-input {
47-
color: var(--text-main-color);
4864
}
4965
`;
5066

5167
const StyledUnit = styled.span`
52-
font-size: 14px;
68+
font-size: 12px;
5369
color: var(--text-light-color);
54-
margin-left: 8px;
70+
font-weight: 500;
71+
min-width: 20px;
5572
`;
5673

5774
export interface FileSizeLimitInputProps {
@@ -61,7 +78,6 @@ export interface FileSizeLimitInputProps {
6178
min?: number;
6279
max?: number;
6380
step?: number;
64-
description?: string;
6581
disabled?: boolean;
6682
}
6783

@@ -72,7 +88,6 @@ export const FileSizeLimitInput: React.FC<FileSizeLimitInputProps> = ({
7288
min = 1,
7389
max = 5000,
7490
step = 1,
75-
description,
7691
disabled = false,
7792
}) => {
7893
const handleChange = (newValue: number | null) => {
@@ -84,21 +99,19 @@ export const FileSizeLimitInput: React.FC<FileSizeLimitInputProps> = ({
8499
return (
85100
<StyledContainer>
86101
<StyledLabel>{label}</StyledLabel>
87-
{description && <StyledDescription>{description}</StyledDescription>}
88102
<StyledInputWrapper>
89-
<Space align="center">
90-
<InputNumber
91-
value={value}
92-
onChange={handleChange}
93-
min={min}
94-
max={max}
95-
step={step}
96-
disabled={disabled}
97-
placeholder="Enter size"
98-
precision={0}
99-
/>
100-
<StyledUnit>MB</StyledUnit>
101-
</Space>
103+
<InputNumber
104+
value={value}
105+
onChange={handleChange}
106+
min={min}
107+
max={max}
108+
step={step}
109+
disabled={disabled}
110+
placeholder={min.toString()}
111+
precision={0}
112+
size="small"
113+
/>
114+
<StyledUnit>MB</StyledUnit>
102115
</StyledInputWrapper>
103116
</StyledContainer>
104117
);

0 commit comments

Comments
 (0)