question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Project selector and user menu

See original GitHub issue

Project Selector and User Menu

Project selector: https://trello.com/c/hMNW8dop User menu: https://trello.com/c/VSs4XyMC

There are two possible APIs.

Proposed API 1

The first option is to make 2 simple components, a ProjectSelector and a UserMenu (naming open for discussion). These are just the clickable parts of the header bar, which trigger context menus. This has the advantage of allowing each option in the menus to have its own onClick method, since, unlike in a Select dropdown component, the actions might be completely different. For example, one might open a pop-up, another might navigate to a new screen, etc. Since this is only really necessary for the user menu, we could enable an onClick prop within the ContextMenu as a shortcut which passes the same method on to all ContextMenuItems.

<ContextMenu>
  <ProjectSelector>Click here</ProjectSelector>
  <ContextMenuItem onClick={() => alert("clicked")}>Menu 1</ContextMenuItem>
  <ContextMenuItem onClick={() => alert("clicked")}>Menu 2</ContextMenuItem>
  <ContextMenuItem onClick={() => alert("clicked")}>Menu 3</ContextMenuItem>
</ContextMenu>

OR:

<ContextMenu onClick={() => alert(“clicked”)}>
  <HeaderMenu>Click here</HeaderMenu>
  <ContextMenuItem>Menu 1</ContextMenuItem>
  <ContextMenuItem>Menu 2</ContextMenuItem>
  <ContextMenuItem>Menu 3</ContextMenuItem>
</ContextMenu>

Proposed API 2

The other alternative is to create 2 more complex components which use ContextMenu internally. This would simplify things for the end user.

const projectOptions = [
  { key: “project1”, label: “Project 1” },
  { key: “project2”, label: “Project 2” },
  { key: “project3”, label: “Project 3” },
]
<ProjectSelector options={projectOptions} active={this.state.activeProject}></ProjectSelector>

const userOptions = [
  { label: “My account”, onClick: () => {…} },
  { label: “Logout”, onClick: () => {…} },
]
<UserMenu options={userOptions}></UserMenu>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ImogenFcommented, Jul 9, 2018
1reaction
ImogenFcommented, Jul 6, 2018

Even if we have a footer menu in the future, that would need to behave a bit differently, wouldn’t it? Context menu would have to expand upwards, etc. And the styling might be different too. Not sure it’s worth worrying about that too much right now.

So I’ll go ahead and work on this for now, if anyone objects or has any other improvements to suggest please let me know!

Read more comments on GitHub >

github_iconTop Results From Across the Web

DITA: Add a menu selector | I'd Rather Be Writing Blog
The menu selector is a simple menu that allows users to select other options. When a user selects an option, the URL switches...
Read more >
Adding Menus and Shortcuts to the Menu Bar and User Interface
This sample project demonstrates how to add menu commands and keyboard shortcuts to the menu bar. The sample app uses its MenuController object...
Read more >
Menus - Android Developers
Stay organized with collections Save and categorize content based on your preferences. Menus are a common user interface component in many ...
Read more >
Favoriting and hiding system projects - OpenShift Design
Assuming the switch is hiding system projects, if a user were to navigate to a resource page that exists in a system project,...
Read more >
Portfolio (Project) and Team selectors | Targetprocess
Portfolio (Project) and Teams default selectors; Open views with the currently selected Portfolios (Projects) and Teams; Advanced use cases. Portfolio (Project) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found