({
className,
showLogo = true,
compactLogo = false,
fallbackPath,
}: WithClassNameProps & {
showLogo?: boolean;
compactLogo?: boolean;
fallbackPath?: string;
})
| 17 | import { useHideOnScrollDown } from '../../features/getApp/hooks/useHideOnScrollDown'; |
| 18 | |
| 19 | export const GoBackButton = ({ |
| 20 | className, |
| 21 | showLogo = true, |
| 22 | compactLogo = false, |
| 23 | fallbackPath, |
| 24 | }: WithClassNameProps & { |
| 25 | showLogo?: boolean; |
| 26 | compactLogo?: boolean; |
| 27 | fallbackPath?: string; |
| 28 | }): JSX.Element | null => { |
| 29 | const router = useRouter(); |
| 30 | const goHome = useCallback(() => router.push('/'), [router]); |
| 31 | const featureTheme = useFeatureTheme(); |
| 32 | |
| 33 | const canGoBack = canGoBackInApp(); |
| 34 | |
| 35 | const goBack = useCallback(() => { |
| 36 | if (canGoBack) { |
| 37 | router.back(); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | if (fallbackPath) { |
| 42 | router.push(fallbackPath); |
| 43 | } |
| 44 | }, [canGoBack, fallbackPath, router]); |
| 45 | |
| 46 | const logoButton = showLogo ? ( |
| 47 | <Logo |
| 48 | className="my-2" |
| 49 | compact={compactLogo} |
| 50 | onLogoClick={goHome} |
| 51 | position={LogoPosition.Initial} |
| 52 | featureTheme={featureTheme} |
| 53 | /> |
| 54 | ) : null; |
| 55 | |
| 56 | return canGoBack || fallbackPath ? ( |
| 57 | <Button |
| 58 | icon={<ArrowIcon className="-rotate-90" />} |
| 59 | size={ButtonSize.Small} |
| 60 | variant={ButtonVariant.Tertiary} |
| 61 | onClick={goBack} |
| 62 | className={className} |
| 63 | type="button" |
| 64 | aria-label="Go back" |
| 65 | /> |
| 66 | ) : ( |
| 67 | logoButton |
| 68 | ); |
| 69 | }; |
| 70 | |
| 71 | interface GoBackHeaderMobileProps extends WithClassNameProps { |
| 72 | title?: string; |
nothing calls this directly
no test coverage detected