Skip to content

Commit

Permalink
[enhance] widgets: bootstrap, merge badge and label
Browse files Browse the repository at this point in the history
  • Loading branch information
Aqua-Ye committed May 1, 2012
1 parent 9341b4f commit ee22493
Showing 1 changed file with 15 additions and 51 deletions.
66 changes: 15 additions & 51 deletions stdlib/widgets/bootstrap/bootstrap.opa
Expand Up @@ -131,26 +131,16 @@ type WBootstrap.Button.button = {

type WBootstrap.Button.group = list(WBootstrap.Button.button)

// Label
// Badge-Label

type WBootstrap.Label.importance =
type WBootstrap.BadgeLabel.importance =
{default}
/ {success}
/ {warning}
/ {important}
/ {info}
/ {inverse}

// Badge

type WBootstrap.Badge.importance =
{default}
/ {success}
/ {warning}
/ {error}
/ {info}
/ {inverse}

// Alert

type WBootstrap.Alert.type =
Expand Down Expand Up @@ -390,22 +380,20 @@ WBootstrap = {{

}}

Label = {{
@private
BadgeLabel(t:string) = {{

make_label(content:xhtml) =
<span>{content}</span> |> Xhtml.update_class("label", _)
make_simple(content:xhtml) =
<span>{content}</span> |> Xhtml.update_class(t, _)

success = Xhtml.update_class("label-success", _)
warning = Xhtml.update_class("label-warning", _)
important = Xhtml.update_class("label-important", _)
info = Xhtml.update_class("label-info", _)
inverse = Xhtml.update_class("label-inverse", _)
success = Xhtml.update_class("{t}-success", _)
warning = Xhtml.update_class("{t}-warning", _)
important = Xhtml.update_class("{t}-important", _)
info = Xhtml.update_class("{t}-info", _)
inverse = Xhtml.update_class("{t}-inverse", _)

/**
* Create a label
*/
make(text:xhtml, importance:WBootstrap.Label.importance) =
lb = make_label(text)
make(text:xhtml, importance:WBootstrap.BadgeLabel.importance) =
lb = make_simple(text)
lb = match importance
{default} -> lb
{success} -> lb |> success(_)
Expand All @@ -417,33 +405,9 @@ WBootstrap = {{

}}

// FIXME: merge with label
Badge = {{

make_badge(content:string) =
<span>{content}</span> |> Xhtml.update_class("badge", _)

success = Xhtml.update_class("badge-success", _)
warning = Xhtml.update_class("badge-warning", _)
error = Xhtml.update_class("badge-error", _)
info = Xhtml.update_class("badge-info", _)
inverse = Xhtml.update_class("badge-inverse", _)
Label = BadgeLabel("label")

/**
* Create a label
*/
make(text:string, importance:WBootstrap.Badge.importance) =
lb = make_badge(text)
lb = match importance
{default} -> lb
{success} -> lb |> success(_)
{warning} -> lb |> warning(_)
{error} -> lb |> error(_)
{info} -> lb |> info(_)
{inverse} -> lb |> inverse(_)
lb

}}
Badge = BadgeLabel("badge")

Thumbnail = {{

Expand Down

0 comments on commit ee22493

Please sign in to comment.