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

[NoQA] [Wave8] Breadcrumbs #32221

Merged
merged 46 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6f3fc56
Change size of Expensify logo
MaciejSWM Nov 28, 2023
ced4c37
Breadcrumbs WIP
MaciejSWM Nov 28, 2023
0bfd97e
Breadcrumb types
MaciejSWM Nov 29, 2023
6c66b08
Pixel perfect alignments
MaciejSWM Nov 29, 2023
ce3c4ea
Align text on mobile devices
MaciejSWM Nov 29, 2023
5209597
Handle DEV badge nicely
MaciejSWM Nov 29, 2023
fbd4789
Add unique keys for each breadcrumb
MaciejSWM Nov 29, 2023
1218a42
Align text on mobile
MaciejSWM Nov 29, 2023
a8a2e38
Unique key
MaciejSWM Nov 29, 2023
857c104
Fix missing key
MaciejSWM Nov 29, 2023
737480f
Fix styles not being applied to header
MaciejSWM Nov 29, 2023
08cd12b
Breadcrumbs storybook
MaciejSWM Nov 29, 2023
a81da06
Rename story
MaciejSWM Nov 30, 2023
87b5b5b
Use theme instead of colors
MaciejSWM Dec 1, 2023
125626a
Remove explicit margin - use flex adjustments
MaciejSWM Dec 1, 2023
694d6ad
Single quote instead of backtick
MaciejSWM Dec 4, 2023
1dba8b0
Drop test breadcrumbs
MaciejSWM Dec 4, 2023
5dbffff
Pixel-perfect alignment
MaciejSWM Dec 4, 2023
8e3309c
Drop unused import
MaciejSWM Dec 4, 2023
9467923
Merge branch 'main' into wave8/breadcrumbs
MaciejSWM Dec 5, 2023
c276ae2
Pixel perfect adjustments
MaciejSWM Dec 5, 2023
74d8e2b
Change color of separator to match Figma
MaciejSWM Dec 5, 2023
3c415dc
Restore initial iconHeight
MaciejSWM Dec 5, 2023
fdad0cc
Drop unnecessary keys
MaciejSWM Dec 5, 2023
3dd6fca
Wrap separator and text inside of text to glue it together
MaciejSWM Dec 5, 2023
d0fd4a6
Rename root to header
MaciejSWM Dec 11, 2023
fa46d37
Allow only two elements in Breadcrumbs array
MaciejSWM Dec 11, 2023
d121272
Refactor: Allow only up to two levels breadcrumbs
MaciejSWM Dec 11, 2023
62f576b
Rename const for breadcrumb
MaciejSWM Dec 11, 2023
6eb2110
Drop old breadcrumb styles
MaciejSWM Dec 11, 2023
2fdbd74
Max width helper style
MaciejSWM Dec 11, 2023
3d394ff
Fix alignment
MaciejSWM Dec 11, 2023
0383f26
Drop Normal story sample - not used in app
MaciejSWM Dec 11, 2023
90304da
Add styles from breadcrumb style
MaciejSWM Dec 11, 2023
0a9afd7
Merge branch 'main' into wave8/breadcrumbs
MaciejSWM Dec 12, 2023
333fb45
Adjust colors after main merge
MaciejSWM Dec 12, 2023
7c7051c
Pixel perfect logo height adjustment
MaciejSWM Dec 12, 2023
bb7dda3
Logo width exactly like in Figma
MaciejSWM Dec 12, 2023
27357f4
Merge branch 'main' into wave8/breadcrumbs
MaciejSWM Dec 14, 2023
9a0c2e0
Change import paths
MaciejSWM Dec 14, 2023
e5cc42e
Merge branch 'main' into wave8/breadcrumbs
MaciejSWM Dec 18, 2023
22864a4
Convert object to boolean before doing AND on it
MaciejSWM Dec 18, 2023
39784fb
Migrate Storybook file to TS
MaciejSWM Dec 18, 2023
f14e7b4
Add optional style prop
MaciejSWM Dec 18, 2023
e0cef1a
Export type to use in storybook
MaciejSWM Dec 18, 2023
0d30c94
Prop description
MaciejSWM Dec 18, 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
6 changes: 6 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ const CONST = {
AVATAR_MAX_WIDTH_PX: 4096,
AVATAR_MAX_HEIGHT_PX: 4096,

BREADCRUMB_TYPE: {
ROOT: 'root',
STRONG: 'strong',
NORMAL: 'normal',
},

DEFAULT_AVATAR_COUNT: 24,
OLD_DEFAULT_AVATAR_COUNT: 8,

Expand Down
80 changes: 80 additions & 0 deletions src/components/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React from 'react';
import {StyleProp, View, ViewStyle} from 'react-native';
import LogoComponent from '@assets/images/expensify-wordmark.svg';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import Header from './Header';
import Text from './Text';

type BreadcrumbHeader = {
type: typeof CONST.BREADCRUMB_TYPE.ROOT;
};

type BreadcrumbStrong = {
text: string;
type: typeof CONST.BREADCRUMB_TYPE.STRONG;
};

type Breadcrumb = {
text: string;
type?: typeof CONST.BREADCRUMB_TYPE.NORMAL;
};

type BreadcrumbsProps = {
/** An array of breadcrumbs consisting of the root/strong breadcrumb, followed by an optional second level breadcrumb */
breadcrumbs: [BreadcrumbHeader | BreadcrumbStrong, Breadcrumb | undefined];

/** Styles to apply to the container */
style?: StyleProp<ViewStyle>;
};

function Breadcrumbs({breadcrumbs, style}: BreadcrumbsProps) {
const theme = useTheme();
const styles = useThemeStyles();
const [primaryBreadcrumb, secondaryBreadcrumb] = breadcrumbs;

return (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.gap1, styles.w100, style]}>
{primaryBreadcrumb.type === CONST.BREADCRUMB_TYPE.ROOT ? (
<View style={styles.breadcrumbLogo}>
<Header
title={
<LogoComponent
fill={theme.text}
width={variables.lhnLogoWidth}
height={variables.lhnLogoHeight}
/>
}
shouldShowEnvironmentBadge
/>
</View>
) : (
<Text
numberOfLines={1}
style={[styles.flexShrink1, styles.breadcrumb, styles.breadcrumbStrong]}
>
{primaryBreadcrumb.text}
</Text>
)}

{!!secondaryBreadcrumb && (
<>
<Text style={[styles.breadcrumbSeparator]}>/</Text>
<Text
numberOfLines={1}
style={[styles.mw75, styles.flexShrink0, styles.breadcrumb]}
>
{secondaryBreadcrumb.text}
</Text>
</>
)}
</View>
);
}

