Comments (5)
Hi @tbe, thank you for your contribution!
I actually like the way that the library is "dumb" in the way that, if you provide it with invalid HTML, it will happily render that, just like if you wrote raw HTML. However, I see your point.
I think in your case it would make sense to bake the is-primary
functionality into the button itself:
type BulmaButtonProps struct {
IsPrimary bool
}
func BulmaButton(p BulmaButtonProps, children ...g.Node) g.Node {
return Button(c.Classes{"button": true, "is-primary": p.IsPrimary}, g.Group(children))
}
So basically the button "owns" the various ways in which it can be rendered. Would that solution solve your issue?
from gomponents.
Hey @markuswustenberg , that is the exact usecase why i open this issue.
While "dump" rendering is fine if you use the gomponents directly, in this case it is not obvious to a user what happens. If the user provides another set of classes, the "is-primary" will be shadowed, or it will shadow the user supplied classes, however the browser decides.
As the type of the attributes is not exported, we can't apply any check in the factory function for the button.
from gomponents.
Yes, that's true, there can be attribute clashes in general. I think there's no way around that in gomponents because of the way I've designed it. Solutions that I can currently think of:
- Document that the user of the
BulmaButton
shouldn't use separateclass
attributes. - Don't accept arbitrary
Node
children but only custom types. - Put children nodes on a child node of the button and not the button directly, thus creating a sort of wrapper node inside the button.
- Render all children nodes and check for disallowed attributes.
Would any of those work in your use case?
from gomponents.
After thinking about it, i see your concerns. My needs differ from the design philosophy behind gomponents. So i decided to write an alternative module, that sacrifices a little bit of usability for more advanced features. Should hit github today or tomorrow.
The main reason is, that implementing the proposed logic on top of gomponents is most likely the same work and adds nothing but an extra layer of abstraction.
Thank you for the great project @markuswustenberg , i got a lot of inspiration from it.
from gomponents.
I'm happy you found a solution, @tbe. 😊
from gomponents.
Related Issues (20)
- Fragments HOT 6
- Links? HOT 1
- Why g.Map doesn't also do g.Group? HOT 2
- Generics g.Map performance HOT 7
- Use Custom attributes & alpine js HOT 3
- component specific css and js HOT 6
- Use with tinygo HOT 3
- Proposal: Re-export packages with shorter names (g, h, c) HOT 3
- Inline if with nil pointer HOT 7
- Why can't a group be rendered? HOT 5
- Add lib to awesome Go HOT 1
- Remove fmt.Stringer support? HOT 1
- Handling internationalization HOT 8
- trigger an error on duplicate attributes HOT 3
- Make Group renderable
- Proposal to Add String Rendering Method to Node Interface HOT 5
- HTML -> gomponents converter tool HOT 2
- Label can be an attribute as well HOT 2
- Missing list attribute HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gomponents.