Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Doc

Manav Rathi3782165155da
diff --git a/web/packages/shared/components/Menu/EnteMenuItem.tsx b/web/packages/shared/components/Menu/EnteMenuItem.tsx
index 15b5878a21..ec95c71bfa 100644
--- a/web/packages/shared/components/Menu/EnteMenuItem.tsx
+++ b/web/packages/shared/components/Menu/EnteMenuItem.tsx
@@ -8,20 +8,58 @@ import {
MenuItem,
Stack,
Typography,
- type ButtonProps,
type TypographyProps,
} from "@mui/material";
import React from "react";
interface EnteMenuItemProps {
- onClick: () => void;
- color?: ButtonProps["color"];
/**
- * - Variant "captioned": The {@link caption}) is shown alongside the main
- * {@link label}, separated from it by a bullet.
+ * Variants:
+ *
+ * - "primary" (default): A menu item with a filled in background color.
+ *
+ * - "captioned": A variant of primary with an associated {@link caption})
+ * shown alongside the main {@link label}, separated from it by a bullet.
+ *
+ * - "toggle": A variant of primary that shows a toggle button (an
+ * {@link EnteSwitch}) at the trailing edge of the menu item.
+ *
+ * - "secondary": A menu item without a fill.
+ *
+ * - "mini": A variant of secondary with a smaller font.
*/
variant?: "primary" | "captioned" | "toggle" | "secondary" | "mini";
+ /**
+ * Color of the menu item.
+ *
+ * Semantically, this is similar to the "color" props for a MUI button,
+ * except we only support two cases for this menu item component:
+ *
+ * - "primary" (default): A menu item that uses "text.base" as the color of
+ * the text (and an approprite background color, if needed, based on the
+ * value of the "variant").
+ *
+ * - "critical": A menu item that uses "critical.main" as the color of the
+ * text. The background fill, if any, will be the same as color "primary".
+ */
+ color?: "primary" | "critical";
fontWeight?: TypographyProps["fontWeight"];
+ /**
+ * Called when the menu item, or the switch it contains, is clicked.
+ *
+ * - For menu items with variant "toggle", this will be called if the user
+ * toggles the value of the {@link EnteSwitch}.
+ *
+ * - For all other variants, this will be called when the user activates
+ * (e.g. clicks) the menu item itself.
+ */
+ onClick: () => void;
+ /**
+ * The state of the toggle associated with the menu item.
+ *
+ * Only valid for menu items with variant "toggle".
+ */
+ checked?: boolean;
startIcon?: React.ReactNode;
endIcon?: React.ReactNode;
/**
@@ -39,8 +77,10 @@ interface EnteMenuItemProps {
* usually makes sense).
*/
caption?: React.ReactNode;
- checked?: boolean;
labelComponent?: React.ReactNode;
+ /**
+ * If true, then the menu item will be disabled.
+ */
disabled?: boolean;
}
@@ -49,14 +89,14 @@ interface EnteMenuItemProps {
*/
export const EnteMenuItem: React.FC<EnteMenuItemProps> = ({
onClick,
+ variant = "primary",
color = "primary",
+ fontWeight = "medium",
+ checked,
startIcon,
endIcon,
label,
caption,
- checked,
- variant = "primary",
- fontWeight = "medium",
labelComponent,
disabled = false,
}) => {