-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from MichaelWest22/patch-1
Add apply-parent-classes feature to class-tools
- Loading branch information
Showing
5 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,12 @@ Within a run, a `,` character separates distinct class operations. | |
A class operation is an operation name `add`, `remove`, or `toggle`, followed by a CSS class name, | ||
optionally followed by a colon `:` and a time delay. | ||
|
||
There is also the option to use `apply-parent-classes` or `data-apply-parent-classes` which uses the same format as `classes` but is instead designed for Out of band updates to allow you to manipulate CSS classes of an existing element in the DOM without otherwise knowing or altering its state. Any element with this property will apply classes to its parent and also remove this child element afterwards so should ideally be used as part of a `hx-swap-oob="beforeend: #some-element`. | ||
|
||
## Install | ||
|
||
```html | ||
<script src="https://unpkg.com/[email protected].0/class-tools.js"></script> | ||
<script src="https://unpkg.com/[email protected].1/class-tools.js"></script> | ||
``` | ||
|
||
## Usage | ||
|
@@ -30,4 +32,7 @@ optionally followed by a colon `:` and a time delay. | |
class "foo" after 1s --> | ||
<div classes="toggle foo:1s"/> <!-- toggles the class "foo" every 1s --> | ||
</div> | ||
<div hx-swap-oob="beforeend: #my-element"> <!-- adds the class "foo" to my-element for 10s --> | ||
<div hx-ext="class-tools" apply-parent-classes="add foo, remove foo:10s"></div> | ||
</div> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters