forked from chandu0101/sri-web-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7f303e
commit 7a65657
Showing
16 changed files
with
265 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
sbt.version=0.13.8 | ||
sbt.version=0.13.9 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.6") | ||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.9") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package sri.templates.web.components | ||
|
||
import sri.core._ | ||
import sri.web.all._ | ||
import sri.web.vdom.htmltags._ | ||
|
||
import scala.scalajs.js | ||
|
||
object Button { | ||
|
||
val Component = (props: Props,children : ReactElement) => { | ||
div(className = props.style, onClick = (e: ReactMouseEventH) => props.onPress())(children) | ||
} | ||
|
||
case class Props(style: String, onPress: () => _) | ||
|
||
def apply(style: String, onPress: () => _,key : js.UndefOr[String] = js.undefined)(children : ReactNode*) = createStatelessFunctionElementWithChildren(Component, Props(style, onPress),key = key)(children : _*) | ||
|
||
} |
42 changes: 0 additions & 42 deletions
42
src/main/scala/sri/templates/web/components/HelloWeb.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package sri.templates.web.components | ||
|
||
import sri.scalacss.Defaults._ | ||
import sri.templates.web.routes.AppRouter.HomePage | ||
import sri.templates.web.styles.Colors | ||
import sri.web.all._ | ||
import sri.web.router.{WebDynamicPage, WebRouterComponent, WebStaticPage} | ||
import sri.web.vdom.htmltags._ | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.Dynamic.{literal => json} | ||
import scala.scalajs.js.annotation.ScalaJSDefined | ||
import scala.scalajs.js.{UndefOr => U} | ||
import scalacss.Defaults._ | ||
|
||
object TopNav { | ||
|
||
@ScalaJSDefined | ||
class Component extends WebRouterComponent[Unit, Unit] { | ||
def render() = { | ||
div(className = styles.navMenu)( | ||
getStaticItem("Home", HomePage)) | ||
} | ||
|
||
def getStaticItem(text: String, page: WebStaticPage, query: js.UndefOr[js.Object] = js.undefined, state: js.UndefOr[js.Object] = js.undefined) = { | ||
Button(style = styles.menuItem(page == currentRoute.page), | ||
onPress = () => navigateTo(page, query = query, state = state))( | ||
span()(text) | ||
) | ||
} | ||
|
||
def getDynamicItem(text: String, page: WebDynamicPage[_], placeholder: String, query: js.UndefOr[js.Object] = js.undefined, state: js.UndefOr[js.Object] = js.undefined) = { | ||
Button(style = styles.menuItem(page == currentRoute.page), | ||
onPress = () => navigateToDynamic(page, placeholder = placeholder, query = query, state = state))( | ||
span()(text) | ||
) | ||
} | ||
} | ||
|
||
@ScalaJSDefined | ||
class StaticQuery(val sorting: String, val option: js.UndefOr[String] = js.undefined) extends js.Object | ||
|
||
|
||
object styles extends StyleSheet.Inline { | ||
|
||
import dsl._ | ||
|
||
val navMenu = style(display.flex, | ||
flexDirection.row, | ||
alignItems.center, | ||
backgroundColor :=! Colors.gold, | ||
margin.`0`, | ||
height(60.px), | ||
paddingLeft(40 px)) | ||
|
||
val menuItem = styleF.bool(selected => { | ||
styleS(padding(20.px), | ||
fontSize :=! "1.5em", | ||
cursor.pointer, | ||
color :=! c"rgb(244, 233, 233)", | ||
marginLeft(10.px), | ||
marginRight(10.px), | ||
mixinIfElse(selected)(backgroundColor :=! Colors.darkGold, | ||
fontWeight._500)(backgroundColor :=! Colors.transparent, | ||
fontWeight.normal) | ||
) | ||
}) | ||
|
||
|
||
} | ||
|
||
|
||
val ctor = getTypedConstructor(js.constructorOf[Component], classOf[Component]) | ||
|
||
ctor.contextTypes = sri.web.router.routerContextTypes | ||
|
||
|
||
def apply(ref: js.UndefOr[String] = "", key: js.Any = {}) = createElementNoProps(ctor) | ||
|
||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package sri.templates.web.routes | ||
|
||
import sri.core.ReactElement | ||
import sri.scalacss.Defaults._ | ||
import sri.templates.web.components._ | ||
import sri.templates.web.screens.HomeScreen | ||
import sri.templates.web.styles.GlobalStyle | ||
import sri.web.router._ | ||
import sri.web.vdom.htmltags._ | ||
object AppRouter { | ||
|
||
object HomePage extends WebStaticPage | ||
|
||
|
||
object Config extends WebRouterConfig { | ||
|
||
override val history: History = HistoryFactory.browserHistory() | ||
|
||
override val initialRoute: (WebStaticPage, WebRoute) = defineInitialRoute(HomePage, (route: WebRoute) => HomeScreen()) | ||
|
||
|
||
override val notFound: WebRouteNotFound = WebRouteNotFound(HomePage) | ||
|
||
/** | ||
* this method is responsible for rendering components , | ||
* @param route current route that is pushed to stack | ||
* @return | ||
*/ | ||
override def renderScene(route: WebRoute): ReactElement = { | ||
div(className = GlobalStyle.flexOneAndDirectionVertical)( | ||
TopNav(), | ||
super.renderScene(route) | ||
) | ||
} | ||
} | ||
|
||
val router = WebRouter(Config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package sri.templates.web.screens | ||
|
||
import sri.templates.web.styles.GlobalStyle | ||
import sri.web.all._ | ||
import sri.web.vdom.htmltags._ | ||
import sri.core._ | ||
import sri.universal.components._ | ||
import sri.web.all._ | ||
import sri.web.vdom.htmltags._ | ||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation.ScalaJSDefined | ||
import scala.scalajs.js.{UndefOr => U, undefined => undefined} | ||
import scalacss.Defaults._ | ||
import sri.scalacss.Defaults._ | ||
|
||
object HomeScreen { | ||
|
||
@ScalaJSDefined | ||
class Component extends ReactComponent[Unit, Unit] { | ||
def render() = div(className = GlobalStyle.flexOneAndCenter)( | ||
span(className = GlobalStyle.bigText)("Home Screen") | ||
) | ||
} | ||
|
||
val ctor = getTypedConstructor(js.constructorOf[Component], classOf[Component]) | ||
|
||
def apply(key: js.UndefOr[String] = js.undefined, ref: js.Function1[Component, _] = null) = createElementNoProps(ctor, key = key, ref = ref) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package sri.templates.web.styles | ||
|
||
|
||
import sri.scalacss.Defaults._ | ||
import sri.templates.web.components.TopNav | ||
|
||
import scalacss.Defaults._ | ||
import scalacss.mutable.GlobalRegistry | ||
|
||
object AppStyles { | ||
|
||
def load() = { | ||
GlobalRegistry.register(GlobalStyle, | ||
TopNav.styles) | ||
GlobalRegistry.addToDocumentOnRegistration() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package sri.templates.web.styles | ||
|
||
object Colors { | ||
|
||
val blue = "#0B8AA9" | ||
|
||
val darkBlue = "#126884" | ||
|
||
|
||
val gold = "#D09527" | ||
|
||
val darkGold = "#D86D1F" | ||
|
||
val transparent = "transparent" | ||
|
||
val lightGrey = "#DAD5D5" | ||
} |
Oops, something went wrong.