Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add badge and flexDivider components (#78)
* Add badge component and use it inside tabs * Add flexDivider * Code review
- Loading branch information
1 parent
c369f56
commit 5e148db
Showing
7 changed files
with
178 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module Lumi.Components.Examples.Badge where | ||
|
||
import Lumi.Components.Badge (badge, badge_) | ||
import Lumi.Components.Color (colors) | ||
import Lumi.Components.Column (column_) | ||
import Lumi.Components.Spacing (Space(..), vspace) | ||
import Lumi.Components.Text (nbsp) | ||
import React.Basic (JSX) | ||
import React.Basic.DOM as R | ||
|
||
docs :: JSX | ||
docs = | ||
column_ | ||
[ badge_ "1" | ||
, vspace S8 | ||
|
||
, badge_ "2" | ||
, vspace S8 | ||
|
||
, badge_ "3" | ||
, vspace S8 | ||
|
||
, badge_ "Hello!" | ||
, vspace S8 | ||
|
||
, badge | ||
{ background: colors.primary | ||
, color: colors.white | ||
, style: R.css {} | ||
, text: "1" | ||
} | ||
, vspace S8 | ||
|
||
, badge | ||
{ background: colors.primary | ||
, color: colors.white | ||
, style: R.css {} | ||
, text: nbsp | ||
} | ||
] |
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,58 @@ | ||
module Lumi.Components.Badge where | ||
|
||
import Prelude | ||
|
||
import Color (cssStringHSLA) | ||
import JSS (JSS, jss) | ||
import Lumi.Components.Color (Color, colors) | ||
import Lumi.Components.Text (lumiSubtextFontSize) | ||
import React.Basic (JSX, element) | ||
import React.Basic.DOM as R | ||
|
||
type BadgeProps = | ||
{ background :: Color | ||
, color :: Color | ||
, style :: R.CSS | ||
, text :: String | ||
} | ||
|
||
badge_ :: String -> JSX | ||
badge_ = badge <<< defaults { text = _ } | ||
|
||
badge :: BadgeProps -> JSX | ||
badge { background, color, style, text } = | ||
lumiBadgeElement | ||
{ style: R.mergeStyles | ||
[ R.css | ||
{ color: cssStringHSLA color | ||
, background: cssStringHSLA background | ||
} | ||
, style | ||
] | ||
, children: R.text text | ||
} | ||
where | ||
lumiBadgeElement = element (R.unsafeCreateDOMComponent "lumi-badge") | ||
|
||
defaults :: BadgeProps | ||
defaults = | ||
{ background: colors.black5 | ||
, color: colors.secondary | ||
, style: R.css {} | ||
, text: "" | ||
} | ||
|
||
styles :: JSS | ||
styles = jss | ||
{ "@global": | ||
{ "lumi-badge": | ||
{ alignSelf: "baseline" | ||
, display: "inline" | ||
, fontSize: lumiSubtextFontSize | ||
, lineHeight: "17px" | ||
, borderRadius: "9px" | ||
, marginTop: "2px" | ||
, padding: "0px 6px" | ||
} | ||
} | ||
} |
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