From 562faa76cce6e935295f30359cbd7180b912cec1 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 17 May 2023 11:10:51 -0500 Subject: [PATCH] feat: add basic visual feedback on Button interactions (#708) * feat: add basic visual feedback on Button interaction * Use a more efficient approach to providing visual feedback * Fix some lint issues left over from another PR --------- Co-authored-by: Simek --- src/view/com/util/forms/Button.tsx | 17 ++++++++++++++++- src/view/shell/desktop/RightNav.tsx | 9 ++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/view/com/util/forms/Button.tsx b/src/view/com/util/forms/Button.tsx index a8f1f363..6a5f19f9 100644 --- a/src/view/com/util/forms/Button.tsx +++ b/src/view/com/util/forms/Button.tsx @@ -128,6 +128,7 @@ export function Button({ }, }, ) + const onPressWrapped = React.useCallback( (event: Event) => { event.stopPropagation() @@ -136,9 +137,23 @@ export function Button({ }, [onPress], ) + + const getStyle = React.useCallback( + state => { + const arr = [typeOuterStyle, styles.outer, style] + if (state.pressed) { + arr.push({opacity: 0.6}) + } else if (state.hovered) { + arr.push({opacity: 0.8}) + } + return arr + }, + [typeOuterStyle, style], + ) + return ( { store.shell.setDarkMode(!store.shell.darkMode) @@ -72,12 +72,11 @@ export const DesktopRightNav = observer(function DesktopRightNav() { : 'Sets display to dark mode' }> - { - mode === 'Dark' ? + {mode === 'Dark' ? ( - : + ) : ( - } + )} {otherMode} mode