Giter VIP home page Giter VIP logo

Comments (3)

peteryates avatar peteryates commented on June 19, 2024

My plan for this was to get an initial draft of the components in and then look at ensuring the API is consistent via something like form builder's traits and making them inherit from a single base class; then we can make these decisions in a single place and enforce uniformity.

I don't mind too much whether the classes argument takes a String, Array but I'm leaning towards having it accept both. Internally, combining arrays feels much cleaner than appending strings and there are patterns which work nicely in the form builder that we can use for inspiration.

When this is dealt with in a single place we can refactor and hone it until everyone's happy. I definitely think that standardising should be the next step once the components are implemented, although there's no reason we can't start that now.

from govuk-components.

peteryates avatar peteryates commented on June 19, 2024

I've made some progress on this. Now all the components inherit from GovukComponent::Base which deals with the classes arg. The same behaviour can be used throughout to set classes on the main element in the component. I'll add the same approach for custom HTML attributes shortly.

Since introducing slots, much of the 'subcomponent' functionality (i.e. tabs in a tab list) can be moved to its own class and called within the block (component.slot(:tab, title: 'Hello') { ... }), we can use the same approach here and add custom classes/attrs at the slot level.

This will give us all the flexibility of the official nunjucks macros but with a more Rails-like API.

from govuk-components.

peteryates avatar peteryates commented on June 19, 2024

I think this is now handled consistently throughout via the classes: keyword arg. Happy to have another look if it's not sufficient.

from govuk-components.

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.