Skip to content

Commit 2335563

Browse files
fix(navbar): no item position (#9007)
* fix(navbar): no item position * Update index.module.css
1 parent cf4aa62 commit 2335563

3 files changed

Lines changed: 76 additions & 25 deletions

File tree

‎packages/ui-components/src/Containers/NavBar/index.module.css‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@
3939
}
4040

4141
.sidebarItemTogglerLabel {
42-
@apply block
42+
@apply ml-auto
43+
block
4344
cursor-pointer
44-
xl:hidden;
45-
46-
.navInteractionIcon {
47-
@apply size-6;
48-
}
45+
xl:hidden; /* Push toggler to the right if Logo exists */
4946
}
5047
}
5148

49+
.navInteractionIcon {
50+
@apply size-6;
51+
}
52+
5253
.sidebarItemToggler {
5354
@apply absolute
5455
right-4
@@ -62,11 +63,11 @@
6263
.main {
6364
@apply flex-1
6465
flex-col
65-
justify-between
6666
gap-4
6767
xl:flex
6868
xl:flex-row
69-
xl:items-center;
69+
xl:items-center
70+
xl:justify-between;
7071
}
7172

7273
.navItems {
@@ -86,6 +87,7 @@
8687

8788
.actionsWrapper {
8889
@apply flex
90+
w-full
8991
flex-row
9092
flex-wrap
9193
items-center
@@ -95,6 +97,7 @@
9597
border-neutral-200
9698
p-4
9799
sm:flex-nowrap
100+
xl:ml-auto
98101
xl:basis-96
99102
xl:border-0
100103
xl:p-0

‎packages/ui-components/src/Containers/NavBar/index.stories.tsx‎

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,61 @@
1+
import Logo from '#ui/Common/NodejsLogo';
2+
import SearchModal from '#ui/Common/Search/Modal';
13
import NavBar from '#ui/Containers/NavBar';
24

35
import type { Meta as MetaObj, StoryObj } from '@storybook/react-webpack5';
46

57
type Story = StoryObj<typeof NavBar>;
68
type Meta = MetaObj<typeof NavBar>;
79

8-
const common = {
9-
as: 'a',
10-
Logo: 'a',
11-
pathname: '/',
10+
export const Default: Story = {
11+
args: {
12+
as: 'a',
13+
Logo,
14+
pathname: '/',
15+
children: <SearchModal client={null} placeholder="Search the docs..." />,
16+
navItems: [
17+
{
18+
text: 'Learn',
19+
link: '/',
20+
},
21+
{
22+
text: 'About',
23+
link: '/about',
24+
},
25+
{
26+
text: 'Docs',
27+
link: '/docs',
28+
},
29+
{
30+
text: 'Download',
31+
link: '/download',
32+
},
33+
{
34+
text: 'Blog',
35+
link: '/blog',
36+
},
37+
{
38+
text: 'Certification',
39+
link: 'https://openjsf.org/certification',
40+
},
41+
],
42+
},
43+
};
1244

13-
children: <a>Some other child</a>,
14-
} as const;
45+
export const NoNavItems: Story = {
46+
args: {
47+
as: 'a',
48+
Logo,
49+
pathname: '/',
50+
children: <SearchModal client={null} placeholder="Search the docs..." />,
51+
},
52+
};
1553

16-
export const Default: Story = {
54+
export const NoLogo: Story = {
1755
args: {
18-
...common,
56+
as: 'a',
57+
pathname: '/',
58+
children: <SearchModal client={null} placeholder="Search the docs..." />,
1959
navItems: [
2060
{
2161
text: 'Learn',
@@ -45,6 +85,12 @@ export const Default: Story = {
4585
},
4686
};
4787

48-
export const NoNavItems: Story = { args: common };
88+
export const NoLogoNoNavItems: Story = {
89+
args: {
90+
as: 'a',
91+
pathname: '/',
92+
children: <SearchModal client={null} placeholder="Search the docs..." />,
93+
},
94+
};
4995

5096
export default { component: NavBar } as Meta;

‎packages/ui-components/src/Containers/NavBar/index.tsx‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type NavbarProps = {
3939
link: string;
4040
target?: HTMLAttributeAnchorTarget | undefined;
4141
}>;
42-
Logo: ElementType;
42+
Logo?: ElementType;
4343
as: LinkLike;
4444
pathname: string;
4545
sidebarItemTogglerAriaLabel: string;
@@ -61,13 +61,15 @@ const NavBar: FC<PropsWithChildren<NavbarProps>> = ({
6161
<nav className={styles.container}>
6262
<div className={styles.innerContainer}>
6363
<div className={styles.nodeIconAndMobileItemsToggler}>
64-
<Component
65-
className={styles.nodeIconWrapper}
66-
href="/"
67-
aria-label="Home"
68-
>
69-
<Logo />
70-
</Component>
64+
{Logo && (
65+
<Component
66+
className={styles.nodeIconWrapper}
67+
href="/"
68+
aria-label="Home"
69+
>
70+
<Logo />
71+
</Component>
72+
)}
7173

7274
<Label.Root
7375
className={styles.sidebarItemTogglerLabel}

0 commit comments

Comments
 (0)