Skip to content

Navbar dropdown component#17

Open
antonTan96 wants to merge 4 commits into
mainfrom
navbar-dropdown
Open

Navbar dropdown component#17
antonTan96 wants to merge 4 commits into
mainfrom
navbar-dropdown

Conversation

@antonTan96

Copy link
Copy Markdown

No description provided.

@marcus-ong-qy marcus-ong-qy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do delete package-lock.json. And remember next time pull req add some screenshots ya

Do make the textboxes bigger, text looks cramped right now. Refer to the figma file!
image

Also, when mouseover text enlarge they overflow the dropdown, which is bad
image

In general not bad! Basic idea is there but just need refinements

Comment thread components/NavBar.tsx
key={index}
text={item}
isActive={item.toLowerCase() === pageName || (item === 'Home' && pageName === '')}
isDropdown={item.toLowerCase() === 'about us'}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok acceptable for now

Comment thread components/NavItem.tsx

{dropdown && (
<DropdownDiv>
{dropdownTitles.map((item, index) => (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice attempt to abstract the dropdown titles! should work for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

but think what if we want to have multiple tabs on the navbar to have different dropdown menus? and how you store information such as which URL will each dropdown option direct to

Comment thread components/NavItem.tsx
Comment on lines +125 to +131
<NavItem
key={index}
text={item}
isDropdown={item.toLowerCase() === 'about us'}
href={item === 'Home' ? '/' : `/${item.toLowerCase()}`}
isInColumn={isInColumn}
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm you should create a new component for dropdown item instead of just reusing the navbar NavItem component!

Comment thread components/NavItem.tsx
Comment on lines +111 to +144
if (isDropdown) {
return (
<StyledNavItem
href={href ?? ''}
isActive={isActive}
fontType={h3}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
>
<div>{text}</div>

{dropdown && (
<DropdownDiv>
{dropdownTitles.map((item, index) => (
<NavItem
key={index}
text={item}
isDropdown={item.toLowerCase() === 'about us'}
href={item === 'Home' ? '/' : `/${item.toLowerCase()}`}
isInColumn={isInColumn}
/>
))}
</DropdownDiv>
)}
</StyledNavItem>
)
}
if (isInColumn) {
return (
<ColumnNavItemContainer href={href ?? ''} isActive={isActive} fontType={h3}>
{text}
</ColumnNavItemContainer>
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of putting rerturns within if else statement what you could do is:

  1. Abstract the components that you want to render on certain conditions only (i.e. the dropdown)
  2. Have only ONE return statement
  3. In the return statement, do something like isDropdown && <Dropdown />. This will then only render the dropdown when the argument isDropdown is set to true

@@ -0,0 +1 @@
export const dropdownTitles = ['Text1', 'Text2', 'Text3', 'Text4']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm actually you can put this under the navTitles.ts file together

Comment thread components/NavItem.tsx
Comment on lines +103 to +109
const onMouseLeave = () => {
if (window.innerWidth < 960) {
setDropdown(false)
} else {
setDropdown(false)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

both is the same??????????

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants