ampproject / ampproject/amphtml

amp-bind: Easier toggling of classes

Open
#10,622 8 comments 0 reactions 1 assignee Claimed by @kristoferbaxter View on GitHub
P3: When Possible Stale Type: Discussion/Question Type: Feature Request WG: performance
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.