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

Fix global nav styles #29428

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dbd917c
fix header gap
kosmydel Oct 12, 2023
e477710
set the settings root color to darkHighlightBackground
robertKozik Oct 12, 2023
2f16e92
change signin button avatar
kosmydel Oct 12, 2023
0e4849b
change LHP width
kosmydel Oct 12, 2023
fcdae82
fix header gap
kosmydel Oct 12, 2023
117a846
display profile status as bubble beneth avatar
robertKozik Oct 12, 2023
0bba34c
center traffic lights, set padding top to 20px
robertKozik Oct 13, 2023
3ecbe7d
fix color around the avatar
kosmydel Oct 16, 2023
e2710d1
Merge branch 'main' into fix-globalnav
kosmydel Oct 16, 2023
3e2b25e
fix typing
kosmydel Oct 16, 2023
c54e9fd
fix LHP width
kosmydel Oct 16, 2023
b224772
run prettier against changed files
robertKozik Oct 16, 2023
f763129
remove todo, add better comment
kosmydel Oct 16, 2023
0fbb284
reduce desktop header padding
kosmydel Oct 16, 2023
859e147
change desktop padding
kosmydel Oct 16, 2023
972911c
fix avatar with workspace border color
kosmydel Oct 16, 2023
e41d3a7
refactor avatar background color
kosmydel Oct 16, 2023
fae9c87
cleanup
kosmydel Oct 16, 2023
2daaf3d
update optionRow/attachemts/indicator sidebar color
robertKozik Oct 16, 2023
a8fbd2c
fix style type - array expected
robertKozik Oct 16, 2023
12aa12e
Fix colors in option row
kosmydel Oct 17, 2023
567f65f
remove excess padding from search icon
robertKozik Oct 24, 2023
0d2417b
unify emoji status displaying
robertKozik Oct 24, 2023
1eadbc3
extend padding top over the safe area
robertKozik Oct 24, 2023
82ae6d7
change styling of status bar
robertKozik Oct 24, 2023
c3a6e35
Merge branch 'Expensify:main' into fix-globalnav
kosmydel Oct 26, 2023
b8d3b52
fix typo
kosmydel Oct 26, 2023
64511f2
set default headerGap color same as global navigation
robertKozik Oct 26, 2023
d57956c
fix naming lhp to lhn
robertKozik Oct 26, 2023
1cae9a5
Merge remote-tracking branch 'upstream/main' into fix-globalnav
robertKozik Oct 30, 2023
fad4311
inverse condition isnside desktop HeaderGap component
robertKozik Oct 30, 2023
7309b93
fix merge
robertKozik Oct 30, 2023
6f6ecd0
run prettier against files
robertKozik Oct 30, 2023
d8f0279
Merge remote-tracking branch 'upstream/main' into fix-globalnav
robertKozik Oct 31, 2023
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
1 change: 1 addition & 0 deletions desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ const mainWindow = () => {
sandbox: false,
},
titleBarStyle: 'hidden',
trafficLightPosition: {x: 9, y: 5},
});

ipcMain.handle(ELECTRON_EVENTS.REQUEST_DEVICE_ID, () => machineId());
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomStatusBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function CustomStatusBar() {
// If we don't have any colour defined for a route, fall back to
// appBG color.
const currentRoute = navigationRef.getCurrentRoute();
let currentScreenBackgroundColor = themeColors.appBG;
let currentScreenBackgroundColor = themeColors.sidebar;
if (currentRoute && 'name' in currentRoute && currentRoute.name in themeColors.PAGE_BACKGROUND_COLORS) {
currentScreenBackgroundColor = themeColors.PAGE_BACKGROUND_COLORS[currentRoute.name];
}
Expand Down
18 changes: 15 additions & 3 deletions src/components/HeaderGap/index.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,33 @@ import React, {PureComponent} from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../../styles/styles';
import stylePropTypes from '../../styles/stylePropTypes';

const propTypes = {
/** Styles to apply to the HeaderGap */
// eslint-disable-next-line react/forbid-prop-types
styles: PropTypes.arrayOf(PropTypes.object),
styles: stylePropTypes,

/** If the HeaderGap is placed in the LHN */
isSidebar: PropTypes.bool,
};

class HeaderGap extends PureComponent {
render() {
return <View style={[styles.headerGap, ...this.props.styles]} />;
if (!this.props.isSidebar) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: IMO it makes more sense to reverse this and return the sidebar if the prop is passed rather than checking if it is not passed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👌🏼

return <View style={[styles.headerGap, ...this.props.styles]} />;
}
return (
<View style={[styles.headerGap, styles.globalAndSubNavigationContainer, styles.flexRow]}>
<View style={styles.globalNavigation} />
<View style={styles.headerGapLhnRight} />
</View>
);
}
}

