Conversation
|
I think your implementation is not very easy to use, Did you make your package because something was wrong with By reviewing gnomod.toml I also see that package and folder name differs (ui_lib vs svg) I would also add these standard primitives as they're often used: And also some example and test file would be nice ! After thinking about all of this I'd prefer to use something like this : func Render() string {
return svg.Canvas().
Size(400, 200).
ViewBox("300,200,400,400").
Add(svg.Circle().At(100, 100).Radius(50).Color("#FF0000")).
Add(svg.Rect().At(150, 150).Size(100, 80).Rounded(10).Color("#00FF00").Class("example-class")).
Add(svg.Circle().At(100, 100).Radius(50).Color("#FF0000")).
Render()
}If you want grouping, you should be able to do it with official func Render() string {
canvas := svg.Canvas{Width: 400, Height: 200, ViewBox: "300 200 400 400"}
group := svg.Group{Attr: svg.BaseAttrs{Class: "example-class"}}
group.Append(
svg.Rectangle{X: 150, Y: 150, Width: 100, Height: 80, RX: 10, RY: 10, Fill: "#00FF00"},
svg.Circle{CX: 100, CY: 100, R: 50, Fill: "#FF0000"},
)
canvas.Append(
svg.Circle{CX: 100, CY: 100, R: 50, Fill: "#FF0000"},
group,
)
return canvas.String()
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ui_lib
This is a library designed to generate SVG on-the-fly or at runtime. Now, users can create dynamic SVGs using this library more easily and with greater flexibility. Here's an example usage:
But like Guillaume said, you can inject JavaScript, but this isn't a security flaw of the library; rather, it's related to Gnoweb.
because anyone can simply create an SVG with JavaScript and make an Realm, regardless of my library
example