Breadcrumbs.displayName = 'Breadcrumbs';

export type {BreadcrumbsProps};
export default Breadcrumbs;
2 changes: 1 addition & 1 deletion src/components/EnvironmentBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function EnvironmentBadge() {
success={environment === CONST.ENVIRONMENT.STAGING || environment === CONST.ENVIRONMENT.ADHOC}
error={environment !== CONST.ENVIRONMENT.STAGING && environment !== CONST.ENVIRONMENT.ADHOC}
text={text}
badgeStyles={[styles.alignSelfEnd, styles.headerEnvBadge]}
badgeStyles={[styles.alignSelfStart, styles.headerEnvBadge]}
textStyles={[styles.headerEnvBadgeText]}
environment={environment}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/TeachersUnite/ImTeacherUpdateEmailPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function ImTeacherUpdateEmailPage() {
linkKey="teachersUnitePage.contactMethods"
onLinkPress={() => Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(activeRoute))}
iconWidth={variables.signInLogoWidthLargeScreen}
iconHeight={variables.lhnLogoWidth}
iconHeight={variables.signInLogoHeightLargeScreen}
/>
<FixedFooter style={[styles.flexGrow0]}>
<Button
Expand Down
50 changes: 50 additions & 0 deletions src/stories/Breadcrumbs.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import Breadcrumbs, {BreadcrumbsProps} from '@components/Breadcrumbs';
import CONST from '@src/CONST';

/**
* We use the Component Story Format for writing stories. Follow the docs here:
*
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format
*/
const story = {
title: 'Components/Breadcrumbs',
component: Breadcrumbs,
};

type StoryType = typeof Template & {args?: Partial<BreadcrumbsProps>};

function Template(args: BreadcrumbsProps) {
// eslint-disable-next-line react/jsx-props-no-spreading
return <Breadcrumbs {...args} />;
}

// Arguments can be passed to the component by binding
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Default: StoryType = Template.bind({});
Default.args = {
breadcrumbs: [
{
type: CONST.BREADCRUMB_TYPE.ROOT,
},
{
text: 'Chats',
},
],
};

const FirstBreadcrumbStrong: StoryType = Template.bind({});
FirstBreadcrumbStrong.args = {
breadcrumbs: [
{
text: "Cathy's Croissants",
type: CONST.BREADCRUMB_TYPE.STRONG,
},
{
text: 'Chats',
},
],
};

export default story;
export {Default, FirstBreadcrumbStrong};
33 changes: 31 additions & 2 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,31 @@ const styles = (theme: ThemeColors) =>
justifyContent: 'center',
textDecorationLine: 'none',
},