HeaderGap.propTypes = propTypes;
HeaderGap.defaultProps = {
styles: [],
isSidebar: false,
};
export default HeaderGap;
20 changes: 17 additions & 3 deletions src/components/HeaderGap/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import {PureComponent} from 'react';
import React, {PureComponent} from 'react';
import {View} from 'react-native';
import styles from '../../styles/styles';
import stylePropTypes from '../../styles/stylePropTypes';

export default class HeaderGap extends PureComponent {
const propTypes = {
/** Styles to apply to the HeaderGap */
// eslint-disable-next-line react/forbid-prop-types
styles: stylePropTypes,
};
class HeaderGap extends PureComponent {
render() {
return null;
return <View style={[styles.headerGap, ...this.props.styles]} />;
}
}

HeaderGap.propTypes = propTypes;
HeaderGap.defaultProps = {
styles: [],
};
export default HeaderGap;
2 changes: 2 additions & 0 deletions src/components/Icon/Expensicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import Emoji from '../../../assets/images/emoji.svg';
import EmptyStateRoutePending from '../../../assets/images/emptystate__routepending.svg';
import Exclamation from '../../../assets/images/exclamation.svg';
import Exit from '../../../assets/images/exit.svg';
import ExpensifyAppIcon from '../../../assets/images/expensify-app-icon.svg';
import ExpensifyCard from '../../../assets/images/expensifycard.svg';
import ExpensifyWordmark from '../../../assets/images/expensify-wordmark.svg';
import Expand from '../../../assets/images/expand.svg';
Expand Down Expand Up @@ -174,6 +175,7 @@ export {
EmptyStateRoutePending,
Exclamation,
Exit,
ExpensifyAppIcon,
ExpensifyCard,
ExpensifyWordmark,
ExpensifyFooterLogo,
Expand Down
20 changes: 16 additions & 4 deletions src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ function OptionRowLHN(props) {
{!_.isEmpty(optionItem.icons) &&
(optionItem.shouldShowSubscript ? (
<SubscriptAvatar
backgroundColor={props.isFocused ? themeColors.activeComponentBG : themeColors.sidebar}
backgroundColor={StyleUtils.getAvatarBackgroundColor(
props.isFocused,
hovered || isContextMenuActive,
themeColors.activeComponentBG,
hoveredBackgroundColor,
themeColors.sidebar,
)}
mainAvatar={optionItem.icons[0]}
secondaryAvatar={optionItem.icons[1]}
size={props.viewMode === CONST.OPTION_MODE.COMPACT ? CONST.AVATAR_SIZE.SMALL : defaultSubscriptSize}
Expand All @@ -226,9 +232,15 @@ function OptionRowLHN(props) {
isFocusMode={props.viewMode === CONST.OPTION_MODE.COMPACT}
size={props.viewMode === CONST.OPTION_MODE.COMPACT ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
secondAvatarStyle={[
StyleUtils.getBackgroundAndBorderStyle(themeColors.sidebar),
props.isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined,
hovered && !props.isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined,
StyleUtils.getBackgroundAndBorderStyle(
StyleUtils.getAvatarBackgroundColor(
props.isFocused,
hovered || isContextMenuActive,
focusedBackgroundColor,
hoveredBackgroundColor,
themeColors.sidebar,
),
),
]}
shouldShowTooltip={OptionsListUtils.shouldOptionShowTooltip(optionItem)}
/>
Expand Down
10 changes: 5 additions & 5 deletions src/components/ScreenWrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function ScreenWrapper({
shouldDismissKeyboardBeforeClose,
onEntryTransitionEnd,
testID,
isSidebar,
}) {
const {windowHeight, isSmallScreenWidth} = useWindowDimensions();
const keyboardState = useKeyboardState();
Expand Down Expand Up @@ -103,10 +104,6 @@ function ScreenWrapper({
{({insets, paddingTop, paddingBottom, safeAreaPaddingBottomStyle}) => {
const paddingStyle = {};

if (includePaddingTop) {
paddingStyle.paddingTop = paddingTop;
}

// We always need the safe area padding bottom if we're showing the offline indicator since it is bottom-docked.
if (includeSafeAreaPaddingBottom || isOffline) {
paddingStyle.paddingBottom = paddingBottom;
Expand All @@ -133,7 +130,10 @@ function ScreenWrapper({
style={styles.flex1}
enabled={shouldEnablePickerAvoiding}
>
<HeaderGap styles={headerGapStyles} />
<HeaderGap
styles={[includePaddingTop && {height: paddingTop}, ...headerGapStyles]}
isSidebar={isSidebar}
/>
{isDevelopment && <TestToolsModal />}
{isDevelopment && <CustomDevMenu />}
{
Expand Down
4 changes: 4 additions & 0 deletions src/components/ScreenWrapper/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const propTypes = {

/** Styles for the offline indicator */
offlineIndicatorStyle: stylePropTypes,

/** Is screen in Sidebar */
isSidebar: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -60,6 +63,7 @@ const defaultProps = {
shouldShowOfflineIndicator: true,
offlineIndicatorStyle: [],
headerGapStyles: [],
isSidebar: false,
};

export {propTypes, defaultProps};
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export default (isSmallScreenWidth) => ({

cardStyle: {
...getNavigationModalCardStyle(),
width: isSmallScreenWidth ? '100%' : variables.sideBarWidth,
width: isSmallScreenWidth ? '100%' : variables.lhnWidth,

// We need to translate the sidebar to not be covered by the StackNavigator so it can be clickable.
transform: [{translateX: isSmallScreenWidth ? 0 : -variables.sideBarWidth}],
transform: [{translateX: isSmallScreenWidth ? 0 : -variables.lhnWidth}],
...(isSmallScreenWidth ? {} : styles.borderRight),
},
},
Expand All @@ -52,7 +52,7 @@ export default (isSmallScreenWidth) => ({
...getNavigationModalCardStyle(),

// This is necessary to cover whole screen. Including translated sidebar.
marginLeft: isSmallScreenWidth ? 0 : -variables.sideBarWidth,
marginLeft: isSmallScreenWidth ? 0 : -variables.lhnWidth,
},
},

Expand All @@ -64,7 +64,7 @@ export default (isSmallScreenWidth) => ({

cardStyle: {
...getNavigationModalCardStyle(),
paddingRight: isSmallScreenWidth ? 0 : variables.sideBarWidth,
paddingRight: isSmallScreenWidth ? 0 : variables.lhnWidth,
},
},
});
2 changes: 1 addition & 1 deletion src/pages/home/report/AnimatedEmptyStateBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function AnimatedEmptyStateBackground() {
const IMAGE_OFFSET_X = windowWidth / 2;

// If window width is greater than the max background width, repeat the background image
const maxBackgroundWidth = variables.sideBarWidth + CONST.EMPTY_STATE_BACKGROUND.ASPECT_RATIO * CONST.EMPTY_STATE_BACKGROUND.WIDE_SCREEN.IMAGE_HEIGHT;
const maxBackgroundWidth = variables.lhnWidth + CONST.EMPTY_STATE_BACKGROUND.ASPECT_RATIO * CONST.EMPTY_STATE_BACKGROUND.WIDE_SCREEN.IMAGE_HEIGHT;

// Get data from phone rotation sensor and prep other variables for animation
const animatedSensor = useAnimatedSensor(SensorType.GYROSCOPE);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function ReportFooter(props) {
const isArchivedRoom = ReportUtils.isArchivedRoom(props.report);
const isAnonymousUser = Session.isAnonymousUser();

const isSmallSizeLayout = props.windowWidth - (props.isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint;
const isSmallSizeLayout = props.windowWidth - (props.isSmallScreenWidth ? 0 : variables.lhnWidth) < variables.anonymousReportFooterBreakpoint;
const hideComposer = ReportUtils.shouldDisableWriteActions(props.report);

return (
Expand Down
19 changes: 9 additions & 10 deletions src/pages/home/sidebar/AvatarWithOptionalStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,21 @@ function AvatarWithOptionalStatus({emojiStatus, isCreateMenuOpen}) {

return (
<View style={styles.sidebarStatusAvatarContainer}>
<PressableAvatarWithIndicator isCreateMenuOpen={isCreateMenuOpen} />
<PressableWithoutFeedback
accessibilityLabel={translate('sidebarScreen.buttonMySettings')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
onPress={showStatusPage}
style={styles.flex1}
style={[styles.flex1, styles.sidebarStatusAvatar]}
>
<View style={styles.sidebarStatusAvatar}>
<Text
style={styles.emojiStatusLHN}
numberOfLines={1}
>
{emojiStatus}
</Text>
</View>
<Text
family="SYSTEM"
style={styles.sidebarStatusAvatarEmoji}
numberOfLines={1}
>
{emojiStatus}
</Text>
</PressableWithoutFeedback>
<PressableAvatarWithIndicator isCreateMenuOpen={isCreateMenuOpen} />
</View>
);
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/home/sidebar/SidebarLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ function SidebarLinks({onLinkClick, insets, optionListItems, isLoading, priority
<PressableWithoutFeedback
accessibilityLabel={translate('sidebarScreen.buttonSearch')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
style={[styles.flexRow, styles.ph5]}
onPress={Session.checkIfActionIsAllowed(showSearchPage)}
>
<Icon src={Expensicons.MagnifyingGlass} />
Expand Down
6 changes: 6 additions & 0 deletions src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Performance from '../../../../libs/Performance';
import * as Browser from '../../../../libs/Browser';
import GlobalNavigation from '../GlobalNavigation';
import SubNavigation from '../SubNavigation/SubNavigation';
import getPlatform from '../../../../libs/getPlatform';

const propTypes = {
/** Children to wrap (floating button). */
Expand All @@ -23,13 +24,16 @@ const startTimer = () => {
Performance.markStart(CONST.TIMING.SWITCH_REPORT);
};

const isDesktop = getPlatform() === CONST.PLATFORM.DESKTOP;

function BaseSidebarScreen(props) {
return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableKeyboardAvoidingView={false}
style={[styles.sidebar, Browser.isMobile() ? styles.userSelectNone : {}]}
testID={BaseSidebarScreen.displayName}
isSidebar
>
{({insets}) => (
<>
Expand All @@ -38,6 +42,8 @@ function BaseSidebarScreen(props) {
<SubNavigation
onLinkClick={startTimer}
insets={insets}
// Don't display radius if platform is desktop. In this cases HeaderGap component is handling it.
shouldDisplayRadius={!isDesktop}
stitesExpensify marked this conversation as resolved.
Show resolved Hide resolved
/>
</View>
{props.children}
Expand Down
12 changes: 4 additions & 8 deletions src/pages/home/sidebar/SignInButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import React from 'react';
import {View} from 'react-native';
import PressableWithoutFeedback from '../../../components/Pressable/PressableWithoutFeedback';
import Button from '../../../components/Button';
import styles from '../../../styles/styles';
import * as Session from '../../../libs/actions/Session';
import useLocalize from '../../../hooks/useLocalize';
import CONST from '../../../CONST';
import Avatar from '../../../components/Avatar';
import * as Expensicons from '../../../components/Icon/Expensicons';

function SignInButton() {
const {translate} = useLocalize();
Expand All @@ -17,13 +18,8 @@ function SignInButton() {
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
onPress={Session.signOutAndRedirectToSignIn}
>
<View style={styles.signInButtonAvatar}>
<Button
medium
success
text={translate('common.signIn')}
onPress={Session.signOutAndRedirectToSignIn}
/>
<View style={[styles.sidebarAvatar]}>
<Avatar source={Expensicons.ExpensifyAppIcon} />
</View>
</PressableWithoutFeedback>
);
Expand Down
7 changes: 5 additions & 2 deletions src/pages/home/sidebar/SubNavigation/SubNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ const propTypes = {

/** Insets for SidebarLInksData */
insets: safeAreaInsetPropTypes.isRequired,

/** Whether the sidebar should display a radius */
shouldDisplayRadius: PropTypes.bool.isRequired,
};

function SubNavigation({onLinkClick, insets}) {
function SubNavigation({onLinkClick, insets, shouldDisplayRadius}) {
useEffect(() => {
Performance.markStart(CONST.TIMING.SIDEBAR_LOADED);
Timing.start(CONST.TIMING.SIDEBAR_LOADED, true);
}, []);

return (
<View style={styles.subNavigationContainer}>
<View style={styles.subNavigationContainer(shouldDisplayRadius)}>
<SidebarLinksData
insets={insets}
onLinkClick={onLinkClick}
Expand Down
11 changes: 11 additions & 0 deletions src/styles/StyleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,16 @@ function getTransparentColor(color: string) {
return `${color}00`;
}

function getAvatarBackgroundColor(isFocused: boolean, hovered: boolean, focusedBackgroundColor: string, hoveredBackgroundColor: string, defaultBackgroundColor: string) {
if (isFocused) {
return focusedBackgroundColor;
}
if (hovered) {
return hoveredBackgroundColor;
}
return defaultBackgroundColor;
}

export {
combineStyles,
displayIfTrue,
Expand Down Expand Up @@ -1398,4 +1408,5 @@ export {
getContainerStyles,
getEReceiptColorStyles,
getEReceiptColorCode,
getAvatarBackgroundColor,
};
Loading
Loading