Macros Component API should not require internal classes for modifiers
See original GitHub issueMacros abstract our class names, if we were to change our class names, macro usage would break for our users.
In our button examples, we pass the internal button modifier class to make a button into a start button.
We could consider passing a boolean instead so that if we choose to change how our classes work, macros still function.
For example instead of
- name: start
data:
text: Start now button
classes: 'govuk-c-button--start'
We could do:
- name: start
data:
text: Start now button
start: true
See also the GOV.UK Publishing component: http://govuk-static.herokuapp.com/component-guide/button/start_now_button
We constructed the class based on booleans, then finally merge with classes
and inject into the markup.
Edit: I put together an example showing how you can restructure the macro to avoid the confusing forking logic.
This approach only forks on individual parts of the template, which is easier to reason about.
https://glitch.com/edit/#!/flag-based-macro-approach?path=views/index.html:15:26
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:12 (9 by maintainers)
Top GitHub Comments
Two more use cases raised #1150 and #1151.
Closing this for now – let’s see if this is something that comes up in user research or once we’ve got some experience rolling out breaking changes.