mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
web: introduce "dangerous" variant for menu items
This commit is contained in:
@@ -317,7 +317,7 @@ const AttachmentMenuItems: (
|
||||
{
|
||||
type: "button",
|
||||
key: "permanent-delete",
|
||||
styles: { icon: { color: "red" }, text: { color: "red" } },
|
||||
variant: "dangerous",
|
||||
title: "Delete permanently",
|
||||
icon: DeleteForver.path,
|
||||
onClick: () => Multiselect.deleteAttachments([attachment])
|
||||
|
||||
@@ -501,7 +501,7 @@ const menuItems: (note: any, items?: any[]) => MenuItem[] = (
|
||||
type: "button",
|
||||
key: "movetotrash",
|
||||
title: "Move to trash",
|
||||
styles: { icon: { color: "red" }, text: { color: "red" } },
|
||||
variant: "dangerous",
|
||||
icon: Trash.path,
|
||||
isDisabled:
|
||||
items.length === 1
|
||||
|
||||
@@ -190,7 +190,7 @@ const menuItems: (notebook: any, items?: any[]) => MenuItem[] = (
|
||||
type: "button",
|
||||
key: "movetotrash",
|
||||
title: "Move to trash",
|
||||
styles: { icon: { color: "red" }, text: { color: "red" } },
|
||||
variant: "dangerous",
|
||||
icon: Trash.path,
|
||||
onClick: async () => {
|
||||
const result = await confirm({
|
||||
|
||||
@@ -144,7 +144,7 @@ const menuItems: (
|
||||
type: "button",
|
||||
key: "delete",
|
||||
title: "Delete",
|
||||
styles: { icon: { color: "red" }, text: { color: "red" } },
|
||||
variant: "dangerous",
|
||||
icon: Trash.path,
|
||||
onClick: async () => {
|
||||
confirm({
|
||||
|
||||
@@ -89,7 +89,7 @@ const menuItems: (tag: any, items?: any[]) => MenuItem[] = (
|
||||
{
|
||||
type: "button",
|
||||
key: "delete",
|
||||
styles: { icon: { color: "red" }, text: { color: "red" } },
|
||||
variant: "dangerous",
|
||||
title: "Delete",
|
||||
icon: DeleteForver.path,
|
||||
onClick: async () => {
|
||||
|
||||
@@ -104,7 +104,7 @@ const menuItems: (topic: any, items?: any[]) => MenuItem[] = (
|
||||
key: "delete",
|
||||
title: "Delete",
|
||||
icon: Trash.path,
|
||||
styles: { icon: { color: "red" }, text: { color: "red" } },
|
||||
variant: "dangerous",
|
||||
onClick: async () => {
|
||||
const result = await confirm({
|
||||
title: `Delete ${pluralize(items.length, "topic")}?`,
|
||||
|
||||
@@ -87,7 +87,7 @@ const menuItems: (item: any, items?: any[]) => MenuItem[] = (
|
||||
key: "delete",
|
||||
title: "Delete",
|
||||
icon: DeleteForver.path,
|
||||
styles: { icon: { color: "red" }, text: { color: "red" } },
|
||||
variant: "dangerous",
|
||||
onClick: async () => {
|
||||
if (!(await showMultiPermanentDeleteConfirmation(items.length))) return;
|
||||
const ids = items.map((i) => i.id);
|
||||
|
||||
@@ -41,7 +41,8 @@ export function MenuButton(props: MenuButtonProps) {
|
||||
isChecked,
|
||||
menu,
|
||||
modifier,
|
||||
styles
|
||||
styles,
|
||||
variant = "normal"
|
||||
} = item;
|
||||
const itemRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
@@ -74,8 +75,8 @@ export function MenuButton(props: MenuButtonProps) {
|
||||
<Icon
|
||||
path={icon}
|
||||
size={"medium"}
|
||||
sx={{ mr: 2, ...styles?.icon }}
|
||||
color={styles?.icon?.color as string}
|
||||
sx={{ mr: 2 }}
|
||||
color={variant === "dangerous" ? "icon-error" : "icon"}
|
||||
/>
|
||||
)}
|
||||
<Text
|
||||
@@ -84,6 +85,7 @@ export function MenuButton(props: MenuButtonProps) {
|
||||
sx={{
|
||||
fontSize: "inherit",
|
||||
fontFamily: "inherit",
|
||||
color: variant === "dangerous" ? "paragraph-error" : "paragraph",
|
||||
...styles?.title
|
||||
}}
|
||||
>
|
||||
@@ -95,15 +97,27 @@ export function MenuButton(props: MenuButtonProps) {
|
||||
sx={{ ml: 4 }}
|
||||
data-test-id={`toggle-state-${isChecked ? "on" : "off"}`}
|
||||
>
|
||||
{isChecked && <Icon path={mdiCheck} size={"small"} />}
|
||||
{menu && <Icon path={mdiChevronRight} size={"small"} />}
|
||||
{isChecked && (
|
||||
<Icon
|
||||
path={mdiCheck}
|
||||
size={"small"}
|
||||
color={variant === "dangerous" ? "icon-error" : "icon"}
|
||||
/>
|
||||
)}
|
||||
{menu && (
|
||||
<Icon
|
||||
path={mdiChevronRight}
|
||||
size={"small"}
|
||||
color={variant === "dangerous" ? "icon-error" : "icon"}
|
||||
/>
|
||||
)}
|
||||
{modifier && (
|
||||
<Text
|
||||
as="span"
|
||||
sx={{
|
||||
fontFamily: "body",
|
||||
fontSize: "menu",
|
||||
color: "paragraph"
|
||||
color: "paragraph-secondary"
|
||||
}}
|
||||
>
|
||||
{modifier}
|
||||
|
||||
@@ -45,10 +45,10 @@ export type MenuButtonItem = BaseMenuItem<"button"> & {
|
||||
isChecked?: boolean;
|
||||
modifier?: string;
|
||||
menu?: { title?: string; items: MenuItem[] };
|
||||
variant?: "dangerous" | "normal";
|
||||
|
||||
styles?: {
|
||||
title?: ThemeUICSSObject;
|
||||
icon?: ThemeUICSSObject;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user