Skip to content

Commit

Permalink
added prop border collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartaccent committed Jun 2, 2024
1 parent dc0a57f commit 7878d5b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

### v0.1.1

Added new props:

- border-collapse

### v0.1.0

- Allow a color to be mixed with another color.
Expand Down
8 changes: 3 additions & 5 deletions examples/css-resets/resets.go → examples/css-resets/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ var resets = []gcss.Style{
{
Selector: "table",
Props: gcss.Props{
BorderColor: props.ColorInherit(),
TextIndent: variables.Size0,
},
CustomProps: []gcss.CustomProp{
{Attr: "border-collapse", Value: "collapse"},
BorderCollapse: props.BorderCollapseCollapse,
BorderColor: props.ColorInherit(),
TextIndent: variables.Size0,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/css-resets/resets.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions props/border_collapse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package props

type BorderCollapse string

const (
BorderCollapseCollapse BorderCollapse = "collapse"
BorderCollapseSeparate BorderCollapse = "separate"
)

func (b BorderCollapse) String() string {
return string(b)
}
1 change: 1 addition & 0 deletions style.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type (
BorderBottom props.Border `css:"border-bottom"`
BorderBottomLeftRadius props.Unit `css:"border-bottom-left-radius"`
BorderBottomRightRadius props.Unit `css:"border-bottom-right-radius"`
BorderCollapse props.BorderCollapse `css:"border-collapse"`
BorderColor props.Color `css:"border-color"`
BorderLeft props.Border `css:"border-left"`
BorderRadius props.Unit `css:"border-radius"`
Expand Down
40 changes: 27 additions & 13 deletions style_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,6 @@ func TestStyle_BackgroundSize(t *testing.T) {
}
}

func TestStyle_BorderColor(t *testing.T) {
testCases := map[props.Color]string{
props.ColorRGBA(0, 0, 0, 255): "rgba(0,0,0,1.00)",
props.ColorRGBA(255, 255, 255, 230): "rgba(255,255,255,0.90)",
}

for prop, expected := range testCases {
st := &Style{Selector: ".test", Props: Props{BorderColor: prop}}
css := fmt.Sprintf(".test{border-color:%s;}", expected)
runTest(t, st, css)
}
}

func TestStyle_Border(t *testing.T) {
testCases := map[props.Border]string{
{
Expand Down Expand Up @@ -297,6 +284,33 @@ func TestStyle_BorderBottomRightRadius(t *testing.T) {
}
}

func TestStyle_BorderCollapse(t *testing.T) {
testCases := map[props.BorderCollapse]string{
props.BorderCollapseSeparate: "separate",
props.BorderCollapseCollapse: "collapse",
props.BorderCollapse("initial"): "initial",
}

for prop, expected := range testCases {
st := &Style{Selector: ".test", Props: Props{BorderCollapse: prop}}
css := fmt.Sprintf(".test{border-collapse:%s;}", expected)
runTest(t, st, css)
}
}

func TestStyle_BorderColor(t *testing.T) {
testCases := map[props.Color]string{
props.ColorRGBA(0, 0, 0, 255): "rgba(0,0,0,1.00)",
props.ColorRGBA(255, 255, 255, 230): "rgba(255,255,255,0.90)",
}

for prop, expected := range testCases {
st := &Style{Selector: ".test", Props: Props{BorderColor: prop}}
css := fmt.Sprintf(".test{border-color:%s;}", expected)
runTest(t, st, css)
}
}

func TestStyle_BorderLeft(t *testing.T) {
testCases := map[props.Border]string{
{
Expand Down

0 comments on commit 7878d5b

Please sign in to comment.