Skip to content

Commit

Permalink
Upgrade to gomponents v0.22.0 (#8)
Browse files Browse the repository at this point in the history
Also, drop support for pre Go 1.18.
  • Loading branch information
markuswustenberg authored Oct 15, 2024
1 parent 0792144 commit 029a66f
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 73 deletions.
31 changes: 17 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ jobs:
strategy:
matrix:
go:
- 1.16
- 1.17
- 1.18
- 1.19
- "1.18"
- "1.19"
- "1.20"
- "1.21"
- "1.22"
- "1.23"
version:
- "."
- "v2"

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
check-latest: true
Expand All @@ -42,21 +44,22 @@ jobs:
run: cd ${{ matrix.version }} && go build -v ./...

- name: Test
if: ${{ matrix.go != '1.16' }}
run: cd ${{ matrix.version }} && go test -v -shuffle on ./...

- name: Test
if: ${{ matrix.go == '1.16' }}
run: cd ${{ matrix.version }} && go test -v ./...
run: cd ${{ matrix.version }} && go test -v -coverprofile=coverage.txt -shuffle on ./...

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true

- name: Lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v6
with:
version: latest
15 changes: 3 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
.PHONY: benchmark cover lint test

benchmark:
go test -bench=.

cover:
go tool cover -html=cover.out

lint:
golangci-lint run

.PHONY: test
test:
go test -coverprofile=cover.out -shuffle on ./...
go test -shuffle on ./...
cd v2 && go test -shuffle on ./...
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Heroicons has two version: v1 and v2. This library supports both.
To get the newest v2:

```shell
go get -u github.com/maragudk/gomponents-heroicons/v2@v2
go get github.com/maragudk/gomponents-heroicons/v2@v2
```

To get v1:

```shell
go get -u github.com/maragudk/gomponents-heroicons
go get github.com/maragudk/gomponents-heroicons
```

Made in 🇩🇰 by [maragu](https://www.maragu.dk), maker of [online Go courses](https://www.golang.dk/).
21 changes: 10 additions & 11 deletions heroicons.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package heroicons

import (
g "github.com/maragudk/gomponents"
. "github.com/maragudk/gomponents"
. "github.com/maragudk/gomponents/html"
"github.com/maragudk/gomponents/svg"
)

func Outline(children ...g.Node) g.Node {
func Outline(children ...Node) Node {
return SVG(
svg.ViewBox("0 0 24 24"),
svg.Fill("none"),
svg.Stroke("currentColor"),
Attr("viewBox", "0 0 24 24"),
Attr("fill", "none"),
Attr("stroke", "currentColor"),
Aria("hidden", "true"),
g.Group(children),
Group(children),
)
}

func Solid(children ...g.Node) g.Node {
func Solid(children ...Node) Node {
return SVG(
svg.ViewBox("0 0 20 20"),
svg.Fill("currentColor"),
Attr("viewBox", "0 0 20 20"),
Attr("fill", "currentColor"),
Aria("hidden", "true"),
g.Group(children),
Group(children),
)
}
6 changes: 3 additions & 3 deletions heroicons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package heroicons_test
import (
"testing"

. "github.com/maragudk/gomponents"
. "github.com/maragudk/gomponents/html"
"github.com/maragudk/gomponents/svg"

heroicons "github.com/maragudk/gomponents-heroicons"
"github.com/maragudk/gomponents-heroicons/internal/assert"
)

func TestOutline(t *testing.T) {
t.Run("returns svg with viewbox 0 0 24 24, no fill, currentColor stroke", func(t *testing.T) {
assert.Equal(t, `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Outline(Class("hat"), svg.Path()))
assert.Equal(t, `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Outline(Class("hat"), El("path")))
})
}

func TestSolid(t *testing.T) {
t.Run("returns svg with viewbox 0 0 20 20, currentColor fill", func(t *testing.T) {
assert.Equal(t, `<svg viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Solid(Class("hat"), svg.Path()))
assert.Equal(t, `<svg viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Solid(Class("hat"), El("path")))
})
}
4 changes: 2 additions & 2 deletions v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/maragudk/gomponents-heroicons/v2

go 1.15
go 1.18

require github.com/maragudk/gomponents v0.20.1
require github.com/maragudk/gomponents v0.22.0
4 changes: 2 additions & 2 deletions v2/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/maragudk/gomponents v0.20.1 h1:TeJY1fXEcfUvzmvjeUgxol42dvkYMggK1c0V67crWWs=
github.com/maragudk/gomponents v0.20.1/go.mod h1:nHkNnZL6ODgMBeJhrZjkMHVvNdoYsfmpKB2/hjdQ0Hg=
github.com/maragudk/gomponents v0.22.0 h1:0gNrSDC1nM6w0Vxj5wgGXqV8frDH9UVPE+dEyy4ApPQ=
github.com/maragudk/gomponents v0.22.0/go.mod h1:nHkNnZL6ODgMBeJhrZjkMHVvNdoYsfmpKB2/hjdQ0Hg=
45 changes: 22 additions & 23 deletions v2/heroicons.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
package heroicons

import (
g "github.com/maragudk/gomponents"
"github.com/maragudk/gomponents/html"
. "github.com/maragudk/gomponents/svg"
. "github.com/maragudk/gomponents"
. "github.com/maragudk/gomponents/html"
)

func Outline(children ...g.Node) g.Node {
func Outline(children ...Node) Node {
// <svg fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
return html.SVG(
Fill("none"),
ViewBox("0 0 24 24"),
g.Attr("stroke-width", "1.5"),
Stroke("currentColor"),
html.Aria("hidden", "true"),
g.Group(children),
return SVG(
Attr("fill", "none"),
Attr("viewBox", "0 0 24 24"),
Attr("stroke-width", "1.5"),
Attr("stroke", "currentColor"),
Aria("hidden", "true"),
Group(children),
)
}

func Solid(children ...g.Node) g.Node {
func Solid(children ...Node) Node {
// <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
return html.SVG(
ViewBox("0 0 24 24"),
Fill("currentColor"),
html.Aria("hidden", "true"),
g.Group(children),
return SVG(
Attr("viewBox", "0 0 24 24"),
Attr("fill", "currentColor"),
Aria("hidden", "true"),
Group(children),
)
}

func Mini(children ...g.Node) g.Node {
func Mini(children ...Node) Node {
// <svg viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
return html.SVG(
ViewBox("0 0 20 20"),
Fill("currentColor"),
html.Aria("hidden", "true"),
g.Group(children),
return SVG(
Attr("viewBox", "0 0 20 20"),
Attr("fill", "currentColor"),
Aria("hidden", "true"),
Group(children),
)
}
8 changes: 4 additions & 4 deletions v2/heroicons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ package heroicons_test
import (
"testing"

. "github.com/maragudk/gomponents"
. "github.com/maragudk/gomponents/html"
"github.com/maragudk/gomponents/svg"

heroicons "github.com/maragudk/gomponents-heroicons/v2"
"github.com/maragudk/gomponents-heroicons/v2/internal/assert"
)

func TestOutline(t *testing.T) {
t.Run("returns svg with no fill, viewBox 0 0 24 24, stroke width 1.5, currentColor stroke", func(t *testing.T) {
assert.Equal(t, `<svg fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Outline(Class("hat"), svg.Path()))
assert.Equal(t, `<svg fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Outline(Class("hat"), El("path")))
})
}

func TestSolid(t *testing.T) {
t.Run("returns svg with viewbox 0 0 24 24, currentColor fill", func(t *testing.T) {
assert.Equal(t, `<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Solid(Class("hat"), svg.Path()))
assert.Equal(t, `<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Solid(Class("hat"), El("path")))
})
}

func TestMini(t *testing.T) {
t.Run("returns svg with viewbox 0 0 20 20, currentColor fill", func(t *testing.T) {
assert.Equal(t, `<svg viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Mini(Class("hat"), svg.Path()))
assert.Equal(t, `<svg viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="hat"><path></path></svg>`, heroicons.Mini(Class("hat"), El("path")))
})
}

0 comments on commit 029a66f

Please sign in to comment.