These are chat archives for chandu0101/scalajs-react-components

2nd
Nov 2015
Janos Haber
@b0c1
Nov 02 2015 10:25
I want to create a left nav bar, which will hide when the screen with is not enough (like material-ui)... but how can I do that?
Zach Langbert
@zlangbert
Nov 02 2015 15:33
You would need to either use css media queries or listen to the window resize event in js
Janos Haber
@b0c1
Nov 02 2015 20:09
hmm... ok
@zlangbert I created a MenuItem with route, and I have a router
but when I click to the menu item, nothing happened
no error or something... just nothing happened
  lazy private val menuItems = js.Array(
    MuiMenuItem(route = "/", text = "Test"),
    MuiMenuItem(route = "/user-details", text = "User details")
  )
And the router
        | staticRoute(root, Test) ~> render(TestComponent.component())
        | staticRoute("/user-details", UserDetails) ~> render(UserDetailsComponent.component())
I miss something?
Zach Langbert
@zlangbert
Nov 02 2015 20:19
I'm not sure how that routes on the menu item are supposed to work
Janos Haber
@b0c1
Nov 02 2015 20:19
ehh :)
but MenuItem have route property :D
Zach Langbert
@zlangbert
Nov 02 2015 20:23
yeah, and I remember at one point I went digging in the material-ui source to try to figure out what it did, and I couldn't figure it out
Janos Haber
@b0c1
Nov 02 2015 20:23
hmm... in this case what is the best way to navigate using MenuItem?
Zach Langbert
@zlangbert
Nov 02 2015 20:24
You need to generate links from the scalajs-router and put them in your menu items
Janos Haber
@b0c1
Nov 02 2015 20:24
ohh... ok
Zach Langbert
@zlangbert
Nov 02 2015 20:26
but you don't just want the urls
here's an example from my code
MenuItem(
  "Foo",
  onClick = ((e: ReactEventH) => {
    val target = Routes.Root.Nest(FooRoutes.Root)
    props.routerCtl.set(target).runNow()
  }): js.Function1[ReactEventH, _]
)
Janos Haber
@b0c1
Nov 02 2015 20:26
ty
Zach Langbert
@zlangbert
Nov 02 2015 20:26
np, you just need to make sure you are using the "v2" menu
Janos Haber
@b0c1
Nov 02 2015 20:36
@zlangbert ummm... MuiMenuItem doesn't have onClick... :D
Zach Langbert
@zlangbert
Nov 02 2015 20:44
it does in my own material-ui facade :p
Janos Haber
@b0c1
Nov 02 2015 23:03
@zlangbert can you help me a little in autowire? I created a route, everything is ok, except it's not work :D
Router.route[T](apiImpl)(
        autowire.Core.Request(path.split("/"),Unpickle[Map[String,ByteBuffer]].fromBytes(ByteBuffer.wrap(b)))
      ).map(buffer => {
      val data = Array.ofDim[Byte](buffer.remaining())
      buffer.get(data)
      Ok(data)
    })
this is my router code (from @ochrons SPA sample)

This is my API

trait UserAPI {
  def user(): UserView
}

and this is the error

Caused by: scala.MatchError: Request(WrappedArray(hu, finesolution, zerolibrary, api, UserAPI, user),Map()) (of class autowire.Core$Request)
Zach Langbert
@zlangbert
Nov 02 2015 23:34
Why route[T]? That's not going to work I don't think
Janos Haber
@b0c1
Nov 02 2015 23:34
yeah, I checked the source... macro will not work like this
now this is the result :D
    internalRoute(path, request) {
      Router.route[UserAPI](new UserAPIImpl(request.identity, request.authenticator, client))
    }
Zach Langbert
@zlangbert
Nov 02 2015 23:41
I wanted to do the same thing and found out that it didn't support that also :/
Janos Haber
@b0c1
Nov 02 2015 23:42
the latest snippet works...
Zach Langbert
@zlangbert
Nov 02 2015 23:59
Sorry, I meant using a type parameter, i.e def route[T](impl: T) = ???