question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Macros Component API should not require internal classes for modifiers

See original GitHub issue

Macros 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

Link to code: https://github.com/alphagov/static/blob/a9a040a72d475ef7015c1c9e690a5d77687fcfd8/app/views/govuk_component/button.raw.html.erb#L1

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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
aliuk2012commented, Jan 23, 2019

Two more use cases raised #1150 and #1151.

1reaction
36degreescommented, Jul 30, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scala - How to manipulate modifiers in annotation macros
I found an api that allows me to manipulate modifiers in ModifiersApi , mapAnnotations . This api use lambda that can manipulate Modifier....
Read more >
Built-in Macro Functions
Use the fromCharCode() function to convert one or more Unicode characters to a string. close() Closes the active image. This function has the ......
Read more >
Modifier
Subcomponent modifiers should be grouped together and follow the parent ... We convert the 30.sp value to dps, which is required for the...
Read more >
Component.h File Reference
Header file for the Component base class. In Lumberyard's component entity system, each component defines a discrete feature that can be attached to...
Read more >
Scala Reflection Library 2.12.11 - scala.reflect.macros.Universe
abstract class Universe extends api.Universe. EXPERIMENTAL. The refinement of scala.reflect.api.Universe for the use by macro ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found