From 2e00ad2b26038875b164e067254132efcbceaa1e Mon Sep 17 00:00:00 2001 From: th3c0d3br34ker Date: Sat, 23 Sep 2023 11:02:59 +0530 Subject: [PATCH] Fix active styles in Button --- .../src/components/common/Button.tsx | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/desktop-client/src/components/common/Button.tsx b/packages/desktop-client/src/components/common/Button.tsx index 5a981cbeb94..e568196b4dd 100644 --- a/packages/desktop-client/src/components/common/Button.tsx +++ b/packages/desktop-client/src/components/common/Button.tsx @@ -102,6 +102,28 @@ const _getPadding = type => { } }; +const _getActiveStyles = (type, bounce) => { + switch (type) { + case 'bare': + return { backgroundColor: theme.buttonBareBackgroundActive }; + case 'link': + return { + transform: 'none', + boxShadow: 'none', + }; + default: + return { + transform: bounce && 'translateY(1px)', + boxShadow: `0 1px 4px 0 ${ + type === 'primary' + ? theme.buttonPrimaryShadow + : theme.buttonNormalShadow + }`, + transition: 'none', + }; + } +}; + const Button = forwardRef( ( { @@ -131,17 +153,7 @@ const Button = forwardRef( ...hoveredStyle, }; activeStyle = { - ...(type === 'bare' - ? { backgroundColor: theme.buttonBareBackgroundActive } - : { - transform: bounce && 'translateY(1px)', - boxShadow: - '0 1px 4px 0 ' + - (type === 'primary' - ? theme.buttonPrimaryShadow - : theme.buttonNormalShadow), - transition: 'none', - }), + ..._getActiveStyles(type, bounce), ...activeStyle, };