π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Improve focus visible and add active state for switch
Manav Rathi8b9830fe79c1
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 7bf433d1e1..f821cfe790 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -3,6 +3,7 @@ import { stashRedirect } from "@/accounts/services/redirect";import type { MiniDialogAttributes } from "@/base/components/MiniDialog";import { AppNavbar, NavbarBase } from "@/base/components/Navbar";import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";+import { FocusVisibleButton } from "@/base/components/mui/FocusVisibleButton";import { errorDialogAttributes } from "@/base/components/utils/dialog";import { useIsSmallWidth } from "@/base/components/utils/hooks";import { useModalVisibility } from "@/base/components/utils/modal";@@ -85,7 +86,7 @@ import ArrowBackIcon from "@mui/icons-material/ArrowBack";import FileUploadOutlinedIcon from "@mui/icons-material/FileUploadOutlined";import MenuIcon from "@mui/icons-material/Menu";import type { ButtonProps, IconButtonProps } from "@mui/material";-import { Box, Button, IconButton, Stack, Typography } from "@mui/material";+import { Box, IconButton, Stack, Typography } from "@mui/material";import AuthenticateUserModal from "components/AuthenticateUserModal";import CollectionNamer, {CollectionNamerAttributes,@@ -1199,14 +1200,14 @@ const UploadButton: React.FC<ButtonProps & IconButtonProps> = (props) => {{icon}</IconButton>) : (- <Button+ <FocusVisibleButton{...props}disabled={disabled}color={"secondary"}startIcon={icon}>{t("upload")}- </Button>+ </FocusVisibleButton>)}</Box>);diff --git a/web/packages/base/components/EnteSwitch.tsx b/web/packages/base/components/EnteSwitch.tsxindex d0b2a9e16e..d03f3c285f 100644--- a/web/packages/base/components/EnteSwitch.tsx+++ b/web/packages/base/components/EnteSwitch.tsx@@ -5,11 +5,7 @@ import React from "react";* A custom variant of the MUI {@link Switch}, styled per our designs.*/export const EnteSwitch: React.FC<SwitchProps> = styled((props) => (- <Switch- focusVisibleClassName=".Mui-focusVisible"- disableRipple- {...props}- />+ <Switch disableRipple {...props} />))(({ theme }) => ({width: 40,height: 24,@@ -20,7 +16,7 @@ export const EnteSwitch: React.FC<SwitchProps> = styled((props) => (transitionDuration: "300ms","&.Mui-checked": {transform: "translateX(16px)",- color: "#fff",+ color: theme.vars.palette.fixed.white,"& + .MuiSwitch-track": {backgroundColor: "#65C466",opacity: 1,@@ -33,10 +29,6 @@ export const EnteSwitch: React.FC<SwitchProps> = styled((props) => (opacity: 0.5,},},- "&.Mui-focusVisible .MuiSwitch-thumb": {- color: "#33cf4d",- border: "6px solid #fff",- },"&.Mui-disabled .MuiSwitch-thumb": {color: theme.palette.grey[600],...theme.applyStyles("light", {@@ -66,4 +58,15 @@ export const EnteSwitch: React.FC<SwitchProps> = styled((props) => (backgroundColor: "#E9E9EA",}),},+ // Use an alternative affordance to indicate focusVisible as the ripple+ // effect is disabled.+ ".MuiSwitch-switchBase.Mui-focusVisible + .MuiSwitch-track": {+ outline: `1px solid ${theme.vars.palette.fixed.white}`,+ outlineOffset: "-1px",+ },+ // Same for when the switch is actived.+ ".MuiSwitch-switchBase:active + .MuiSwitch-track": {+ outline: `1px solid ${theme.vars.palette.stroke.faint}`,+ outlineOffset: "-1px",+ },}));diff --git a/web/packages/base/components/mui/FocusVisibleButton.tsx b/web/packages/base/components/mui/FocusVisibleButton.tsxindex 23709a0b62..cb7e3e0636 100644--- a/web/packages/base/components/mui/FocusVisibleButton.tsx+++ b/web/packages/base/components/mui/FocusVisibleButton.tsx@@ -9,13 +9,15 @@ export const RippleDisabledButton: React.FC<ButtonProps> = (props) => (* A MUI {@link Button} that shows a keyboard focus indicator (e.g. when the* user tabs to it) and also an affordance to indicate when it is activated.*/-export const FocusVisibleButton = styled(RippleDisabledButton)`+export const FocusVisibleButton = styled(RippleDisabledButton)(+ ({ theme }) => `&.Mui-focusVisible {- outline: 1px solid ${(props) => props.theme.colors.stroke.base};+ outline: 1px solid ${theme.vars.palette.stroke.base};outline-offset: 2px;}&:active {- outline: 1px solid ${(props) => props.theme.colors.stroke.faint};+ outline: 1px solid ${theme.vars.palette.stroke.faint};outline-offset: 1px;}-`;+`,+);diff --git a/web/packages/base/components/utils/mui-theme.d.ts b/web/packages/base/components/utils/mui-theme.d.tsindex 768df48e60..461f2a46ff 100644--- a/web/packages/base/components/utils/mui-theme.d.ts+++ b/web/packages/base/components/utils/mui-theme.d.ts@@ -173,6 +173,7 @@ declare module "@mui/material/styles" {* These change with the color scheme.*/stroke: {+ base: string;muted: string;faint: string;};diff --git a/web/packages/base/components/utils/theme.ts b/web/packages/base/components/utils/theme.tsindex fd5eb4671e..1dc476cf54 100644--- a/web/packages/base/components/utils/theme.ts+++ b/web/packages/base/components/utils/theme.ts@@ -353,6 +353,7 @@ const getPalletteOptions = (faint: colors.fill!.faint!,},stroke: {+ base: colors.stroke!.base!,muted: colors.stroke!.muted!,faint: colors.stroke!.faint!,},