Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hovered effect on the workspace switcher button (210) #58

Merged
merged 1 commit into from
Jan 31, 2024
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
5 changes: 4 additions & 1 deletion src/components/SubscriptAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ type SubIcon = {

/** Height of the icon */
height?: number;

/** The fill color for the icon. Can be hex, rgb, rgba, or valid react-native named color such as 'red' or 'blue'. */
fill?: string;
};

type SubscriptAvatarProps = {
Expand Down Expand Up @@ -120,7 +123,7 @@ function SubscriptAvatar({mainAvatar, secondaryAvatar, subscriptIcon, size = CON
width={subscriptIcon.width}
height={subscriptIcon.height}
additionalStyles={styles.alignSelfCenter}
fill={theme.icon}
fill={subscriptIcon.fill ?? theme.icon}
/>
</View>
)}
Expand Down
21 changes: 15 additions & 6 deletions src/components/WorkspaceSwitcherButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useMemo} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import Navigation from '@libs/Navigation/Navigation';
import {getDefaultWorkspaceAvatar} from '@libs/ReportUtils';
Expand All @@ -21,6 +22,7 @@ type WorkspaceSwitcherButtonProps = {activeWorkspaceID?: string} & WorkspaceSwit

function WorkspaceSwitcherButton({activeWorkspaceID, policy}: WorkspaceSwitcherButtonProps) {
const {translate} = useLocalize();
const theme = useTheme();

const {source, name, type} = useMemo(() => {
if (!activeWorkspaceID) {
Expand All @@ -46,12 +48,19 @@ function WorkspaceSwitcherButton({activeWorkspaceID, policy}: WorkspaceSwitcherB
})
}
>
<SubscriptAvatar
mainAvatar={{source, name, type}}
subscriptIcon={{source: Expensicons.DownArrow, width: CONST.WORKSPACE_SWITCHER.SUBSCRIPT_ICON_SIZE, height: CONST.WORKSPACE_SWITCHER.SUBSCRIPT_ICON_SIZE}}
showTooltip={false}
noMargin
/>
{({hovered}) => (
<SubscriptAvatar
mainAvatar={{source, name, type}}
subscriptIcon={{
source: Expensicons.DownArrow,
width: CONST.WORKSPACE_SWITCHER.SUBSCRIPT_ICON_SIZE,
height: CONST.WORKSPACE_SWITCHER.SUBSCRIPT_ICON_SIZE,
fill: hovered ? theme.buttonHoveredBG : theme.icon,
}}
showTooltip={false}
noMargin
/>
)}
</PressableWithFeedback>
);
}
Expand Down
Loading