Skip to content

armgit / ente

Public Imported from GitHub
0

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

Trim

Manav Rathib0318e4ec3ec
diff --git a/web/packages/new/photos/components/DropdownInput.tsx b/web/packages/new/photos/components/DropdownInput.tsx
index 423a250852..3f101a341a 100644
--- a/web/packages/new/photos/components/DropdownInput.tsx
+++ b/web/packages/new/photos/components/DropdownInput.tsx
@@ -1,6 +1,4 @@
-import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import {
- Box,
MenuItem,
Select,
type SelectChangeEvent,
@@ -58,107 +56,41 @@ export const DropdownInput = <T extends string>({
// Return the value that is shown in the unexpanded state.
const label = options.find((o) => o.value == selected)?.label;
return label ? (
- <Typography>{label}</Typography>
+ // Wrap the label if doesn't fit.
+ <Typography sx={{ whiteSpace: "normal" }}>{label}</Typography>
) : (
<Typography sx={{ color: "text.muted" }}>
{placeholder}
</Typography>
);
}}
- >
- {options.map((option, index) => (
- <MenuItem
- key={option.value}
- // divider={index !== options.length - 1}
- // value={option.value}
- // sx={{ px: "16px", py: "14px" }}
- >
- {/* <Typography>{option.label}</Typography> */}
- {option.label}
- </MenuItem>
- ))}
- </Select>
-);
-
-export const DropdownInput2 = <T extends string>({
- options,
- selected,
- onSelect,
- placeholder,
-}: DropdownInputProps<T>) => (
- <Select
- IconComponent={ExpandMoreIcon}
- displayEmpty
- variant="standard"
MenuProps={{
PaperProps: {
sx: {
- // Select component automatically sets the min width of the element to the width
- // of the select input's width, so setting the maxWidth to 0, forces to element
- // width to equal to minWidth
+ // Select component sets the min width of each element to
+ // the width of the select input's width, so setting the
+ // maxWidth to 0 forces element widths to equal minWidth.
maxWidth: 0,
},
},
MenuListProps: {
sx: {
backgroundColor: "background.paper2",
- ".MuiMenuItem-root ": {
+ ".MuiMenuItem-root": {
color: "text.faint",
whiteSpace: "normal",
},
- // Make the selected item pop out by giving it a
- // different color instead of giving it a different
- // background color.
+ // Make the selected item pop out by using color.
"&&& > .Mui-selected": {
- backgroundColor: "background.paper2",
color: "text.base",
},
},
},
}}
- sx={{
- "::before , ::after": {
- borderBottom: "none !important",
- },
- ".MuiInput-root": {
- backgroundColor: "fill.faint",
- borderRadius: "8px",
- },
- ".MuiSelect-select": {
- backgroundColor: "fill.faint",
- borderRadius: "8px",
- },
- "&&& .MuiSelect-select": {
- p: "12px 36px 12px 16px",
- },
- ".MuiSelect-icon": {
- mr: "12px",
- color: "stroke.muted",
- },
- }}
- renderValue={(selected) => {
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
- return !selected?.length ? (
- <Box sx={{ color: "text.muted" }}>{placeholder ?? ""}</Box>
- ) : (
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
- options.find((o) => o.value === selected).label
- );
- }}
- value={selected}
- onChange={(event: SelectChangeEvent) => {
- onSelect(event.target.value as T);
- }}
>
- {options.map((option, index) => (
- <MenuItem
- key={option.value}
- divider={index !== options.length - 1}
- value={option.value}
- sx={{ px: "16px", py: "14px" }}
- >
- <Typography>{option.label}</Typography>
+ {options.map(({ value, label }) => (
+ <MenuItem key={value} value={value}>
+ <Typography>{label}</Typography>
</MenuItem>
))}
</Select>