Skip to content

Commit 818748f

Browse files
authored
feat(MainNavigationBar): topSlot support (#1518)
WEB-2378
1 parent 229ace4 commit 818748f

11 files changed

Lines changed: 119 additions & 10 deletions

playroom/snippets.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,21 @@ const navigationBarSnippets = [
26772677
name: 'MainNavigationBar',
26782678
code: `
26792679
<MainNavigationBar
2680+
topSlotBackgroundColor={colors.backgroundNegative}
2681+
topSlot={
2682+
<ThemeVariant variant="negative">
2683+
<Box paddingY={8}>
2684+
<Align x="center">
2685+
<Inline space={24} alignItems="center">
2686+
<Text2 medium>BLACK FRIDAY - 60% en tecnología</Text2>
2687+
<ButtonSecondary small onPress={() => {}}>
2688+
See offers
2689+
</ButtonSecondary>
2690+
</Inline>
2691+
</Align>
2692+
</Box>
2693+
</ThemeVariant>
2694+
}
26802695
sections={[
26812696
{
26822697
title: "Start",
Loading
Loading
Loading
Loading
Loading

src/__screenshot_tests__/navigation-bar-screenshot-test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,42 @@ test('MainNavigationBar wide', async () => {
8888
expect(await page.screenshot()).toMatchImageSnapshot();
8989
});
9090

91+
test('MainNavigationBar desktop with topSlot', async () => {
92+
const page = await openStoryPage({
93+
id: 'components-navigation-bars-mainnavigationbar--default',
94+
device: 'DESKTOP',
95+
args: {topSlot: true, desktopLargeMenu: true, menu: 'default'},
96+
});
97+
98+
expect(await page.screenshot()).toMatchImageSnapshot();
99+
100+
await page.click(await screen.findByRole('button', {name: 'Start'}));
101+
expect(await page.screenshot()).toMatchImageSnapshot();
102+
});
103+
104+
test('MainNavigationBar mobile with topSlot', async () => {
105+
const page = await openStoryPage({
106+
id: 'components-navigation-bars-mainnavigationbar--default',
107+
device: 'MOBILE_IOS',
108+
args: {topSlot: true},
109+
});
110+
111+
expect(await page.screenshot()).toMatchImageSnapshot();
112+
113+
await page.click(await screen.findByRole('button', {name: 'Abrir menú de navegación'}));
114+
expect(await page.screenshot()).toMatchImageSnapshot();
115+
});
116+
117+
test('MainNavigationBar desktop with topSlot and custom background', async () => {
118+
const page = await openStoryPage({
119+
id: 'components-navigation-bars-mainnavigationbar--default',
120+
device: 'DESKTOP',
121+
args: {topSlot: true, topSlotBackgroundColor: '#FABADA'},
122+
});
123+
124+
expect(await page.screenshot()).toMatchImageSnapshot();
125+
});
126+
91127
test.each`
92128
variant | isDarkMode | device
93129
${'default'} | ${false} | ${'DESKTOP'}

src/__stories__/main-navigation-bar-story.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type Args = {
4141
menu: 'undefined' | 'default' | 'custom';
4242
desktopLargeMenu: boolean;
4343
customLogo: boolean;
44+
topSlot: boolean;
45+
topSlotBackgroundColor: string;
4446
wide: boolean;
4547
paddingX: PadSize | 'undefined';
4648
};
@@ -54,6 +56,8 @@ export const Default: StoryComponent<Args> = ({
5456
menu,
5557
desktopLargeMenu,
5658
customLogo,
59+
topSlot,
60+
topSlotBackgroundColor,
5761
wide,
5862
paddingX,
5963
}) => {
@@ -68,6 +72,8 @@ export const Default: StoryComponent<Args> = ({
6872
burgerMenuExtra={burgerMenuExtra ? <Placeholder /> : undefined}
6973
desktopLargeMenu={desktopLargeMenu}
7074
logo={customLogo ? <Placeholder width={40} height={40} /> : undefined}
75+
topSlot={topSlot ? <Placeholder height={24} /> : undefined}
76+
topSlotBackgroundColor={topSlotBackgroundColor || undefined}
7177
sections={
7278
sections
7379
? sectionTitles.map((title, idx) => ({
@@ -139,6 +145,8 @@ Default.args = {
139145
menu: 'undefined',
140146
desktopLargeMenu: false,
141147
customLogo: false,
148+
topSlot: false,
149+
topSlotBackgroundColor: '',
142150
wide: false,
143151
paddingX: 'undefined',
144152
};
@@ -154,6 +162,10 @@ Default.argTypes = {
154162
if: {arg: 'sections'},
155163
},
156164
desktopLargeMenu: {if: {arg: 'sections'}},
165+
topSlotBackgroundColor: {
166+
control: {type: 'color'},
167+
if: {arg: 'topSlot'},
168+
},
157169
paddingX: {
158170
options: ['undefined', 8, 12, 16, 20, 24, 32, 40, 48, 56, 64, 72, 80],
159171
control: {type: 'select'},

src/box.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type BoxProps = {
1717
paddingBottom?: ByBreakpoint<PadSize>;
1818
paddingLeft?: ByBreakpoint<PadSize>;
1919
paddingRight?: ByBreakpoint<PadSize>;
20+
background?: string;
2021
as?: React.ComponentType<any> | string;
2122
children?: React.ReactNode;
2223
/**
@@ -46,6 +47,7 @@ const Box = React.forwardRef<HTMLDivElement, BoxProps>(
4647
paddingBottom = paddingY,
4748
paddingLeft = paddingX,
4849
paddingRight = paddingX,
50+
background,
4951
role,
5052
id,
5153
dataAttributes,
@@ -99,6 +101,7 @@ const Box = React.forwardRef<HTMLDivElement, BoxProps>(
99101
...applyPaddingVars(styles.vars.paddingLeft, paddingLeftValues),
100102
...applyPaddingVars(styles.vars.paddingRight, paddingRightValues),
101103
...(width !== undefined ? {width, boxSizing: 'border-box'} : {}),
104+
background,
102105
}}
103106
id={id}
104107
>

src/navigation-bar.css.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ export const burgerMenuButton = style({
401401

402402
export const burgerMenu = sprinkles({
403403
position: 'fixed',
404-
top: NAVBAR_HEIGHT_MOBILE,
405404
left: 0,
406405
right: 0,
407406
bottom: 0,

0 commit comments

Comments
 (0)