一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
53 行
1.3 KiB
TypeScript
53 行
1.3 KiB
TypeScript
import * as React from 'react';
|
|
import { NotificationType } from './types';
|
|
import { _ } from '@joplin/lib/locale';
|
|
|
|
interface Props {
|
|
children: React.ReactNode;
|
|
key: string;
|
|
type: NotificationType;
|
|
dismissing: boolean;
|
|
popup: boolean;
|
|
}
|
|
|
|
const NotificationItem: React.FC<Props> = props => {
|
|
const [iconClassName, iconLabel] = (() => {
|
|
if (props.type === NotificationType.Success) {
|
|
return ['fas fa-check', _('Success')];
|
|
}
|
|
if (props.type === NotificationType.Error) {
|
|
return ['fas fa-times', _('Error')];
|
|
}
|
|
if (props.type === NotificationType.Info) {
|
|
return ['fas fa-info', _('Info')];
|
|
}
|
|
return ['', ''];
|
|
})();
|
|
|
|
const containerModifier = (() => {
|
|
if (props.type === NotificationType.Success) return '-success';
|
|
if (props.type === NotificationType.Error) return '-error';
|
|
if (props.type === NotificationType.Info) return '-info';
|
|
return '';
|
|
})();
|
|
|
|
const icon = <i
|
|
role='img'
|
|
aria-label={iconLabel}
|
|
className={`icon ${iconClassName}`}
|
|
/>;
|
|
|
|
return <li
|
|
role={props.popup ? 'alert' : undefined}
|
|
className={`popup-notification-item ${containerModifier} ${props.dismissing ? '-dismissing' : ''}`}
|
|
>
|
|
{iconClassName ? icon : null}
|
|
<div className='ripple'/>
|
|
<div className='content'>
|
|
{props.children}
|
|
</div>
|
|
</li>;
|
|
};
|
|
|
|
export default NotificationItem;
|