fix(mobile): progress styles (#9001)

fix AF-1875, fix AF-1878, fix AF-1879
This commit is contained in:
pengx17
2024-12-04 06:56:33 +00:00
parent 82d133d64d
commit e4f94c7e3f
8 changed files with 64 additions and 112 deletions
@@ -63,10 +63,16 @@ export const DocPropertyIconSelector = ({
return (
<Menu
items={
<IconsSelectorPanel
selectedIcon={propertyInfo.icon}
onSelectedChange={onSelectedChange}
/>
<div
style={{
padding: BUILD_CONFIG.isMobileEdition ? '0 20px' : undefined,
}}
>
<IconsSelectorPanel
selectedIcon={propertyInfo.icon}
onSelectedChange={onSelectedChange}
/>
</div>
}
>
<div className={styles.iconSelectorButton}>
@@ -1,6 +1,5 @@
import { PropertyValue } from '@affine/component';
import { useI18n } from '@affine/i18n';
import { NumberIcon } from '@blocksuite/icons/rc';
import {
type ChangeEventHandler,
useCallback,
@@ -8,11 +7,10 @@ import {
useState,
} from 'react';
import { ConfigModal } from '../../mobile';
import * as styles from './number.css';
import type { PropertyValueProps } from './types';
const DesktopNumberValue = ({ value, onChange }: PropertyValueProps) => {
export const NumberValue = ({ value, onChange }: PropertyValueProps) => {
const parsedValue = isNaN(Number(value)) ? null : value;
const [tempValue, setTempValue] = useState(parsedValue);
const handleBlur = useCallback(
@@ -51,80 +49,3 @@ const DesktopNumberValue = ({ value, onChange }: PropertyValueProps) => {
</PropertyValue>
);
};
const MobileNumberValue = ({
value,
onChange,
propertyInfo,
}: PropertyValueProps) => {
const parsedValue = isNaN(Number(value)) ? null : value;
const [tempValue, setTempValue] = useState(parsedValue);
const handleBlur = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
onChange(e.target.value.trim());
},
[onChange]
);
const handleOnChange: ChangeEventHandler<HTMLInputElement> = useCallback(
e => {
setTempValue(e.target.value.trim());
},
[]
);
const t = useI18n();
useEffect(() => {
setTempValue(parsedValue);
}, [parsedValue]);
const [open, setOpen] = useState(false);
const onClose = useCallback(() => {
setOpen(false);
onChange(tempValue);
}, [onChange, tempValue]);
return (
<>
<PropertyValue
className={styles.numberPropertyValueContainer}
isEmpty={!parsedValue}
onClick={() => {
setOpen(true);
}}
>
<div className={styles.mobileNumberPropertyValueInput}>
{value ||
t['com.affine.page-properties.property-value-placeholder']()}
</div>
</PropertyValue>
<ConfigModal
open={open}
variant="popup"
onDone={onClose}
onOpenChange={setOpen}
title={
<>
<NumberIcon className={styles.numberIcon} />
{propertyInfo?.name}
</>
}
>
<input
className={styles.mobileNumberPropertyValueInput}
type="number"
inputMode="decimal"
value={tempValue || ''}
onChange={handleOnChange}
onBlur={handleBlur}
data-empty={!tempValue}
placeholder={t[
'com.affine.page-properties.property-value-placeholder'
]()}
/>
</ConfigModal>
</>
);
};
export const NumberValue = BUILD_CONFIG.isMobileEdition
? MobileNumberValue
: DesktopNumberValue;
@@ -83,13 +83,15 @@ export const ConfigModal = ({
)}
{children}
{variant === 'popup' && onDone ? (
<Button
variant="primary"
className={styles.bottomDoneButton}
onClick={onDone}
>
{t['Done']()}
</Button>
<div className={styles.bottomDoneButtonContainer}>
<Button
variant="primary"
className={styles.bottomDoneButton}
onClick={onDone}
>
{t['Done']()}
</Button>
</div>
) : null}
</div>
</Modal>
@@ -11,7 +11,9 @@ export const pageModalContent = style({
backgroundColor: cssVarV2('layer/background/secondary'),
});
export const popupModalContent = style({});
export const popupModalContent = style({
padding: '12px',
});
export const pageTitle = style([
bodyEmphasized,
@@ -30,6 +32,8 @@ export const popupTitle = style([
alignItems: 'center',
gap: 8,
color: cssVarV2('text/primary'),
padding: '0 8px',
height: 44,
},
]);
@@ -43,7 +47,7 @@ export const pageContent = style({
export const popupContent = style({
display: 'flex',
flexDirection: 'column',
gap: 16,
gap: 24,
});
export const doneButton = style([
@@ -53,8 +57,15 @@ export const doneButton = style([
},
]);
export const bottomDoneButtonContainer = style({
padding: '4px',
});
export const bottomDoneButton = style({
width: '100%',
height: 44,
fontSize: 17,
alignSelf: 'center',
});
export const group = style({