mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 03:49:56 +08:00
refactor(core): move actions to footer of notification card (#11894)
This PR move all actions button to the footer of `NotificationCard`. There are some example as following: ### No Changes    ### Changes ### Before  #### After 
This commit is contained in:
@@ -364,13 +364,16 @@ export function notifyDocCreated(std: BlockStdScope, doc: Store) {
|
||||
message: 'You can click undo to recovery block content',
|
||||
accent: 'info',
|
||||
duration: 10 * 1000,
|
||||
action: {
|
||||
label: 'Undo',
|
||||
onClick: () => {
|
||||
doc.undo();
|
||||
clear();
|
||||
actions: [
|
||||
{
|
||||
key: 'undo',
|
||||
label: 'Undo',
|
||||
onClick: () => {
|
||||
doc.undo();
|
||||
clear();
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
abort: abortController.signal,
|
||||
onClose: clear,
|
||||
});
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { cssVar } from '@toeverything/theme';
|
||||
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
import { style } from '@vanilla-extract/css';
|
||||
|
||||
export const viewInPageNotifyFooter = style({
|
||||
display: 'flex',
|
||||
justifyContent: 'flex-end',
|
||||
gap: '12px',
|
||||
});
|
||||
|
||||
export const viewInPageNotifyFooterButton = style({
|
||||
padding: '0px 6px',
|
||||
borderRadius: '4px',
|
||||
color: cssVarV2('text/primary'),
|
||||
|
||||
fontSize: cssVar('fontSm'),
|
||||
lineHeight: '22px',
|
||||
fontWeight: '500',
|
||||
textAlign: 'center',
|
||||
|
||||
':hover': {
|
||||
background: cssVarV2('layer/background/hoverOverlay'),
|
||||
},
|
||||
});
|
||||
@@ -41,7 +41,6 @@ import { html } from 'lit';
|
||||
import { keyed } from 'lit/directives/keyed.js';
|
||||
|
||||
import { changeNoteDisplayMode } from '../commands';
|
||||
import * as styles from '../components/view-in-page-notify.css';
|
||||
import { NoteConfigExtension } from '../config';
|
||||
|
||||
const trackBaseProps = {
|
||||
@@ -550,22 +549,18 @@ function setDisplayMode(
|
||||
message: `${data.message} Find it in the TOC for quick navigation.`,
|
||||
accent: 'success',
|
||||
duration: 5 * 1000,
|
||||
footer: html`<div class=${styles.viewInPageNotifyFooter}>
|
||||
<button
|
||||
class=${styles.viewInPageNotifyFooterButton}
|
||||
@click=${undo}
|
||||
data-testid="undo-display-in-page"
|
||||
>
|
||||
Undo
|
||||
</button>
|
||||
<button
|
||||
class=${styles.viewInPageNotifyFooterButton}
|
||||
@click=${viewInToc}
|
||||
data-testid="view-in-toc"
|
||||
>
|
||||
View in Toc
|
||||
</button>
|
||||
</div>`,
|
||||
actions: [
|
||||
{
|
||||
key: 'undo-display-in-page',
|
||||
label: 'Undo',
|
||||
onClick: () => undo(),
|
||||
},
|
||||
{
|
||||
key: 'view-in-toc',
|
||||
label: 'View in Toc',
|
||||
onClick: () => viewInToc(),
|
||||
},
|
||||
],
|
||||
abort: abortController.signal,
|
||||
onClose: () => {
|
||||
clear();
|
||||
|
||||
@@ -35,13 +35,16 @@ function notify(std: BlockStdScope, title: string, message: string) {
|
||||
message,
|
||||
accent: 'info',
|
||||
duration: 10 * 1000,
|
||||
action: {
|
||||
label: 'Undo',
|
||||
onClick: () => {
|
||||
doc.undo();
|
||||
clear();
|
||||
actions: [
|
||||
{
|
||||
key: 'undo',
|
||||
label: 'Undo',
|
||||
onClick: () => {
|
||||
doc.undo();
|
||||
clear();
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
abort: abortController.signal,
|
||||
onClose: clear,
|
||||
});
|
||||
|
||||
@@ -29,14 +29,14 @@ export interface NotificationService {
|
||||
notify(options: {
|
||||
title: string | TemplateResult;
|
||||
message?: string | TemplateResult;
|
||||
footer?: string | TemplateResult;
|
||||
accent?: 'info' | 'success' | 'warning' | 'error';
|
||||
duration?: number; // unit ms, give 0 to disable auto dismiss
|
||||
abort?: AbortSignal;
|
||||
action?: {
|
||||
actions?: {
|
||||
key: string;
|
||||
label: string | TemplateResult;
|
||||
onClick: () => void;
|
||||
};
|
||||
}[];
|
||||
onClose: () => void;
|
||||
}): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user