Skip to content

Commit

Permalink
Slowly fading in new messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
akoprow committed Apr 4, 2011
1 parent 65023c1 commit a2ca3ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/msg.opa
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Msg.segment =
msg_parser = parser res=segment_parser* -> res msg_parser = parser res=segment_parser* -> res
Parser.parse(msg_parser, Msg.get_content(msg)) Parser.parse(msg_parser, Msg.get_content(msg))
render(msg : Msg.t, mode : {preview} / {final}) : xhtml = render(msg : Msg.t, mode : {preview} / {final} / {new}) : xhtml =
render_segment = render_segment =
| ~{ text } -> <>{text}</> | ~{ text } -> <>{text}</>
| ~{ url } -> | ~{ url } ->
Expand All @@ -69,13 +69,23 @@ type Msg.segment =
date = WDatePrinter.html(WDatePrinter.default_config, date = WDatePrinter.html(WDatePrinter.default_config,
uniq(), Msg.get_creation_date(msg)) uniq(), Msg.get_creation_date(msg))
author = Msg.get_author(msg) author = Msg.get_author(msg)
<div class="msg"> id = uniq()
classes = ["msg" | if mode == {new} then ["hidden"] else []]
ready(_) = match mode with
| {new} ->
_ = Dom.Effect.fade_in()
|> Dom.Effect.with_duration({millisec=1500}, _)
|> Dom.transition(#{id}, _)
void
| _ -> void
<div id={id} class={classes} onready={ready}>
{User.show_photo({size_px=48}, author)} {User.show_photo({size_px=48}, author)}
<div class="content"> <div class="content">
<div class="user">{User.to_anchor(author)}</> <div class="user">{User.to_anchor(author)}</>
<div class="text">{content}</> <div class="text">{content}</>
{match mode with {match mode with
| {final} -> <div class="date">{date}</> | {final}
| {new} -> <div class="date">{date}</>
| {preview} -> <></> // don't display date in preview | {preview} -> <></> // don't display date in preview
} }
</> </>
Expand All @@ -95,6 +105,10 @@ msg_css = css
padding: 10px; padding: 10px;
border-radius: 10px; border-radius: 10px;
border: 1px solid #C0CAED; border: 1px solid #C0CAED;
margin-bottom: 10px;
}
.msg.new {
background: #FF0000;
} }
.msg:hover { .msg:hover {
background: #D0DAFD; background: #D0DAFD;
Expand Down
5 changes: 4 additions & 1 deletion src/pages.opa
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Pages = {{
("Twopenny", unimplemented) ("Twopenny", unimplemented)


@client show_new_message(~{newmsg}) = @client show_new_message(~{newmsg}) =
exec([#msgs -<- Msg.render(newmsg, {final})]) exec([#msgs -<- Msg.render(newmsg, {new})])


@client setup_msg_updates(_) = @client setup_msg_updates(_) =
chan = Session.make_callback(show_new_message) chan = Session.make_callback(show_new_message)
Expand Down Expand Up @@ -63,6 +63,9 @@ page_css = css
border-left: 1px dotted black; border-left: 1px dotted black;
border-right: 1px dotted black; border-right: 1px dotted black;
} }
.hidden {
display: none;
}
.header .image { .header .image {
margin: -15px 0px; margin: -15px 0px;
} }
Expand Down

0 comments on commit a2ca3ab

Please sign in to comment.