Replies: 2 comments
-
I agree with the proposal to decouple logic from templates for the reasons you point out :). Perhaps we could start with going through everything that does |
Beta Was this translation helpful? Give feedback.
-
Closing as enhancements with votes needed. Our workflow with enhancements is that we close them and have people vote on them, then we sort our enhancements by most votes to see which ones should be prioritized: https://github.com/ing-bank/lion/issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement+sort%3Areactions-%2B1-desc |
Beta Was this translation helpful? Give feedback.
-
Decouple styling and logic
Let's make it easier for Sub Classers that want to extend a certain component to adhere to their Design System.
In most cases, extending a component comes down to:
_xTemplate
(for instance_inputTemplate
) functions that define markupstatic get styles
with Design System specific stylesPoint 2 is straightforward.
For point 1 though, we currently have a lot of places where we mix logic and markup/styling. An example (slightly adjusted) currently in https://github.com/ing-bank/lion/blob/master/packages/calendar/src/LionCalendar.js:
Current implementation
If we can make the following assumptions:
We can approach this using the spread directive: https://open-wc.org/developing/lit-helpers.html#spread-directives.
Decoupled implementation
An extension implementation
Let's say we want to create our own Material Design calendar. Our template function would look like:
As you can see, we abstracted away the logic in this template, so the extending party only has to worry about applying the right styles (in this example this means the md-button and the class supplied).
For clarity and consistency, a "data-ref" attribute was added, that makes it directly clear where the prevButtonProps should be applied.
Of course, our logic has moved to a different place now:
Advantages
This approach makes the Lion layer more flexible: it allows functional changes without breaking the extension layer.
What if we still need overrides?
If the button should call a different method, the extending party is still able to do so. Same for translations etc.
Beta Was this translation helpful? Give feedback.
All reactions