Skip to content

Commit

Permalink
fix(mobile): adjust mobile UI (#8719)
Browse files Browse the repository at this point in the history
- fix(mobile): add close button for login, close AF-1581
- fix(mobile): adjust explorer title font, close AF-1575
- fix(mobile): disable user-select globally, close AF-1626
- fix(mobile): usage loading ui in setting, close AF-1422
- fix(mobile): adjust header height, close AF-1574
  • Loading branch information
CatsJuice committed Nov 8, 2024
1 parent add8c56 commit 06591db
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 53 deletions.
61 changes: 30 additions & 31 deletions packages/frontend/component/src/ui/modal/confirm-modal.css.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { bodyEmphasized, bodyRegular } from '@toeverything/theme/typography';
import { style } from '@vanilla-extract/css';

// desktop
Expand Down Expand Up @@ -41,28 +42,25 @@ export const mobileStyles = {
padding: '12px 0 !important',
borderRadius: 22,
}),
description: style({
padding: '11px 22px',
fontSize: 17,
fontWeight: 400,
letterSpacing: -0.43,
lineHeight: '22px',
}),
header: style({
padding: '10px 16px',
marginBottom: '0px !important',
fontSize: 17,
fontWeight: 600,
letterSpacing: -0.43,
lineHeight: '22px',
}),
content: style({
padding: '11px 22px',
fontSize: 17,
fontWeight: 400,
letterSpacing: -0.43,
lineHeight: '22px',
}),
description: style([
bodyRegular,
{
padding: '11px 22px',
},
]),
header: style([
bodyEmphasized,
{
padding: '10px 16px',
marginBottom: '0px !important',
},
]),
content: style([
bodyRegular,
{
padding: '11px 22px',
},
]),
footer: style({
padding: '8px 16px',
display: 'flex',
Expand All @@ -74,13 +72,14 @@ export const mobileStyles = {
},
},
}),
action: style({
width: '100%',
height: 44,
borderRadius: 8,
fontSize: 17,
fontWeight: 400,
letterSpacing: -0.43,
lineHeight: '22px',
}),
action: style([
bodyRegular,
{
width: '100%',
height: 44,
borderRadius: 8,
fontSize: 17,
fontWeight: 400,
},
]),
};
4 changes: 3 additions & 1 deletion packages/frontend/component/src/ui/modal/confirm-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const ConfirmModal = ({
autoFocusConfirm = true,
headerClassName,
descriptionClassName,
contentOptions,
...props
}: ConfirmModalProps) => {
const onConfirmClick = useCallback(() => {
Expand All @@ -50,7 +51,8 @@ export const ConfirmModal = ({
return (
<Modal
contentOptions={{
className: styles.container,
...contentOptions,
className: clsx(styles.container, contentOptions?.className),
onPointerDownOutside: e => {
e.stopPropagation();
onCancel?.();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cssVar } from '@toeverything/theme';
import { title3Regular } from '@toeverything/theme/typography';
import { headlineRegular } from '@toeverything/theme/typography';
import { cssVarV2 } from '@toeverything/theme/v2';
import { style } from '@vanilla-extract/css';

Expand All @@ -21,7 +21,7 @@ export const triggerRoot = style({
borderRadius: 4,
});
export const triggerLabel = style([
title3Regular,
headlineRegular,
{
flexGrow: '0',
display: 'flex',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Skeleton } from '@affine/component';
import {
AuthService,
ServerConfigService,
Expand All @@ -7,7 +8,7 @@ import {
import { useLiveData, useService } from '@toeverything/infra';
import { cssVar } from '@toeverything/theme';
import { cssVarV2 } from '@toeverything/theme/v2';
import { useEffect } from 'react';
import { type ReactNode, useEffect } from 'react';

import { SettingGroup } from '../group';
import * as styles from './style.css';
Expand All @@ -28,31 +29,47 @@ const Progress = ({
percent,
desc,
color,
children,
}: {
name: string;
percent: number;
desc: string;
color: string | null;
name: ReactNode;
desc: ReactNode;
percent?: number;
color?: string | null;
children?: React.ReactNode;
}) => {
return (
<div className={styles.progressRoot}>
<div className={styles.progressInfoRow}>
<span className={styles.progressName}>{name}</span>
<span className={styles.progressDesc}>{desc}</span>
</div>
<div className={styles.progressTrack}>
<div
className={styles.progressBar}
style={{
width: `${percent}%`,
backgroundColor: color ?? cssVarV2('button/primary'),
}}
/>
</div>
{children ?? (
<div className={styles.progressTrack}>
<div
className={styles.progressBar}
style={{
width: `${percent}%`,
backgroundColor: color ?? cssVarV2('button/primary'),
}}
/>
</div>
)}
</div>
);
};

const skeletonProps = { style: { margin: 0 }, animation: 'wave' } as const;
const Loading = () => {
return (
<Progress
name={<Skeleton height={22} width="60" {...skeletonProps} />}
desc={<Skeleton height={16} width="80" {...skeletonProps} />}
>
<Skeleton height={10} {...skeletonProps} />
</Progress>
);
};

const UsagePanel = () => {
const serverConfigService = useService(ServerConfigService);
const serverFeatures = useLiveData(
Expand Down Expand Up @@ -82,7 +99,7 @@ const CloudUsage = () => {

const loading = percent === null;

if (loading) return null;
if (loading) return <Loading />;

return (
<Progress
Expand Down Expand Up @@ -110,7 +127,7 @@ const AiUsage = () => {
}, [copilotQuotaService]);

if (loading || loadError) {
return null;
return <Loading />;
}

if (copilotActionLimit === 'unlimited') {
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/core/src/mobile/styles/mobile.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ globalStyle(':root', {
vars: {
[globalVars.appTabHeight]: BUILD_CONFIG.isIOS ? '49px' : '62px',
},
userSelect: 'none',
});

globalStyle('body', {
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/core/src/mobile/views/all-docs/style.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { style } from '@vanilla-extract/css';

const basicHeader = style({
width: '100%',
height: 56,
height: 44,
});
export const header = style({
width: '100%',
Expand All @@ -25,7 +25,7 @@ export const headerContent = style([
]);

export const tabs = style({
height: 56,
height: 44,
gap: 16,
display: 'flex',
alignItems: 'center',
Expand Down
16 changes: 15 additions & 1 deletion packages/frontend/core/src/mobile/views/sign-in/modal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Modal } from '@affine/component';
import { IconButton, Modal, SafeArea } from '@affine/component';
import { authAtom } from '@affine/core/components/atoms';
import { CloseIcon } from '@blocksuite/icons/rc';
import { cssVarV2 } from '@toeverything/theme/v2';
import { useAtom } from 'jotai';
import { useCallback } from 'react';
Expand Down Expand Up @@ -35,6 +36,19 @@ export const MobileSignInModal = () => {
withoutCloseButton
>
<MobileSignIn onSkip={closeModal} />
<SafeArea
top
style={{ position: 'absolute', top: 0, right: 0, paddingRight: 16 }}
topOffset={8}
>
<IconButton
size="24"
variant="solid"
icon={<CloseIcon />}
style={{ borderRadius: 8, padding: 4 }}
onClick={closeModal}
/>
</SafeArea>
</Modal>
);
};

0 comments on commit 06591db

Please sign in to comment.