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

Update drop drown for logged in desktop (library) #2021

Open
wants to merge 9 commits into
base: modularization-main
Choose a base branch
from

Conversation

saengel
Copy link
Contributor

@saengel saengel commented Sep 4, 2024

Description

Updating the user drop down for library logged-in view.

Code Changes

  1. In static/css/s2.css - CSS shifts to get everything working, tested to make sure it doesn't break anything. Commenting out the chevron dropdown (see note below)
  2. static/icons/logged_out.svg - The icon for logged out users.
  3. static/js/Header.jsx - The new logged in dropdown component (<LoggedInDropdown />), rendering it. Fixes also to the module switcher to jive with the adjustment to <DropdownMenu />
  4. static/js/common/DropdownMenu.jsx - Adjusting the dropdown menu component to flexibly allow opening in new tabs vs same window, and accepting an icon component instead of a url for more flexibility.

Notes

  • A subtle shift was introduced to the <DropdownMenu /> component, accepting the icon image (from which the dropdown 'hangs') as a component instead of a url string. This allows for greater flexibility when rendering components like the initials icon. We will need to likely shift some small pieces in other PRs for everything to merge seamlessly, but it should be fairly easy.
  • The hanging chevron was commented out, seems to no longer be in spec. Will return if needed.

@saengel saengel self-assigned this Sep 4, 2024
<DropdownMenuItemWithIcon icon={'/static/icons/library_icon.svg'} textEn={'Library'} textHe={'ספריה'} />
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem url={'//sheets.sefaria.org'}>
<DropdownMenuItem url={'//sheets.sefaria.org'} newTab={true}>
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these double slashes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make the URL not relative (i.e. route to sheets.sefaria.org vs localhost:8000/sheets.sefaria.org). It's a bit hacky, is there a better way to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might be /sheets, confirm with SK.

@@ -40,7 +45,7 @@ const DropdownMenuItemWithIcon = ({icon, textEn, textHe}) => {
);
}

const DropdownMenu = ({children}) => {
const DropdownMenu = ({children, menuIconComponent}) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are you passing in here? another react component as a prop? thats generally not considered a good practice...

Copy link
Contributor

Choose a reason for hiding this comment

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

If you need to be able to insert a dynamic component the way to do it is composability, as we have done with the rest of the menu.
Further break down the top components so you can render the menu icon component inline as children.
For example

  <DropdownMenu>
     <ProfilePic>
     <DropDownMenuContents>
        <DropDownMenuItem>
        .....
     </DropDownMenuContents>
 </DropdownMenu>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out! I didn't realize, and really appreciate learning about better React practices.

I will push back a drop - in this case, I needed parity with the code that renders the "initials" when a profile image is not present, and needed to structure the code this way iirc to enable that in both PRs. Happy to discuss more, and hear your insights as to if there's a better and more proper React way of doing this. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this icon in this PR if the PR is for logged in menu?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mistake, taking out. Thanks for catching :)

<DropdownMenuItemWithIcon icon={'/static/icons/sheets_icon.svg'} textEn={'Sheets'} textHe={'דפים'}/>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem url={'//developers.sefaria.org'}>
<DropdownMenuItem url={'//developers.sefaria.org'} newTab={true}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switch to full URL

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