@@ -16,19 +16,41 @@ object Router0 {
1616 given codec : JsonValueCodec [Page ] = JsonCodecMaker .make
1717
1818 private val routes = List (
19- Route .static(LivePage , root / endOfSegments, dom.window.location.pathname + " #" ),
20- Route .static(EditPage , root / " edit" / endOfSegments, dom.window.location.pathname + " #" ),
21- Route .static(ViewPage , root / " view" / endOfSegments, dom.window.location.pathname + " #" ),
22- Route .static(HelpPage , root / " help" / endOfSegments, dom.window.location.pathname + " #" )
19+ Route .static(
20+ LivePage ,
21+ root / endOfSegments,
22+ dom.window.location.pathname + " #"
23+ ),
24+ Route .static(
25+ EditPage ,
26+ root / " edit" / endOfSegments,
27+ dom.window.location.pathname + " #"
28+ ),
29+ Route .static(
30+ ViewPage ,
31+ root / " view" / endOfSegments,
32+ dom.window.location.pathname + " #"
33+ ),
34+ Route .static(
35+ HelpPage ,
36+ root / " help" / endOfSegments,
37+ dom.window.location.pathname + " #"
38+ )
2339 )
2440
2541 val router = new Router [Page ](
2642 routes = routes,
2743 getPageTitle = _.title, // displayed in the browser tab next to favicon
28- serializePage = page => writeToString(page), // serialize page data for storage in History API log
29- deserializePage = pageStr => readFromString(pageStr) // deserialize the above
44+ serializePage = page =>
45+ writeToString(
46+ page
47+ ), // serialize page data for storage in History API log
48+ deserializePage = pageStr =>
49+ readFromString(pageStr) // deserialize the above
3050 )(
31- popStateEvents = windowEvents(_.onPopState), // this is how Waypoint avoids an explicit dependency on Laminar
51+ popStateEvents = windowEvents(
52+ _.onPopState
53+ ), // this is how Waypoint avoids an explicit dependency on Laminar
3254 owner = unsafeWindowOwner // this router will live as long as the window
3355 )
3456
@@ -47,9 +69,10 @@ object Router0 {
4769 // Otherwise:
4870 // - Perform regular pushState transition
4971 (onClick
50- .filter(ev => ! (isLinkElement && (ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.altKey)))
72+ .filter(ev =>
73+ ! (isLinkElement && (ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.altKey))
74+ )
5175 .preventDefault
52- --> (_ => router.pushState(page))
53- ).bind(el)
76+ --> (_ => router.pushState(page))).bind(el)
5477 }
55- }
78+ }
0 commit comments