Skip to content

Commit

Permalink
Add library support for more list items
Browse files Browse the repository at this point in the history
  • Loading branch information
lemorage committed Oct 24, 2023
1 parent 59bf4b0 commit 62b6380
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
16 changes: 16 additions & 0 deletions elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ func Ul(props Attrs, children ...Node) *Element {
return NewElement("ul", props, children...)
}

func Ol(props Attrs, children ...Node) *Element {
return NewElement("ol", props, children...)
}

func Dl(props Attrs, children ...Node) *Element {
return NewElement("dl", props, children...)
}

func Dt(props Attrs, children ...Node) *Element {
return NewElement("dt", props, children...)
}

func Dd(props Attrs, children ...Node) *Element {
return NewElement("dd", props, children...)
}

// ========== Forms ==========

func Button(props Attrs, children ...Node) *Element {
Expand Down
24 changes: 24 additions & 0 deletions elements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ func TestUl(t *testing.T) {
assert.Equal(t, expected, el.Render())
}

func TestOl(t *testing.T) {
expected := `<ol><li>Item 1</li><li>Item 2</li></ol>`
el := Ol(nil, Li(nil, Text("Item 1")), Li(nil, Text("Item 2")))
assert.Equal(t, expected, el.Render())
}

func TestDl(t *testing.T) {
expected := `<dl><dt>Term 1</dt><dd>Description 1</dd><dt>Term 2</dt><dd>Description 2</dd></dl>`
el := Dl(nil, Dt(nil, Text("Term 1")), Dd(nil, Text("Description 1")), Dt(nil, Text("Term 2")), Dd(nil, Text("Description 2")))
assert.Equal(t, expected, el.Render())
}

func TestDt(t *testing.T) {
expected := `<dt>Term 1</dt>`
el := Dt(nil, Text("Term 1"))
assert.Equal(t, expected, el.Render())
}

func TestDd(t *testing.T) {
expected := `<dd>Description 1</dd>`
el := Dd(nil, Text("Description 1"))
assert.Equal(t, expected, el.Render())
}

// ========== Forms ==========

func TestButton(t *testing.T) {
Expand Down

0 comments on commit 62b6380

Please sign in to comment.