ampproject / ampproject/amphtml
amp-bind: Easier toggling of classes
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
Discussion issue to consider improvements for binding to `class` attribute and make it easier to add/remove/toggle dynamic classes, specially when combined with a list of static classes.
### Current ways of binding to `class`
1- `
2- `
3- `
**Issue** here is mostly around the need to repeat `static class` part in both `class` and `[class]`
### Possible improvements
1- Expose `elem.addClass(class)` , `elem.removeClass(class)` , `elem.toggleClass(class)` as AMP Actions separate from `amp-bind`
2- Expose a new `addition` syntax in `amp-bind` that would elimiminate the need to repeat the static classes. For instance:
`
/to @choumx
/cc @camelburrito @sebastianbenz @ericlindley-g
Contributor guide
Assessment
This issue has not been assessed yet.