Permalink
Browse files

New module Toolbar (mostly taking over previous Login).

  • Loading branch information...
akoprow committed May 10, 2011
1 parent e8a51e3 commit ff2db734dd62b65eb3ec2a75a577bc1efaa8008b
Showing with 55 additions and 48 deletions.
  1. +2 −9 src/main.opa
  2. +1 −19 src/pages.opa
  3. +51 −19 src/{login.opa → toolbar.opa}
  4. +1 −1 src/twopenny.opack
View
@@ -10,22 +10,15 @@ package mlstate.twopenny
**/
twopenny_page((title, content, style))(_req) =
- status =
- <div id=#status_container>
- <div id=#status>
- <div id=#loginbox>
- {Login.html()}
- </>
- </>
- </>
+ toolbar = Toolbar.html()
page =
<div id=#page>
<div id=#main>
{content}
</>
</>
|> apply_css(style, _)
- body = <>{status}{page}</>
+ body = <>{toolbar}{page}</>
Resource.html(title, body)
resources = @static_include_directory("img")
View
@@ -57,7 +57,7 @@ Pages = {{
}}
-css = [ page_css, login_css, msg_css, msg_box_css, user_css ]
+css = [ page_css, toolbar_css, msg_css, msg_box_css, user_css ]
page_css = css
body, html, #page {
@@ -68,21 +68,6 @@ page_css = css
margin: 0px;
position: relative;
}
- #status_container {
- position: fixed;
- top: 0px;
- overflow: hidden;
- width: 100%;
- height: 30px;
- z-index: 9999;
- border: 1px dotted black;
- border-top: none;
- background: #666;
- }
- #status {
- width: 600px;
- margin: auto;
- }
#page {
padding-top: 30px;
}
@@ -96,9 +81,6 @@ page_css = css
background: #EEE;
opacity: .8;
}
- #loginbox {
- float: right;
- }
h2 {
color: #777;
/* FIXME writing helvetica (small 'h') passes syntax checking and is interpreted
@@ -8,15 +8,15 @@ package mlstate.twopenny
import widgets.{loginbox, switch}
import components.login
-type Login.credentials = option((string, string))
+type Toolbar.state = option(User.ref)
-type Login.state = option(User.ref)
+type Login.credentials = option((string, string))
-type Login.config = CLogin.config(Login.credentials, Login.state, Login.state)
+type Login.config = CLogin.config(Login.credentials, Toolbar.state, Toolbar.state)
-type Login.component = CLogin.t(Login.credentials, Login.state, Login.state)
+type Login.component = CLogin.t(Login.credentials, Toolbar.state, Toolbar.state)
-Login =
+Toolbar =
dom_id = "login"
@@ -25,11 +25,11 @@ Login =
{{
- @private guest_state : Login.state =
+ @private guest_state : Toolbar.state =
none
- @publish @server authenticate(cred : Login.credentials, state : Login.state)
- : option(Login.state) =
+ @publish @server authenticate(cred : Login.credentials, state : Toolbar.state)
+ : option(Toolbar.state) =
do Log.debug("[LOGIN]", "authentication: [{cred}]")
match cred with
| {none} -> none
@@ -51,19 +51,27 @@ Login =
@private login_conf : Login.config =
CLogin.default_config(Random.string(8), authenticate)
+ login_btn_cfg = WButton.default_config
+
login : Login.component =
CLogin.make(guest_state, login_conf)
login_box() =
+ btn_txt = "Register"
+ onclick = ({click}, (_ -> void))
+ signup = WButton.html(login_btn_cfg, Random.string(8), [onclick], <>{btn_txt}</>)
<span id=#{login_box_id} class=loginbox>
{CLogin.html(login)}
+ <span class="signup">
+ Don't have an account yet? {signup}
+ </>
</>
@client login_switch_btn(on, action) =
- btn_cfg = WButton.default_config
- btn_txt = "Sign in/up"
- actions = [({click}, action)]
- xhtml = WButton.html(btn_cfg, Random.string(8), actions, <>{btn_txt}</>)
+ control = if on then "↑" else "↓"
+ btn_txt = "Sign in/up {control}"
+ onclick = ({click}, action)
+ xhtml = WButton.html(login_btn_cfg, Random.string(8), [onclick], <>{btn_txt}</>)
update_dom = if on then Dom.show else Dom.hide
do update_dom(#{login_box_id})
{ update_xhtml=xhtml }
@@ -77,20 +85,44 @@ Login =
WSwitch.edit(cfg, sign_in_switch_id, (_ -> void), false)
html() : xhtml =
- <>
- {login_switch()}
- {login_box()}
+ <div id=#toolbar_container>
+ <div id=#toolbar>
+ <div id=#signin>
+ {login_switch()}
+ {login_box()}
+ </>
+ </>
</>
}}
-login_css = css
+toolbar_css = css
td{}
+ #toolbar_container {
+ position: fixed;
+ top: 0px;
+ overflow: hidden;
+ width: 100%;
+ height: 30px;
+ z-index: 9999;
+ border: 1px dotted ;
+ border-top: none;
+ background: #666;
+ }
+ #toolbar {
+ width: 600px;
+ margin: auto;
+ }
+ #signin {
+ float: right;
+ }
.loginbox {
position: fixed;
- top: 34px;
+ top: 30px;
background: #666;
+ border: 1px dotted black;
+ border-top: none;
padding: 12px;
- border-radius: 8px;
- border: 1px dotted #CCC;
+ border-bottom-left-radius: 8px;
+ border-bottom-right-radius: 8px;
}
View
@@ -7,4 +7,4 @@ msg_factory.opa
user.opa
label.opa
utils.opa
-login.opa
+toolbar.opa

0 comments on commit ff2db73

Please sign in to comment.