Skip to content

Instantly share code, notes, and snippets.

@japgolly
Created February 28, 2015 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save japgolly/78507c5953d8f848f63c to your computer and use it in GitHub Desktop.
Save japgolly/78507c5953d8f848f63c to your computer and use it in GitHub Desktop.
Basic bootstrap NavBar model
// In Link & MenuItem, when onClick is None it means it should be disabled.
// This enforces the invariant that disabled items cannot be clicked.
// If you want something clickable but you want it to do nothing then pass it
// a callback that does nothing: Some(IO(()))
sealed trait NavItem
case class Link(label: String, onClick: Option[IO[Unit]], active: Boolean) extends NavItem
case class DropdownMenu(items: NonEmptyList[MenuItem]) extends NavItem
sealed trait MenuItem
case object MenuDivider extends MenuItem
case class MenuEntry(label: String, onClick: Option[IO[Unit]]) extends MenuItem
case class NavBarProps(items: NonEmptyList[NavItem], disableEverything: Boolean)
val NavBar =
ReactComponentB[NavBarProps]("NavBar")
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment