mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-08 15:43:10 +08:00
feat(desktop): add compact modal size
This commit is contained in:
@@ -162,6 +162,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actionBody {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.actionDescription {
|
.actionDescription {
|
||||||
color: var(--vscode-descriptionForeground);
|
color: var(--vscode-descriptionForeground);
|
||||||
font-size: type.$font-size-xs;
|
font-size: type.$font-size-xs;
|
||||||
|
|||||||
@@ -420,12 +420,13 @@ function ResourceActionModal({ action, cardAction, result, busy, error, onClose,
|
|||||||
const cardActions = cardAction ? [cardAction] : [];
|
const cardActions = cardAction ? [cardAction] : [];
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Modal open title={title} busy={busy} onClose={onClose} submitLabel={t("关闭")} onSubmit={onClose}>
|
<Modal compact open title={title} busy={busy} onClose={onClose} submitLabel={t("关闭")} onSubmit={onClose}>
|
||||||
{result?.description && <span className={styles.actionDescription}>{pluginText(result.description, locale)}</span>}
|
<div className={styles.actionBody}>
|
||||||
{busy && <span className={styles.empty}>{t("正在加载…")}</span>}
|
{result?.description && <span className={styles.actionDescription}>{pluginText(result.description, locale)}</span>}
|
||||||
{error && <span className={styles.error} role="alert">{error}</span>}
|
{busy && <span className={styles.empty}>{t("正在加载…")}</span>}
|
||||||
{!busy && !error && result && result.cards.length === 0 && <span className={styles.empty}>{t("没有可用的重置卡。")}</span>}
|
{error && <span className={styles.error} role="alert">{error}</span>}
|
||||||
{!busy && !error && result && <div className={styles.actionCardList}>
|
{!busy && !error && result && result.cards.length === 0 && <span className={styles.empty}>{t("没有可用的重置卡。")}</span>}
|
||||||
|
{!busy && !error && result && <div className={styles.actionCardList}>
|
||||||
{result.cards.map((card) => <Card key={card.id} className={styles.actionCard}>
|
{result.cards.map((card) => <Card key={card.id} className={styles.actionCard}>
|
||||||
<div className={styles.actionCardMain}>
|
<div className={styles.actionCardMain}>
|
||||||
<strong>{pluginText(card.title, locale)}</strong>
|
<strong>{pluginText(card.title, locale)}</strong>
|
||||||
@@ -444,6 +445,7 @@ function ResourceActionModal({ action, cardAction, result, busy, error, onClose,
|
|||||||
</div>}
|
</div>}
|
||||||
</Card>)}
|
</Card>)}
|
||||||
</div>}
|
</div>}
|
||||||
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
{pendingCard && cardAction && <ConfirmDialog
|
{pendingCard && cardAction && <ConfirmDialog
|
||||||
open
|
open
|
||||||
|
|||||||
@@ -54,6 +54,10 @@
|
|||||||
width: min(1080px, calc(100vw - 48px));
|
width: min(1080px, calc(100vw - 48px));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.compact {
|
||||||
|
width: min(560px, calc(100vw - 48px));
|
||||||
|
}
|
||||||
|
|
||||||
.fullHeight {
|
.fullHeight {
|
||||||
height: calc(100vh - var(--window-header-height) - 24px);
|
height: calc(100vh - var(--window-header-height) - 24px);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ type ModalProps = {
|
|||||||
banner?: ReactNode;
|
banner?: ReactNode;
|
||||||
busy?: boolean;
|
busy?: boolean;
|
||||||
wide?: boolean;
|
wide?: boolean;
|
||||||
|
compact?: boolean;
|
||||||
fullHeight?: boolean;
|
fullHeight?: boolean;
|
||||||
role?: "dialog" | "alertdialog";
|
role?: "dialog" | "alertdialog";
|
||||||
ariaDescribedBy?: string;
|
ariaDescribedBy?: string;
|
||||||
@@ -38,7 +39,7 @@ function focusableElements(root: HTMLElement) {
|
|||||||
.filter((element) => element.getClientRects().length > 0);
|
.filter((element) => element.getClientRects().length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Modal({ id, open, title, children, banner, busy, wide, fullHeight, role = "dialog", ariaDescribedBy, initialFocus = "first", onClose, onSubmit, secondaryAction, closeLabel = t("取消"), submitLabel = t("保存"), submitDisabled = false }: ModalProps) {
|
export function Modal({ id, open, title, children, banner, busy, wide, compact, fullHeight, role = "dialog", ariaDescribedBy, initialFocus = "first", onClose, onSubmit, secondaryAction, closeLabel = t("取消"), submitLabel = t("保存"), submitDisabled = false }: ModalProps) {
|
||||||
const dialog = useRef<HTMLDivElement>(null);
|
const dialog = useRef<HTMLDivElement>(null);
|
||||||
const submitButton = useRef<HTMLButtonElement>(null);
|
const submitButton = useRef<HTMLButtonElement>(null);
|
||||||
const closeRef = useRef(onClose);
|
const closeRef = useRef(onClose);
|
||||||
@@ -89,7 +90,7 @@ export function Modal({ id, open, title, children, banner, busy, wide, fullHeigh
|
|||||||
if (!open) return null;
|
if (!open) return null;
|
||||||
return createPortal(<div className={styles.mask}>
|
return createPortal(<div className={styles.mask}>
|
||||||
<div className={styles.dragLayer} data-tauri-drag-region aria-hidden="true" />
|
<div className={styles.dragLayer} data-tauri-drag-region aria-hidden="true" />
|
||||||
<div id={id} ref={dialog} className={[styles.dialog, wide && styles.wide, fullHeight && styles.fullHeight].filter(Boolean).join(" ")} role={role} aria-modal="true" aria-labelledby={titleId} aria-describedby={ariaDescribedBy} tabIndex={-1}>
|
<div id={id} ref={dialog} className={[styles.dialog, wide && styles.wide, compact && styles.compact, fullHeight && styles.fullHeight].filter(Boolean).join(" ")} role={role} aria-modal="true" aria-labelledby={titleId} aria-describedby={ariaDescribedBy} tabIndex={-1}>
|
||||||
<header id={titleId}>{title}</header>
|
<header id={titleId}>{title}</header>
|
||||||
{banner && <div className={styles.banner}>{banner}</div>}
|
{banner && <div className={styles.banner}>{banner}</div>}
|
||||||
<ScrollableContent alwaysShowVertical className={styles.body} contentClassName={styles.bodyContent}>{children}</ScrollableContent>
|
<ScrollableContent alwaysShowVertical className={styles.body} contentClassName={styles.bodyContent}>{children}</ScrollableContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user