-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[NoQA] [Wave8] Breadcrumbs #32221
Changes from all commits
6f3fc56
ced4c37
0bfd97e
6c66b08
ce3c4ea
5209597
fbd4789
1218a42
a8a2e38
857c104
737480f
08cd12b
a81da06
87b5b5b
125626a
694d6ad
1dba8b0
5dbffff
8e3309c
9467923
c276ae2
74d8e2b
3c415dc
fdad0cc
3dd6fca
d0fd4a6
fa46d37
d121272
62f576b
6eb2110
2fdbd74
3d394ff
0383f26
90304da
0a9afd7
333fb45
7c7051c
bb7dda3
27357f4
9a0c2e0
e5cc42e
22864a4
39784fb
f14e7b4
e0cef1a
0d30c94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; |
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}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1379,6 +1379,31 @@ const styles = (theme: ThemeColors) => | |
justifyContent: 'center', | ||
textDecorationLine: 'none', | ||
}, | ||
|
||
breadcrumb: { | ||
color: theme.textSupporting, | ||
fontSize: variables.fontSizeh1, | ||
lineHeight: variables.lineHeightSizeh1, | ||
...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, | ||
|
@@ -1389,6 +1414,7 @@ const styles = (theme: ThemeColors) => | |
borderBottomRightRadius: isSmallScreenWidth ? 0 : 24, | ||
overflow: 'hidden', | ||
} satisfies ViewStyle), | ||
|
||
RHPNavigatorContainer: (isSmallScreenWidth: boolean) => | ||
({ | ||
width: isSmallScreenWidth ? '100%' : variables.sideBarWidth, | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok QA team created dedicated GH for us 🙂 : #33283 |
||
}, | ||
|
||
headerEnvBadgeText: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,10 @@ export default { | |
maxWidth: 'auto', | ||
}, | ||
|
||
mw75: { | ||
maxWidth: '75%', | ||
}, | ||
|
||
mw100: { | ||
maxWidth: '100%', | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
There was a problem hiding this comment.
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