Skip to content

Commit 09788b0

Browse files
committed
Fix mobile view.
1 parent 20d0827 commit 09788b0

9 files changed

Lines changed: 218 additions & 148 deletions

File tree

fastadmin/static/index.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fastadmin/static/index.min.js

Lines changed: 128 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/components/crud-container/index.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ export const CrudContainer: React.FC<ICrudContainer> = ({
135135
<Header
136136
style={{
137137
background: colorPrimary,
138-
paddingInline: 24,
139-
height: 56,
140-
lineHeight: "56px",
138+
paddingInline: isMobile ? 0 : 20,
139+
height: isMobile ? 48 : 56,
140+
lineHeight: isMobile ? "48px" : "56px",
141141
boxShadow: "0 1px 4px rgba(0, 0, 0, 0.08)",
142142
}}
143143
>
144144
<Row justify="space-between" align="middle">
145145
<Col>
146-
<Space size="middle">
146+
<Space size={isMobile ? 8 : 16}>
147147
{isMobile && (
148148
<Menu
149149
style={{ background: "transparent", minWidth: 0 }}
@@ -196,7 +196,7 @@ export const CrudContainer: React.FC<ICrudContainer> = ({
196196
</Space>
197197
</Col>
198198
<Col>
199-
<Space size="middle">
199+
<Space size={isMobile ? 8 : 16}>
200200
{!isMobile && (
201201
<span
202202
style={{
@@ -273,11 +273,16 @@ export const CrudContainer: React.FC<ICrudContainer> = ({
273273
/>
274274
</Sider>
275275
)}
276-
<Layout style={{ padding: 24, minHeight: "calc(100vh - 56px)" }}>
276+
<Layout
277+
style={{
278+
padding: isMobile ? 8 : 24,
279+
minHeight: "calc(100vh - 56px)",
280+
}}
281+
>
277282
<Row
278283
justify="space-between"
279284
align="middle"
280-
style={{ marginBottom: 16 }}
285+
style={{ marginBottom: isMobile ? 8 : 16 }}
281286
>
282287
<Col>{breadcrumbs}</Col>
283288
{viewOnSite && (
@@ -305,9 +310,11 @@ export const CrudContainer: React.FC<ICrudContainer> = ({
305310
</Row>
306311
}
307312
style={{
308-
marginTop: 0,
309-
borderRadius: 8,
310-
boxShadow: "0 1px 4px rgba(0, 0, 0, 0.06)",
313+
marginTop: isMobile ? 4 : 0,
314+
borderRadius: isMobile ? 6 : 8,
315+
boxShadow: isMobile
316+
? "0 1px 3px rgba(0, 0, 0, 0.05)"
317+
: "0 1px 4px rgba(0, 0, 0, 0.06)",
311318
}}
312319
>
313320
<Skeleton loading={isLoading} active={true}>

frontend/src/components/dashboard-action-widget/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ export const DashboardActionWidget: React.FC<DashboardActionWidgetProps> = ({
249249
</Row>
250250
<pre
251251
style={{
252-
marginTop: 16,
252+
marginTop: 12,
253253
maxHeight: 240,
254254
overflow: "auto",
255255
background: "#fafafa",
256-
padding: 12,
256+
padding: 8,
257257
borderRadius: 4,
258258
border: "1px solid #f0f0f0",
259259
}}

frontend/src/components/form-container/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { InlineWidget } from "@/components/inline-widget";
77
import { getTitleFromFieldName, getTitleFromModel } from "@/helpers/title";
88
import { isJson, isSlug } from "@/helpers/transform";
99
import { getWidgetCls } from "@/helpers/widgets";
10+
import { useIsMobile } from "@/hooks/useIsMobile";
1011
import {
1112
EFieldWidgetType,
1213
type IAddConfigurationField,
@@ -41,6 +42,7 @@ export const FormContainer: React.FC<IFormContainer> = ({
4142
initialValues,
4243
}) => {
4344
const { t: _t } = useTranslation("FormContainer");
45+
const isMobile = useIsMobile();
4446

4547
const [activeKey, setActiveKey] = useState<string[]>(
4648
(modelConfiguration?.fieldsets || [])
@@ -285,7 +287,7 @@ export const FormContainer: React.FC<IFormContainer> = ({
285287
<Divider />
286288
</>
287289
)}
288-
<Row gutter={[32, 32]}>
290+
<Row gutter={isMobile ? [16, 16] : [32, 32]}>
289291
<Col
290292
xs={24}
291293
xl={mode === "inline-add" || mode === "inline-change" ? 24 : 12}

frontend/src/components/sign-in-container/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Helmet } from "react-helmet-async";
55
import { useNavigate } from "react-router-dom";
66

77
import { ROUTES } from "@/constants/routes";
8+
import { useIsMobile } from "@/hooks/useIsMobile";
89
import { SignInUserContext } from "@/providers/SignInUserProvider";
910

1011
interface ISignInContainer {
@@ -18,6 +19,7 @@ export const SignInContainer: React.FC<ISignInContainer> = ({
1819
}) => {
1920
const { signedIn } = useContext(SignInUserContext);
2021
const navigate = useNavigate();
22+
const isMobile = useIsMobile();
2123

2224
useEffect(() => {
2325
if (signedIn) {
@@ -31,7 +33,7 @@ export const SignInContainer: React.FC<ISignInContainer> = ({
3133
minHeight: "100vh",
3234
background:
3335
"linear-gradient(160deg, #f0f5ff 0%, #f5f5f5 50%, #e8f4f8 100%)",
34-
padding: 24,
36+
padding: isMobile ? 16 : 24,
3537
}}
3638
>
3739
<Helmet defaultTitle={title}>

frontend/src/containers/list/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,13 @@ export const List: React.FC = () => {
218218
}
219219
viewOnSite={modelConfiguration?.view_on_site}
220220
headerActions={
221-
<Row style={{ marginTop: 10, marginBottom: 10 }} gutter={[8, 8]}>
221+
<Row
222+
style={{
223+
marginTop: isMobile ? 4 : 10,
224+
marginBottom: isMobile ? 8 : 10,
225+
}}
226+
gutter={[8, 8]}
227+
>
222228
{(modelConfiguration?.actions || []).length > 0 &&
223229
modelConfiguration?.actions_on_top && (
224230
<Col>

frontend/src/containers/sign-in/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { SignInContainer } from "@/components/sign-in-container";
88
import { postFetcher } from "@/fetchers/fetchers";
99
import { handleError } from "@/helpers/forms";
1010
import { getTitleFromFieldName } from "@/helpers/title";
11+
import { useIsMobile } from "@/hooks/useIsMobile";
1112
import { ConfigurationContext } from "@/providers/ConfigurationProvider";
1213
import { SignInUserContext } from "@/providers/SignInUserProvider";
1314

@@ -18,6 +19,7 @@ export const SignIn: React.FC = () => {
1819
} = theme.useToken();
1920
const { configuration } = useContext(ConfigurationContext);
2021
const { signedInUserRefetch } = useContext(SignInUserContext);
22+
const isMobile = useIsMobile();
2123
const { t: _t } = useTranslation("SignIn");
2224

2325
const { mutate: mutateSignIn, isPending: loadingSignIn } = useMutation({
@@ -39,9 +41,11 @@ export const SignIn: React.FC = () => {
3941
<Card
4042
style={{
4143
maxWidth: 420,
42-
margin: "0 auto",
44+
margin: isMobile ? "0 auto" : "24px auto",
4345
borderRadius: 12,
44-
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.08)",
46+
boxShadow: isMobile
47+
? "0 4px 16px rgba(0, 0, 0, 0.06)"
48+
: "0 8px 24px rgba(0, 0, 0, 0.08)",
4549
border: "none",
4650
}}
4751
>
@@ -50,8 +54,8 @@ export const SignIn: React.FC = () => {
5054
<Space
5155
direction="vertical"
5256
align="center"
53-
size="middle"
54-
style={{ width: "100%", marginBottom: 32 }}
57+
size="small"
58+
style={{ width: "100%", marginBottom: isMobile ? 20 : 32 }}
5559
>
5660
<Image
5761
src={`${window.SERVER_DOMAIN ?? ""}${configuration.site_sign_in_logo ?? ""}`}

frontend/src/index.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,52 @@ code {
150150
border-bottom-left-radius: var(--admin-radius-sm);
151151
border-bottom-right-radius: var(--admin-radius-sm);
152152
}
153+
154+
/* Mobile-first spacing adjustments */
155+
@media (max-width: 768px) {
156+
body {
157+
padding: 0;
158+
}
159+
160+
/* Reduce global layout padding on small screens */
161+
.ant-layout {
162+
padding: var(--admin-spacing-xs) !important;
163+
}
164+
165+
.ant-layout-content {
166+
padding: var(--admin-spacing-xs) !important;
167+
}
168+
169+
/* Tighter card padding and radius for mobile */
170+
.ant-card {
171+
border-radius: var(--admin-radius-sm);
172+
}
173+
174+
.ant-card-head {
175+
padding-inline: var(--admin-spacing-sm);
176+
padding-block: var(--admin-spacing-xs);
177+
}
178+
179+
.ant-card-body {
180+
padding: var(--admin-spacing-sm);
181+
}
182+
183+
/* Tighter form spacing for mobile ergonomics */
184+
.ant-form-vertical .ant-form-item {
185+
margin-bottom: 12px;
186+
}
187+
188+
.ant-form-item-label > label {
189+
margin-bottom: 4px;
190+
}
191+
192+
/* Reduce table density slightly on mobile */
193+
.ant-table-wrapper .ant-table {
194+
border-radius: var(--admin-radius-sm);
195+
}
196+
197+
.ant-table-wrapper .ant-table-thead > tr > th,
198+
.ant-table-wrapper .ant-table-tbody > tr > td {
199+
padding: 8px 12px;
200+
}
201+
}

0 commit comments

Comments
 (0)