breadcrumb: {
color: theme.textSupporting,
fontSize: variables.fontSizeh1,
lineHeight: variables.lineHeightSizeh1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting a fixed line height was causing mis-alignment issues when changing the font size, we fixed this in #36655

...headlineFont,
},

breadcrumbStrong: {
color: theme.text,
fontSize: variables.fontSizeXLarge,
},

breadcrumbSeparator: {
color: theme.icon,
fontSize: variables.fontSizeXLarge,
lineHeight: variables.lineHeightSizeh1,
...headlineFont,
},

breadcrumbLogo: {
top: 1.66, // Pixel-perfect alignment due to a small difference between logo height and breadcrumb text height
height: variables.lineHeightSizeh1,
},

LHPNavigatorContainer: (isSmallScreenWidth: boolean) =>
({
width: isSmallScreenWidth ? '100%' : variables.sideBarWidth,
Expand All @@ -1389,6 +1414,7 @@ const styles = (theme: ThemeColors) =>
borderBottomRightRadius: isSmallScreenWidth ? 0 : 24,
overflow: 'hidden',
} satisfies ViewStyle),

RHPNavigatorContainer: (isSmallScreenWidth: boolean) =>
({
width: isSmallScreenWidth ? '100%' : variables.sideBarWidth,
Expand Down Expand Up @@ -3567,12 +3593,15 @@ const styles = (theme: ThemeColors) =>
},

headerEnvBadge: {
marginLeft: 0,
marginBottom: 2,
position: 'absolute',
bottom: -8,
left: -8,
height: 12,
width: 22,
paddingLeft: 4,
paddingRight: 4,
alignItems: 'center',
zIndex: -1,
Comment on lines +3596 to +3604
Copy link
Contributor

@aimane-chnaif aimane-chnaif Dec 15, 2023

Choose a reason for hiding this comment

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

Just to confirm: env badge position is verified by design team?

diff:

env-dev env-stg

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not a blocker for the pr since the badge is only visible in dev or staging

Copy link
Contributor

Choose a reason for hiding this comment

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

ok QA team created dedicated GH for us 🙂 : #33283

},

headerEnvBadgeText: {
Expand Down
4 changes: 4 additions & 0 deletions src/styles/utils/sizing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export default {
maxWidth: 'auto',
},

mw75: {
maxWidth: '75%',
},

mw100: {
maxWidth: '100%',
},
Expand Down
5 changes: 3 additions & 2 deletions src/styles/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ export default {
signInLogoHeight: 34,
signInLogoWidth: 120,
signInLogoWidthLargeScreen: 144,
signInLogoHeightLargeScreen: 108,
signInLogoWidthPill: 132,
tabSelectorButtonHeight: 40,
tabSelectorButtonPadding: 12,
lhnLogoWidth: 108,
lhnLogoHeight: 28,
lhnLogoWidth: 95.09,
lhnLogoHeight: 22.33,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These values are from Figma
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to set a height or can we just set a width and the height will happen automatically?

signInLogoWidthLargeScreenPill: 162,
modalContentMaxWidth: 360,
listItemHeightNormal: 64,
Expand Down
Loading