Skip to content

Commit

Permalink
Merge pull request #33 from u5surf/issue-31
Browse files Browse the repository at this point in the history
Add Support for <i> Element
  • Loading branch information
chasefleming authored Oct 27, 2023
2 parents bb90622 + f2ca068 commit f4a82bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ In this example, if `isAdmin` is `true`, the `Admin Panel` link is rendered. Oth
- `Header`: Header `<header>`
- `Html`: HTML `<html>`
- `Hr`: Horizontal Rule `<hr>`
- `I`: Idiomatic Text `<i>`
- `Img`: Image `<img>`
- `Input`: Input `<input>`
- `Label`: Label `<label>`
Expand Down
4 changes: 4 additions & 0 deletions elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func Hr(props Attrs) *Element {
return NewElement("hr", props)
}

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

func P(props Attrs, children ...Node) *Element {
return NewElement("p", props, children...)
}
Expand Down
9 changes: 9 additions & 0 deletions elements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ func TestHr(t *testing.T) {
assert.Equal(t, expected, el.Render())
}

func TestI(t *testing.T) {
expected1 := `<i>Idiomatic Text</i>`
expected2 := `<i class="fa-regular fa-face-smile"></i>`
el := I(nil, Text("Idiomatic Text"))
assert.Equal(t, expected1, el.Render())
el = I(Attrs{attrs.Class: "fa-regular fa-face-smile"})
assert.Equal(t, expected2, el.Render())
}

func TestP(t *testing.T) {
expected := `<p>Hello, Elem!</p>`
el := P(nil, Text("Hello, Elem!"))
Expand Down

0 comments on commit f4a82bf

Please sign in to comment.