Giter Site home page Giter Site logo

Comments (5)

markuswustenberg avatar markuswustenberg commented on June 19, 2024

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.

tbe avatar tbe commented on June 19, 2024

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.

markuswustenberg avatar markuswustenberg commented on June 19, 2024

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:

  1. Document that the user of the BulmaButton shouldn't use separate class attributes.
  2. Don't accept arbitrary Node children but only custom types.
  3. 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.
  4. Render all children nodes and check for disallowed attributes.

Would any of those work in your use case?

from gomponents.

tbe avatar tbe commented on June 19, 2024

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.

markuswustenberg avatar markuswustenberg commented on June 19, 2024

I'm happy you found a solution, @tbe. 😊

from gomponents.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.