Skip to content

armgit / ente

Public Imported from GitHub
0

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

Style the focus and activation

Manav Rathia7a21e66a7b3
diff --git a/web/apps/photos/src/components/Sidebar/SubscriptionCard.tsx b/web/apps/photos/src/components/Sidebar/SubscriptionCard.tsx
index d72c0972b9..368e65d736 100644
--- a/web/apps/photos/src/components/Sidebar/SubscriptionCard.tsx
+++ b/web/apps/photos/src/components/Sidebar/SubscriptionCard.tsx
@@ -1,6 +1,6 @@
import { Overlay } from "@/base/components/containers";
import type { ButtonishProps } from "@/base/components/mui";
-import { UnstyledButton } from "@/new/photos/components/UnstyledButton";
+import { FocusVisibleUnstyledButton } from "@/new/photos/components/UnstyledButton";
import type { UserDetails } from "@/new/photos/services/user-details";
import {
familyUsage,
@@ -74,8 +74,11 @@ const ClickOverlay: React.FC<ButtonishProps> = ({ onClick }) => (
</ClickOverlayButton>
);
-/** A mixin of UnstyledButton and {@link Overlay}, plus custom styling. */
-const ClickOverlayButton = styled(UnstyledButton)`
+/**
+ * The transparent button element offers activation of the subscription card is activated on clicks
+ * A mixin of UnstyledButton, FocusVisibleUnstyledButton, {@link Overlay}, plus
+ * custom styling. */
+const ClickOverlayButton = styled(FocusVisibleUnstyledButton)`
/* Overlay */
position: absolute;
width: 100%;
diff --git a/web/packages/new/photos/components/UnstyledButton.tsx b/web/packages/new/photos/components/UnstyledButton.tsx
index 920c646065..d3d5d6f590 100644
--- a/web/packages/new/photos/components/UnstyledButton.tsx
+++ b/web/packages/new/photos/components/UnstyledButton.tsx
@@ -24,3 +24,22 @@ export const UnstyledButton = styled("button")`
/* Default cursor on mouse over of a button is not a hand pointer */
cursor: pointer;
`;
+
+/**
+ * A variant of {@link UnstyledButton} that modifying the keyboard focus and
+ * activation states to match the styling of {@link FocusVisibleButton}.
+ */
+export const FocusVisibleUnstyledButton = styled(UnstyledButton)(
+ ({ theme }) => `
+ &:focus-visible {
+ outline: 1px solid ${theme.vars.palette.stroke.base};
+ outline-offset: 2px;
+ border-radius: 2px;
+ }
+ &:active {
+ outline: 1px solid ${theme.vars.palette.stroke.faint};
+ outline-offset: 1px;
+ border-radius: 2px;
+ }
+`,
+);
diff --git a/web/packages/new/photos/components/gallery/BarImpl.tsx b/web/packages/new/photos/components/gallery/BarImpl.tsx
index c648c11ae0..9dada6a492 100644
--- a/web/packages/new/photos/components/gallery/BarImpl.tsx
+++ b/web/packages/new/photos/components/gallery/BarImpl.tsx
@@ -12,7 +12,7 @@ import {
ItemCard,
TileTextOverlay,
} from "@/new/photos/components/Tiles";
-import { UnstyledButton } from "@/new/photos/components/UnstyledButton";
+import { FocusVisibleUnstyledButton } from "@/new/photos/components/UnstyledButton";
import type {
CollectionSummary,
CollectionSummaryType,
@@ -42,8 +42,8 @@ import {
type ListChildComponentProps,
areEqual,
} from "react-window";
-import { isMLSupported } from "../../services/ml";
import type { GalleryBarMode } from "./reducer";
+import { isMLSupported } from "../../services/ml";
export interface GalleryBarImplProps {
/**
@@ -352,7 +352,7 @@ const ModeIndicator: React.FC<
);
};
-const ModeButton = styled(UnstyledButton, {
+const ModeButton = styled(FocusVisibleUnstyledButton, {
shouldForwardProp: (propName) => propName != "active",
})<{ active: boolean }>(
({ theme, active }) => `