feat(core): add indicator for general ai onboarding dialog (#6687)

This commit is contained in:
CatsJuice 2024-04-25 02:09:52 +00:00
parent 21cbef4e20
commit 2a2b1cea28
No known key found for this signature in database
GPG Key ID: 1C1E76924FAFDDE4
3 changed files with 78 additions and 36 deletions

View File

@ -98,11 +98,21 @@ export const footer = style({
gap: 12, gap: 12,
display: 'flex', display: 'flex',
justifyContent: 'space-between', justifyContent: 'space-between',
selectors: { alignItems: 'center',
'&[data-is-last="true"], &[data-is-first="true"]': { });
justifyContent: 'flex-end', export const actionAndIndicator = style({
}, display: 'flex',
}, gap: 16,
alignItems: 'center',
fontWeight: 500,
fontSize: cssVar('fontXs'),
lineHeight: '20px',
color: cssVar('textSecondaryColor'),
});
export const subscribeActions = style({
display: 'flex',
gap: 12,
alignItems: 'center',
}); });
export const baseActionButton = style({ export const baseActionButton = style({
fontSize: cssVar('fontBase'), fontSize: cssVar('fontBase'),
@ -112,3 +122,9 @@ export const baseActionButton = style({
}, },
}, },
}); });
export const transparentActionButton = style([
baseActionButton,
{
backgroundColor: 'transparent',
},
]);

View File

@ -1,4 +1,4 @@
import { Button, Modal } from '@affine/component'; import { Button, IconButton, Modal } from '@affine/component';
import { openSettingModalAtom } from '@affine/core/atoms'; import { openSettingModalAtom } from '@affine/core/atoms';
import { useBlurRoot } from '@affine/core/hooks/use-blur-root'; import { useBlurRoot } from '@affine/core/hooks/use-blur-root';
import { SubscriptionService } from '@affine/core/modules/cloud'; import { SubscriptionService } from '@affine/core/modules/cloud';
@ -90,6 +90,9 @@ export const AIOnboardingGeneral = ({
const isFirst = index === 0; const isFirst = index === 0;
const isLast = index === list.length - 1; const isLast = index === list.length - 1;
const remindLater = useCallback(() => {
showAIOnboardingGeneral$.next(false);
}, []);
const closeAndDismiss = useCallback(() => { const closeAndDismiss = useCallback(() => {
showAIOnboardingGeneral$.next(false); showAIOnboardingGeneral$.next(false);
onDismiss(); onDismiss();
@ -216,7 +219,15 @@ export const AIOnboardingGeneral = ({
data-is-first={isFirst} data-is-first={isFirst}
> >
{isLast ? ( {isLast ? (
aiSubscription ? ( <>
<IconButton
size="default"
icon={<ArrowLeftSmallIcon width={20} height={20} />}
onClick={onPrev}
type="plain"
className={styles.baseActionButton}
/>
{aiSubscription ? (
<Button <Button
className={styles.baseActionButton} className={styles.baseActionButton}
size="large" size="large"
@ -226,7 +237,7 @@ export const AIOnboardingGeneral = ({
{t['com.affine.ai-onboarding.general.get-started']()} {t['com.affine.ai-onboarding.general.get-started']()}
</Button> </Button>
) : ( ) : (
<> <div className={styles.subscribeActions}>
<Button <Button
className={styles.baseActionButton} className={styles.baseActionButton}
size="large" size="large"
@ -242,11 +253,21 @@ export const AIOnboardingGeneral = ({
> >
{t['com.affine.ai-onboarding.general.purchase']()} {t['com.affine.ai-onboarding.general.purchase']()}
</Button> </Button>
</div>
)}
</> </>
)
) : ( ) : (
<> <>
{isFirst ? null : ( {isFirst ? (
<Button
className={styles.transparentActionButton}
onClick={remindLater}
size="large"
type="default"
>
{t['com.affine.ai-onboarding.general.skip']()}
</Button>
) : (
<Button <Button
icon={<ArrowLeftSmallIcon />} icon={<ArrowLeftSmallIcon />}
className={styles.baseActionButton} className={styles.baseActionButton}
@ -257,6 +278,10 @@ export const AIOnboardingGeneral = ({
{t['com.affine.ai-onboarding.general.prev']()} {t['com.affine.ai-onboarding.general.prev']()}
</Button> </Button>
)} )}
<div className={styles.actionAndIndicator}>
<div>
{index + 1} / {list.length}
</div>
<Button <Button
className={styles.baseActionButton} className={styles.baseActionButton}
size="large" size="large"
@ -265,6 +290,7 @@ export const AIOnboardingGeneral = ({
> >
{t['com.affine.ai-onboarding.general.next']()} {t['com.affine.ai-onboarding.general.next']()}
</Button> </Button>
</div>
</> </>
)} )}
</footer> </footer>

View File

@ -1294,7 +1294,7 @@
"com.affine.ai-onboarding.general.4.description": "From concept to completion, turn ideas into reality.", "com.affine.ai-onboarding.general.4.description": "From concept to completion, turn ideas into reality.",
"com.affine.ai-onboarding.general.5.title": "AFFiNE AI is ready", "com.affine.ai-onboarding.general.5.title": "AFFiNE AI is ready",
"com.affine.ai-onboarding.general.5.description": "Go to <a>{{link}}</a> for learn more details about AFFiNE AI.", "com.affine.ai-onboarding.general.5.description": "Go to <a>{{link}}</a> for learn more details about AFFiNE AI.",
"com.affine.ai-onboarding.general.skip": "Alert me later", "com.affine.ai-onboarding.general.skip": "Remind me Later",
"com.affine.ai-onboarding.general.next": "Next", "com.affine.ai-onboarding.general.next": "Next",
"com.affine.ai-onboarding.general.prev": "Back", "com.affine.ai-onboarding.general.prev": "Back",
"com.affine.ai-onboarding.general.try-for-free": "Try for Free", "com.affine.ai-onboarding.general.try-for-free": "Try for Free",