Skip to content

Commit 6482068

Browse files
authored
Merge pull request #32 from dbrattli/fix/border-style-type
fix: border style type mismatch in composite border functions
2 parents 32094a3 + d1e5845 commit 6482068

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

src/Interop.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ module Interop =
5050

5151
let inline mkStyle (key: string) (value: obj) : IStyleAttribute = Style (key, value) :> _
5252

53+
let inline mkBorderStyle (value: string) : IBorderStyle = BorderStyle value :> _
54+
5355
type FunctionComponent<'Props> = 'Props -> ReactElement

src/StyleTypes.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ type CssUnit =
6464
let (CssUnit value) = x
6565
value
6666

67+
type BorderStyle =
68+
| BorderStyle of string
69+
interface IBorderStyle
70+
71+
override x.ToString () =
72+
let (BorderStyle value) = x
73+
value
74+
6775
type TextDecorationLine =
6876
| TextDecorationLine of string
6977
interface ITextDecorationLine

src/Styles.fs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,55 +1715,55 @@ module style =
17151715
/// Specifies a dotted border.
17161716
///
17171717
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1718-
static member inline dotted = Interop.mkStyle "border-style" "dotted"
1718+
static member inline dotted : IBorderStyle = Interop.mkBorderStyle "dotted"
17191719
/// Specifies a dashed border.
17201720
///
17211721
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1722-
static member inline dashed = Interop.mkStyle "border-style" "dashed"
1722+
static member inline dashed : IBorderStyle = Interop.mkBorderStyle "dashed"
17231723
/// Specifies a solid border.
17241724
///
17251725
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1726-
static member inline solid = Interop.mkStyle "border-style" "solid"
1726+
static member inline solid : IBorderStyle = Interop.mkBorderStyle "solid"
17271727
/// Specifies a double border.
17281728
///
17291729
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1730-
static member inline double = Interop.mkStyle "border-style" "double"
1730+
static member inline double : IBorderStyle = Interop.mkBorderStyle "double"
17311731
/// Specifies a 3D grooved border. The effect depends on the border-color value.
17321732
///
17331733
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1734-
static member inline groove = Interop.mkStyle "border-style" "groove"
1734+
static member inline groove : IBorderStyle = Interop.mkBorderStyle "groove"
17351735
/// Specifies a 3D ridged border. The effect depends on the border-color value.
17361736
///
17371737
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1738-
static member inline ridge = Interop.mkStyle "border-style" "ridge"
1738+
static member inline ridge : IBorderStyle = Interop.mkBorderStyle "ridge"
17391739
/// Specifies a 3D inset border. The effect depends on the border-color value.
17401740
///
17411741
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1742-
static member inline inset = Interop.mkStyle "border-style" "inset"
1742+
static member inline inset : IBorderStyle = Interop.mkBorderStyle "inset"
17431743
/// Specifies a 3D outset border. The effect depends on the border-color value.
17441744
///
17451745
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1746-
static member inline outset = Interop.mkStyle "border-style" "outset"
1746+
static member inline outset : IBorderStyle = Interop.mkBorderStyle "outset"
17471747
/// Default value. Specifies no border.
17481748
///
17491749
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=dotted
1750-
static member inline none = Interop.mkStyle "border-style" "none"
1750+
static member inline none : IBorderStyle = Interop.mkBorderStyle "none"
17511751
/// The same as "none", except in border conflict resolution for table elements.
17521752
///
17531753
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=hidden
1754-
static member inline hidden = Interop.mkStyle "border-style" "hidden"
1754+
static member inline hidden : IBorderStyle = Interop.mkBorderStyle "hidden"
17551755
/// Sets this property to its default value.
17561756
///
17571757
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=hidden
17581758
///
17591759
/// Read about initial value https://www.w3schools.com/cssref/css_initial.asp
1760-
static member inline initial = Interop.mkStyle "border-style" "initial"
1760+
static member inline initial : IBorderStyle = Interop.mkBorderStyle "initial"
17611761
/// Inherits this property from its parent element.
17621762
///
17631763
/// See example https://www.w3schools.com/cssref/playit.asp?filename=playcss_border-style&preval=hidden
17641764
///
17651765
/// Read about inherit https://www.w3schools.com/cssref/css_inherit.asp
1766-
static member inline inheritFromParent = Interop.mkStyle "border-style" "inherit"
1766+
static member inline inheritFromParent : IBorderStyle = Interop.mkBorderStyle "inherit"
17671767

17681768
[<Erase>]
17691769
/// Defines the algorithm used to lay out table cells, rows, and columns.

test/ViewEngineTest.fs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,16 @@ let ``Html.table with children renders correctly`` () =
296296
]
297297
]
298298
|> Render.htmlView
299-
Assert.Equal("<table><tr><th>Company</th><th>Contact</th></tr><tr><td>Alfreds</td><td>Maria</td></tr></table>", result)
299+
Assert.Equal("<table><tr><th>Company</th><th>Contact</th></tr><tr><td>Alfreds</td><td>Maria</td></tr></table>", result)
300+
301+
[<Fact>]
302+
let ``borderBottom with style.borderStyle works correctly`` () =
303+
// Regression test for https://github.com/dbrattli/Feliz.ViewEngine/issues/17
304+
let result =
305+
Html.div [
306+
prop.style [
307+
style.borderBottom(1, style.borderStyle.solid, "#888")
308+
]
309+
]
310+
|> Render.htmlView
311+
Assert.Equal("<div style=\"border-bottom:1px solid #888\"></div>", result)

0 commit comments

Comments
 (0)