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

Bento navbar implementation #1033

Open
wants to merge 3 commits into
base: andrew_testing
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/app/components/navigation/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Drawer() {
icon={<Menu strokeWidth={3} />}
bg="transparent"
outlineColor="transparent"
color="white"
color={currentTheme.colors.secondaryBlue}
fontWeight="bold"
focusStyle={{
bg: 'transparent',
Expand Down
161 changes: 4 additions & 157 deletions packages/app/components/navigation/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,160 +1,7 @@
import React, { useMemo } from 'react';
import { View, Text, SafeAreaView, StyleSheet, Platform } from 'react-native';
import { RButton, Container } from '@packrat/ui';
import { useIsMobileView } from 'app/hooks/common';
import { useNavigate } from 'app/hooks/navigation';
import { NavigationList } from '../NavigationList';
import { Drawer } from '../Drawer';
import { useScrollTop } from 'app/hooks/common/useScrollTop';
import { useScreenWidth } from 'app/hooks/common';
import useTheme from 'app/hooks/useTheme';
import { RImage } from '@packrat/ui';
import React from 'react';

export const Navbar = () => {
const { currentTheme } = useTheme();
const scrollTop = useScrollTop();
const { screenWidth } = useScreenWidth();
const isScrolled = !!scrollTop;
const styles = useMemo(() => {
return StyleSheet.create(loadStyles(currentTheme, isScrolled, screenWidth));
}, [isScrolled, currentTheme, screenWidth]);
const navigate = useNavigate();

return (
<SafeAreaView style={styles.safeArea}>
<Container>
<View style={styles.container}>
<View style={styles.logoContainer}>
<RImage
source={{
// TODO: Update this to use the PackRat logo from the assets folder
uri: 'https://github.com/andrew-bierman/PackRat/blob/main/packages/app/assets/packrat_icon.png?raw=true',
width: 40,
height: 40,
}}
width={40}
height={40}
style={styles.logo}
alt="PackRat Logo"
onClick={() => {
navigate('/');
}}
/>
<Text
style={styles.logoText}
onClick={() => {
navigate('/');
}}
>
PackRat
</Text>
</View>
<Drawer />
</View>
</Container>
</SafeAreaView>
);
};
import { TopNavBarWithLogo } from '@packrat/ui/src/Bento/shells/navbars';

const NavbarStyles = {
floatingBg: '#0284c7',
floatingRadius: 25,
floatingBlur: 'blur(2px)',
transition: 'all 0.2s ease-in-out',
floatingSpacing: 4,
};

const loadStyles = (currentTheme, isScrolled, screenWidth) => {
const isWeb = Platform.OS === 'web';
const isFloating = isWeb && isScrolled;
const backgroundColor = isFloating
? NavbarStyles.floatingBg
: currentTheme.colors.background;

return {
drawerStyles: {
backgroundColor: currentTheme.colors.background,
},
safeArea: {
backgroundColor,
width: '100%',
margin: 'auto',
transition: NavbarStyles.transition,
...(isFloating
? {
backdropFilter: NavbarStyles.floatingBlur,
marginTop: NavbarStyles.floatingSpacing,
padding: NavbarStyles.floatingSpacing,
borderRadius: NavbarStyles.floatingRadius,
}
: {}),
...(isWeb
? {
position: 'fixed',
top: 0,
zIndex: 100,
width: '100vw',
}
: {}),
},
container: {
width: '100vw',
maxWidth: '100%', // Ensure container does not exceed the viewport width
flex: 1, // Ensure container can grow to fit content
backgroundColor,
borderRadius: NavbarStyles.floatingRadius,
flexDirection: 'row', // Keep flexDirection as row for alignment
justifyContent: 'space-between',
alignItems: 'center',
flexWrap: 'wrap', // Allow items to wrap
height: 60, // Ensure container takes full height of its container
padding: 16,
},
header: {
flexDirection: 'row', // Keep flexDirection as row for initial alignment
alignItems: 'center',
justifyContent: 'space-between',
width: '100%', // Ensure header takes full width of its container
flexWrap: 'wrap', // Allow header items to wrap
},
logoContainer: {
flexDirection: 'row',
alignItems: 'center',
},
logo: {
marginRight: 10,
cursor: 'pointer',
},
logoText: {
color: currentTheme.colors.text,
fontSize: 38,
fontWeight: '900',
cursor: 'pointer',
},
menuBar: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-end',
paddingHorizontal: 16,
flex: 1, // Keep flexible but consider its behavior with wrapping,
flexWrap: 'wrap', // Allow items to wrap
},
drawerTrigger: {},
menuBarItemActive: {
// Apply styles for the active item
// ...
},
menuBarItemTextActive: {
// Apply styles for the active item's text
// ...
},
menuBarItemSelected: {
// Apply styles for the selected item
// ...
},
menuBarItemTextSelected: {
// Apply styles for the selected item's text
// ...
},
};
export const Navbar = () => {
return <TopNavBarWithLogo />;
};
Loading
Loading