Skip to content

Commit fe34aa6

Browse files
committed
top/bottom only borders
1 parent 1390bd2 commit fe34aa6

File tree

2 files changed

+64
-15
lines changed

2 files changed

+64
-15
lines changed

docs/Examples/Border.example.purs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Lumi.Components.Examples.Border where
33
import Prelude
44

55
import Data.Maybe (Maybe(..))
6-
import Lumi.Components.Border (border, borderSquare, borderRound, borderTop, borderBottom)
6+
import Lumi.Components.Border (border, borderSquare, borderRound, borderSquareTop, borderSquareBottom, borderTop, borderBottom)
77
import Lumi.Components.Column (column, column_)
88
import Lumi.Components.Example (example)
99
import Lumi.Components.Spacing (Space(..))
@@ -20,27 +20,41 @@ docs =
2020
$ borderRound $
2121
column
2222
{ children: [ R.text "bordered element" ]
23-
, style: R.css { padding: "12px" }
23+
, style: R.css {}
2424
}
2525
, h2_ "Square borders"
2626
, example
2727
$ borderSquare $
2828
column
2929
{ children: [ R.text "bordered element" ]
30-
, style: R.css { padding: "12px" }
30+
, style: R.css {}
31+
}
32+
, h2_ "Square Top borders"
33+
, example
34+
$ borderSquareTop $
35+
column
36+
{ children: [ R.text "bordered element" ]
37+
, style: R.css {}
38+
}
39+
, h2_ "Square Bottom borders"
40+
, example
41+
$ borderSquareBottom $
42+
column
43+
{ children: [ R.text "bordered element" ]
44+
, style: R.css {}
3145
}
3246
, h2_ "Top borders"
3347
, example
3448
$ borderTop $
3549
column
3650
{ children: [ R.text "bordered element" ]
37-
, style: R.css { padding: "12px" }
51+
, style: R.css {}
3852
}
3953
, h2_ "Bottom borders"
4054
, example
4155
$ borderBottom $
4256
column
4357
{ children: [ R.text "bordered element" ]
44-
, style: R.css { padding: "12px" }
58+
, style: R.css {}
4559
}
4660
]

src/Lumi/Components/Border.purs

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@ module Lumi.Components.Border where
22

33
import Prelude
44

5-
import Color (cssStringHSLA)
5+
import Color (toHexString)
66
import Lumi.Components.Color (colors)
77
import JSS (JSS, jss)
88
import React.Basic (Component, JSX, createComponent, element, makeStateless)
99
import React.Basic.DOM (unsafeCreateDOMComponent)
1010

1111
data BorderStyle
12-
= Top
13-
| Bottom
12+
= SquareTop
13+
| SquareBottom
1414
| Round
1515
| Square
16+
| Top
17+
| Bottom
1618

1719
toStyle :: BorderStyle -> String
18-
toStyle Top = "top"
19-
toStyle Bottom = "bottom"
20+
toStyle SquareTop = "square-top"
21+
toStyle SquareBottom = "square-bottom"
2022
toStyle Round = "round"
2123
toStyle Square = "square"
24+
toStyle Top = "top"
25+
toStyle Bottom = "bottom"
2226

2327
component :: Component BorderProps
2428
component = createComponent "Border"
@@ -53,6 +57,20 @@ borderRound children =
5357
, borderStyle: Round
5458
}
5559

60+
borderSquareTop :: JSX -> JSX
61+
borderSquareTop children =
62+
border
63+
{ children
64+
, borderStyle: SquareTop
65+
}
66+
67+
borderSquareBottom :: JSX -> JSX
68+
borderSquareBottom children =
69+
border
70+
{ children
71+
, borderStyle: SquareBottom
72+
}
73+
5674
borderTop :: JSX -> JSX
5775
borderTop children =
5876
border
@@ -72,24 +90,41 @@ styles :: JSS
7290
styles = jss
7391
{ "@global":
7492
{ "lumi-border":
75-
{ border: "1px solid " <> cssStringHSLA colors.black3
93+
{ borderColor: toHexString colors.black3
94+
, borderStyle: "solid"
95+
, borderWidth: "1px"
96+
, padding: "16px"
7697
, overflow: "hidden"
7798
, "&[data-border-style='round']":
78-
{ borderRadius: "5px" }
99+
{ borderRadius: "5px"
100+
}
79101
, "&[data-border-style='square']":
80-
{ borderRadius: "0px" }
81-
, "&[data-border-style='top']":
102+
{ borderRadius: "0px"
103+
}
104+
, "&[data-border-style='square-bottom']":
82105
{ borderTopRightRadius: "5px"
83106
, borderTopLeftRadius: "5px"
84107
, borderBottomRightRadius: "0px"
85108
, borderBottomLeftRadius: "0px"
86109
}
87-
, "&[data-border-style='bottom']":
110+
, "&[data-border-style='square-top']":
88111
{ borderTopRightRadius: "0px"
89112
, borderTopLeftRadius: "0px"
90113
, borderBottomRightRadius: "5px"
91114
, borderBottomLeftRadius: "5px"
92115
}
116+
, "&[data-border-style='top']":
117+
{ border: "inherit"
118+
, borderTop: "1px solid " <> toHexString colors.black3
119+
, paddingLeft: "0px"
120+
, paddingRight: "0px"
121+
}
122+
, "&[data-border-style='bottom']":
123+
{ border: "inherit"
124+
, borderBottom: "1px solid " <> toHexString colors.black3
125+
, paddingLeft: "0px"
126+
, paddingRight: "0px"
127+
}
93128
}
94129
}
95130
}

0 commit comments

Comments
 (0)