From 6639b547ddebc98c83c0b6f973899fa1daee4cb3 Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Thu, 3 Feb 2022 05:52:35 -0800 Subject: [PATCH] UI: fix hover effect of LeftRail icons with badge (#3372) Summary: This PR fixes the missing hover effect for the `LeftRail` component buttons, when they have included the badge. To fix the issue, I had to wrap the whole `Button` with `Badge` component (instead wrapping only around icon). However, this solution required to added `offset` property to the `Badge` which moves the indicator to the position prior change (otherwise indicator was moved to the right corner of the button). The file has been formatted after the changes with ESLint. **Edit:** I have also spotted that this change fixes the icon placement inside the button, when badge is present. Earlier, as seen below, the log icon was moved towards the top of the button: Screenshot 2022-01-31 at 00 57 49 ## Changelog [desktop] UI: fix hover effect of LeftRail icons with badge Pull Request resolved: https://github.com/facebook/flipper/pull/3372 Test Plan: The change has been testes by running the desktop Flipper app locally from source. ## Preview (before & after) #### Before Screenshot 2022-01-31 at 00 24 23 #### After > I have used mocked indicator values locally to ensure that the Badges are displayed correctly. Screenshot 2022-01-31 at 00 26 10 Screenshot 2022-01-31 at 00 45 08 Reviewed By: aigoncharov Differential Revision: D33975324 Pulled By: mweststrate fbshipit-source-id: fe4773b4825b9f22e01821e45259747d319233aa --- .../src/sandy-chrome/LeftRail.tsx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx b/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx index 5b3701919..53ed50f1c 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/LeftRail.tsx @@ -97,16 +97,8 @@ export function LeftRailButton({ title?: string; onClick?: React.MouseEventHandler; }) { - let iconElement = + const iconElement = icon && cloneElement(icon, {style: {fontSize: small ? 16 : 24}}); - if (count !== undefined) { - iconElement = - count === true ? ( - {iconElement} - ) : ( - {iconElement} - ); - } let res = ( ); + if (count !== undefined) { + res = + count === true ? ( + + {res} + + ) : ( + + {res} + + ); + } + if (title) { res = (