diff options
author | Markus Wüstenberg | 2024-10-03 10:55:52 +0200 |
---|---|---|
committer | GitHub | 2024-10-03 10:55:52 +0200 |
commit | a58043d58789f95046a567d2ad1bde55e352d5f0 (patch) | |
tree | aef3ef6f2c1add6956a714ad338a4528bd8f4c57 | |
parent | b7a00582ac0052652bc2857ab57016b9dd4f8b0c (diff) | |
download | gomponents-a58043d58789f95046a567d2ad1bde55e352d5f0.tar.lz gomponents-a58043d58789f95046a567d2ad1bde55e352d5f0.tar.zst gomponents-a58043d58789f95046a567d2ad1bde55e352d5f0.zip |
Remove SVG package (#214)
Because the added value of having this was very small, and I don't want to confuse people about what's properly supported, I've removed the SVG package. As #196 showed, there can easily be conflicts between HTML and SVG, and the rendering isn't really set up for anything else than HTML. It's still easy to create SVG elements: `html.SVG` exists in this repo, and the rest is often just a string that can be included using `g.Raw`. Fixes #206
-rw-r--r-- | svg/attributes.go | 33 | ||||
-rw-r--r-- | svg/attributes_test.go | 29 | ||||
-rw-r--r-- | svg/elements.go | 15 | ||||
-rw-r--r-- | svg/elements_test.go | 29 |
4 files changed, 0 insertions, 106 deletions
diff --git a/svg/attributes.go b/svg/attributes.go deleted file mode 100644 index 52c9c61..0000000 --- a/svg/attributes.go +++ /dev/null @@ -1,33 +0,0 @@ -package svg - -import ( - g "github.com/maragudk/gomponents" -) - -func ClipRule(v string) g.Node { - return g.Attr("clip-rule", v) -} - -func D(v string) g.Node { - return g.Attr("d", v) -} - -func Fill(v string) g.Node { - return g.Attr("fill", v) -} - -func FillRule(v string) g.Node { - return g.Attr("fill-rule", v) -} - -func Stroke(v string) g.Node { - return g.Attr("stroke", v) -} - -func StrokeWidth(v string) g.Node { - return g.Attr("stroke-width", v) -} - -func ViewBox(v string) g.Node { - return g.Attr("viewBox", v) -} diff --git a/svg/attributes_test.go b/svg/attributes_test.go deleted file mode 100644 index 7e26548..0000000 --- a/svg/attributes_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package svg_test - -import ( - "fmt" - "testing" - - g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/internal/assert" - . "github.com/maragudk/gomponents/svg" -) - -func TestSimpleAttributes(t *testing.T) { - cases := map[string]func(string) g.Node{ - "clip-rule": ClipRule, - "d": D, - "fill": Fill, - "fill-rule": FillRule, - "stroke": Stroke, - "stroke-width": StrokeWidth, - "viewBox": ViewBox, - } - - for name, fn := range cases { - t.Run(fmt.Sprintf(`should output %v="hat"`, name), func(t *testing.T) { - n := g.El("element", fn("hat")) - assert.Equal(t, fmt.Sprintf(`<element %v="hat"></element>`, name), n) - }) - } -} diff --git a/svg/elements.go b/svg/elements.go deleted file mode 100644 index 98db644..0000000 --- a/svg/elements.go +++ /dev/null @@ -1,15 +0,0 @@ -// Package svg provides common SVG elements and attributes. -// See https://developer.mozilla.org/en-US/docs/Web/SVG/Element for an overview. -package svg - -import ( - g "github.com/maragudk/gomponents" -) - -func Path(children ...g.Node) g.Node { - return g.El("path", children...) -} - -func SVG(children ...g.Node) g.Node { - return g.El("svg", g.Attr("xmlns", "http://www.w3.org/2000/svg"), g.Group(children)) -} diff --git a/svg/elements_test.go b/svg/elements_test.go deleted file mode 100644 index f1ed47c..0000000 --- a/svg/elements_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package svg_test - -import ( - "fmt" - "testing" - - g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/internal/assert" - . "github.com/maragudk/gomponents/svg" -) - -func TestSimpleElements(t *testing.T) { - cases := map[string]func(...g.Node) g.Node{ - "path": Path, - } - - for name, fn := range cases { - t.Run(fmt.Sprintf("should output %v", name), func(t *testing.T) { - n := fn(g.Attr("id", "hat")) - assert.Equal(t, fmt.Sprintf(`<%v id="hat"></%v>`, name, name), n) - }) - } -} - -func TestSVG(t *testing.T) { - t.Run("outputs svg element with xml namespace attribute", func(t *testing.T) { - assert.Equal(t, `<svg xmlns="http://www.w3.org/2000/svg"><path></path></svg>`, SVG(g.El("path"))) - }) -} |