mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 05:25:53 +08:00
3d855647c7
## Button
- Remove props withoutHoverStyle
refactor hover impl with independent layer, so that hover-color won't affect the background even if is overridden outside
- Update `type` (renamed to `variant`):
- remove `processing` and `warning`
- rename `default` with `secondary`
- Remove `shape` props
- Remove `icon` and `iconPosition`, replaced with `prefix: ReactNode` and `suffix: ReactNode`
- Integrate tooltip for more convenient usage
- New Storybook document
- Focus style
## IconButton
- A Wrapper base on `<Button />`
- Override Button size and variant
- size: `'12' | '14' | '16' | '20' | '24' | number`
These presets size are referenced from the design system.
- variant: `'plain' | 'solid' | 'danger' | 'custom'`
- Inset icon via Button 's prefix
## Fix
- fix some button related issues
- close AF-1159, AF-1160, AF-1161, AF-1162, AF-1163, AF-1158, AF-1157
## Storybook

73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
import { useI18n } from '@affine/i18n';
|
|
import { useCallback, useState } from 'react';
|
|
|
|
import { Button } from '../../ui/button';
|
|
import { AuthInput } from './auth-input';
|
|
import { AuthPageContainer } from './auth-page-container';
|
|
import * as styles from './share.css';
|
|
import { emailRegex } from './utils';
|
|
|
|
export const ChangeEmailPage = ({
|
|
onChangeEmail: propsOnChangeEmail,
|
|
}: {
|
|
onChangeEmail: (email: string) => Promise<boolean>;
|
|
onOpenAffine: () => void;
|
|
}) => {
|
|
const t = useI18n();
|
|
const [hasSetUp, setHasSetUp] = useState(false);
|
|
const [email, setEmail] = useState('');
|
|
const [isValidEmail, setIsValidEmail] = useState(true);
|
|
const [loading, setLoading] = useState(false);
|
|
const onContinue = useCallback(
|
|
() =>
|
|
void (async () => {
|
|
if (!emailRegex.test(email)) {
|
|
setIsValidEmail(false);
|
|
return;
|
|
}
|
|
setIsValidEmail(true);
|
|
setLoading(true);
|
|
|
|
const setup = await propsOnChangeEmail(email);
|
|
|
|
setLoading(false);
|
|
setHasSetUp(setup);
|
|
})(),
|
|
[email, propsOnChangeEmail]
|
|
);
|
|
const onEmailChange = useCallback((value: string) => {
|
|
setEmail(value);
|
|
}, []);
|
|
return (
|
|
<AuthPageContainer
|
|
title={t['com.affine.auth.change.email.page.title']()}
|
|
subtitle={t['com.affine.auth.change.email.page.subtitle']()}
|
|
>
|
|
<>
|
|
<AuthInput
|
|
className={styles.input}
|
|
label={t['com.affine.settings.email']()}
|
|
placeholder={t['com.affine.auth.sign.email.placeholder']()}
|
|
value={email}
|
|
onChange={onEmailChange}
|
|
error={!isValidEmail}
|
|
errorHint={
|
|
isValidEmail ? '' : t['com.affine.auth.sign.email.error']()
|
|
}
|
|
onEnter={onContinue}
|
|
disabled={hasSetUp}
|
|
/>
|
|
<Button
|
|
variant="primary"
|
|
size="large"
|
|
onClick={onContinue}
|
|
loading={loading}
|
|
disabled={hasSetUp}
|
|
>
|
|
{t['com.affine.auth.set.email.save']()}
|
|
</Button>
|
|
</>
|
|
</AuthPageContainer>
|
|
);
|
|
};
|