Skip to content

Commit

Permalink
added column and row gap
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartaccent committed May 22, 2024
1 parent dcf5839 commit 6cf2221
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

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

### v0.0.6

Added new props:

- column-gap
- row-gap

### v0.0.5

Added explicit CustomProp type and make CustomProps a slice to preserve ordering.
Expand Down
2 changes: 2 additions & 0 deletions style.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type (
Bottom props.Unit `css:"bottom"`
CaptionSide props.CaptionSide `css:"caption-side"`
Color props.Color `css:"color"`
ColumnGap props.Unit `css:"column-gap"`
Cursor props.Cursor `css:"cursor"`
Display props.Display `css:"display"`
FlexBasis props.Unit `css:"flex-basis"`
Expand Down Expand Up @@ -69,6 +70,7 @@ type (
Position props.Position `css:"position"`
PrintColorAdjust props.PrintColorAdjust `css:"print-color-adjust"`
Right props.Unit `css:"right"`
RowGap props.Unit `css:"row-gap"`
TextAlign props.TextAlign `css:"text-align"`
TextOverflow props.TextOverflow `css:"text-overflow"`
Top props.Unit `css:"top"`
Expand Down
46 changes: 46 additions & 0 deletions style_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,29 @@ func TestStyle_Color(t *testing.T) {
}
}

func TestStyle_ColumnGap(t *testing.T) {
testCases := map[props.Unit]string{
props.UnitPx(10): "10px",
props.UnitPercent(50): "50.00%",
props.UnitRem(10): "10.000rem",
}

for prop, expected := range testCases {
t.Run(expected, func(t *testing.T) {
st := &Style{Selector: ".test", Props: Props{ColumnGap: prop}}
var buf bytes.Buffer
err := st.CSS(&buf)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
css := fmt.Sprintf(".test{column-gap:%s;}", expected)
if buf.String() != css {
t.Errorf("expected %q, got %q", css, buf.String())
}
})
}
}

func TestStyle_Cursor(t *testing.T) {
testCases := map[props.Cursor]string{
props.CursorAuto: "auto",
Expand Down Expand Up @@ -1607,6 +1630,29 @@ func TestStyle_Right(t *testing.T) {
}
}

func TestStyle_RowGap(t *testing.T) {
testCases := map[props.Unit]string{
props.UnitPx(10): "10px",
props.UnitPercent(50): "50.00%",
props.UnitRem(10): "10.000rem",
}

for prop, expected := range testCases {
t.Run(expected, func(t *testing.T) {
st := &Style{Selector: ".test", Props: Props{RowGap: prop}}
var buf bytes.Buffer
err := st.CSS(&buf)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
css := fmt.Sprintf(".test{row-gap:%s;}", expected)
if buf.String() != css {
t.Errorf("expected %q, got %q", css, buf.String())
}
})
}
}

func TestStyle_TextAlign(t *testing.T) {
testCases := map[props.TextAlign]string{
props.TextAlignLeft: "left",
Expand Down

0 comments on commit 6cf2221

Please sign in to comment.