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
Showing
15 changed files
with
192 additions
and
90 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 +1,63 @@ | ||
"use strict" | ||
|
||
SPArouter = require "spa-router" | ||
# -- Models | ||
Session = require "./models/session" | ||
# -- components | ||
Button = require "./components/button" | ||
Router = require "./components/router" | ||
# -- forms | ||
FormSession = require "./forms/form.session" | ||
# -- Screens | ||
ScreenSession = require "./screens/session" | ||
ScreenConsole = require "./screens/console" | ||
# -- Modules | ||
C = require "./modules/constants" | ||
|
||
App = React.createClass | ||
|
||
# -- States & Properties | ||
getInitialState: -> | ||
session : null | ||
context : "campaigns" | ||
|
||
# -- Lifecycle | ||
componentWillMount: -> | ||
SPArouter.listen | ||
"/session/:id" : (id) => | ||
@setState session: false, context: id | ||
"/:context/:area/:element" : (context, area, element) => | ||
@setState session: true, context: context | ||
"/session/:context" : (context) => | ||
@setState session: false, context: context | ||
"/:context/:area" : (context, area) => | ||
@setState session: true, context: context | ||
"/:context" : (context) => | ||
@setState session: true, context: context | ||
@setState session: true, context: context, area: area | ||
|
||
# -- Events | ||
onSessionSuccess: (data) -> | ||
@setState session: true | ||
SPArouter.path "console" | ||
header_style = @refs.header.getDOMNode().classList | ||
header_style.add "disabled" | ||
header_style.remove "expanded" | ||
setTimeout => | ||
SPArouter.path "campaigns/list" | ||
, C.ANIMATION.DURATION | ||
setTimeout => | ||
header_style.remove "disabled" | ||
, (C.ANIMATION.DURATION * 2) | ||
|
||
onConsoleScroll: (value) -> @setState scrolling: value | ||
|
||
onLogout: -> SPArouter.path "session/login" | ||
|
||
# -- Render | ||
render: -> | ||
<app> | ||
{ | ||
if @state.session | ||
<ScreenConsole context={@state.context}/> | ||
else | ||
<ScreenSession context={@state.context} onSuccess={@onSessionSuccess} /> | ||
} | ||
if @state.session | ||
avatar = "http://soyjavi.com/assets/img/soyjavi.hat.jpg" | ||
else | ||
avatar = "./assets/img/avatar.jpg" | ||
|
||
<app className={"scrolling" if @state.scrolling}> | ||
<header ref="header" | ||
data-flex="horizontal center grow" | ||
data-flex-justify="start" | ||
className={"expanded" unless @state.session}> | ||
<img src={avatar} data-flex-grow="min" onClick={@onLogout}/> | ||
{ | ||
if @state.session | ||
<Router context={@state.context} area={@state.area} /> | ||
else | ||
<FormSession context={@state.context} onSuccess={@onSessionSuccess}/> | ||
} | ||
</header> | ||
{ <ScreenConsole context={@state.context} onScroll={@onConsoleScroll}/> if @state.session } | ||
</app> | ||
|
||
React.render <App />, document.body |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
### | ||
@todo | ||
### | ||
|
||
Button = require "./button" | ||
Navigation = require "./navigation" | ||
C = require "../modules/constants" | ||
|
||
module.exports = React.createClass | ||
|
||
# -- States & Properties | ||
propTypes: | ||
routes : React.PropTypes.array.required | ||
|
||
getDefaultProps: -> | ||
routes : [ | ||
label: "Campaigns", route: "/campaigns/list" | ||
, | ||
label: "Creatives", route: "/creatives/list" | ||
, | ||
label: "Users", route: "/users/list" | ||
, | ||
label: "Deals", route: "/deals/list" | ||
, | ||
label: "Analytics", route: "/analytics" | ||
] | ||
|
||
# -- Render | ||
render: -> | ||
for route in @props.routes | ||
route.className = if route.label.toLowerCase() is @props.context then "active" else "" | ||
for route in subroutes = C.SUBROUTES[@props.context.toUpperCase()] | ||
route.className = if route.label.toLowerCase() is @props.area then "active" else "" | ||
<div> | ||
<div data-flex-grow="max"> | ||
<Navigation routes={@props.routes} role="text"/> | ||
<h1>Console</h1> | ||
<Navigation routes={subroutes} role="text"/> | ||
</div> | ||
<nav data-role="circle"> | ||
<Button caption="+" style="circle primary"/> | ||
<Button caption="?" style="circle secondary"/> | ||
</nav> | ||
</div> |
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
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,15 @@ | ||
form | ||
padding : SPACE | ||
// -- Classes | ||
&.session | ||
max-width : 25vw | ||
> * | ||
margin-bottom : (SPACE / 2) | ||
|
||
h1 | ||
padding : 0 | ||
input | ||
font-size : FONT_SIZE_BIG !important | ||
a | ||
text-align : center | ||
font-size : FONT_SIZE_TINY |
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
Oops, something went wrong.