Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export type GoogleUiState = "checking" | "repairing" | GoogleConnectionState;

export type CommandActionIcon = "CloudArrowUpIcon";

export type IconColor = "muted" | "warning" | "error";

export type GoogleUiConfig = {
commandAction: {
label: string;
Expand All @@ -16,7 +14,7 @@ export type GoogleUiConfig = {
sidebarStatus: {
tooltip: string;
isDisabled: boolean;
iconColor?: IconColor;
iconColor?: string;
dialog?: {
title: string;
description: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { theme } from "@web/common/styles/theme";
import {
type CommandActionIcon,
type GoogleUiConfig,
Expand Down Expand Up @@ -41,7 +42,7 @@ export const getGoogleConnectionConfig = (
isDisabled: true,
},
sidebarStatus: {
iconColor: "warning",
iconColor: theme.color.status.warning,
tooltip: "Repairing Google Calendar in the background.",
isDisabled: true,
dialog: buildRepairDialog(onRepairGoogle),
Expand All @@ -56,7 +57,6 @@ export const getGoogleConnectionConfig = (
onSelect: onConnectGoogle,
},
sidebarStatus: {
iconColor: "muted",
tooltip: "Google Calendar not connected. Click to connect.",
isDisabled: false,
onSelect: onConnectGoogle,
Expand All @@ -71,7 +71,7 @@ export const getGoogleConnectionConfig = (
onSelect: onConnectGoogle,
},
sidebarStatus: {
iconColor: "error",
iconColor: theme.color.status.error,
tooltip: "Google Calendar needs reconnecting. Click to reconnect.",
isDisabled: false,
onSelect: onConnectGoogle,
Expand All @@ -98,7 +98,7 @@ export const getGoogleConnectionConfig = (
onSelect: onRepairGoogle,
},
sidebarStatus: {
iconColor: "warning",
iconColor: theme.color.status.warning,
tooltip: "Google Calendar needs repair. Click to repair.",
isDisabled: false,
dialog: buildRepairDialog(onRepairGoogle),
Expand All @@ -112,7 +112,6 @@ export const getGoogleConnectionConfig = (
isDisabled: true,
},
sidebarStatus: {
iconColor: "muted",
tooltip: "Google Calendar connected.",
isDisabled: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type GoogleUiConfig,
type GoogleUiState,
} from "@web/auth/google/hooks/useConnectGoogle/useConnectGoogle.types";
import { theme } from "@web/common/styles/theme";
import { type AuthView } from "@web/components/AuthModal/hooks/useAuthModal";
import { afterAll, beforeEach, describe, expect, it, mock } from "bun:test";

Expand Down Expand Up @@ -37,7 +38,7 @@ const mockUseConnectGoogle = mock(
isAvailable: true,
isRepairing: false,
sidebarStatus: {
iconColor: "error",
iconColor: theme.color.status.error,
isDisabled: false,
onSelect: mockGoogleOnSelect,
tooltip: "Google Calendar needs reconnecting. Click to reconnect.",
Expand Down Expand Up @@ -161,7 +162,7 @@ describe("HeaderInfoIcon", () => {
isAvailable: true,
isRepairing: false,
sidebarStatus: {
iconColor: "error",
iconColor: theme.color.status.error,
isDisabled: false,
onSelect: mockGoogleOnSelect,
tooltip: "Google Calendar needs reconnecting. Click to reconnect.",
Expand Down Expand Up @@ -234,7 +235,7 @@ describe("HeaderInfoIcon", () => {
isAvailable: false,
isRepairing: false,
sidebarStatus: {
iconColor: "error",
iconColor: theme.color.status.error,
isDisabled: false,
onSelect: mockGoogleOnSelect,
tooltip: "Google Calendar needs reconnecting. Click to reconnect.",
Expand Down Expand Up @@ -289,7 +290,7 @@ describe("HeaderInfoIcon", () => {
isAvailable: true,
isRepairing: true,
sidebarStatus: {
iconColor: "warning",
iconColor: theme.color.status.warning,
isDisabled: true,
tooltip: "Repairing Google Calendar in the background.",
},
Expand Down
18 changes: 3 additions & 15 deletions packages/web/src/components/HeaderInfoIcon/HeaderInfoIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { InfoIcon } from "@phosphor-icons/react";
import { type IconColor } from "@web/auth/google/hooks/useConnectGoogle/useConnectGoogle.types";
import { theme } from "@web/common/styles/theme";
import { SpinnerIcon } from "@web/components/Icons/Spinner";
import { TooltipWrapper } from "@web/components/Tooltip/TooltipWrapper";
import { StatusDotPopover } from "./HeaderInfoIconPopover";
import { useHeaderInfo } from "./useHeaderInfo";

const ICON_COLOR_MAP: Record<IconColor, string> = {
muted: theme.color.text.darkPlaceholder,
warning: theme.color.status.warning,
error: theme.color.status.error,
};

const ANONYMOUS_PROMPT_ICON_CLASSNAME =
"origin-center transition-all duration-200 ease-out motion-safe:animate-sync-dot-pulse motion-safe:group-hover:animate-none";
const DOT_BUTTON_CLASSNAME = "inline-flex h-6 w-6 items-center justify-center";
Expand All @@ -33,23 +25,19 @@ export const HeaderInfoIcon = () => {
);
}

// Only render when user attention is needed (warning or error states)
if (
sidebarStatus.iconColor !== "warning" &&
sidebarStatus.iconColor !== "error"
) {
// Only render when user attention is needed
if (!sidebarStatus.iconColor) {
return null;
}

const iconColor = ICON_COLOR_MAP[sidebarStatus.iconColor];
const iconClassName = isAnonymousSignUpPrompt
? ANONYMOUS_PROMPT_ICON_CLASSNAME
: undefined;
const icon = (
<InfoIcon
aria-hidden="true"
className={iconClassName}
style={{ color: iconColor }}
style={{ color: sidebarStatus.iconColor }}
size={15}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/components/HeaderInfoIcon/useHeaderInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
type GoogleUiConfig,
type UseConnectGoogleResult,
} from "@web/auth/google/hooks/useConnectGoogle/useConnectGoogle.types";
import { theme } from "@web/common/styles/theme";
import { useAuthModal } from "@web/components/AuthModal/hooks/useAuthModal";

const ANONYMOUS_SIGN_UP_TOOLTIP = "Sign up to save your changes.";
Expand Down Expand Up @@ -39,7 +40,7 @@ export const useHeaderInfo = (): HeaderInfo => {
isAnonymousSignUpPrompt: true,
isRepairing: false,
sidebarStatus: {
iconColor: "warning" as const,
iconColor: theme.color.status.info,
isDisabled: false,
onSelect: handleOpenSignUp,
tooltip: ANONYMOUS_SIGN_UP_TOOLTIP,
Expand All @@ -53,7 +54,6 @@ export const useHeaderInfo = (): HeaderInfo => {
isAnonymousSignUpPrompt: false,
isRepairing: false,
sidebarStatus: {
iconColor: "muted" as const,
isDisabled: true,
tooltip: "",
},
Expand Down
Loading