-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add [key]Classes method to better handle multiple CSS classes #344
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
54e077e
Add [key]Classes method to better handle multiple classes
f578181
Handle undefined edge case
b96aa48
Accessing utility classes with singular property returns first class …
1a4cd87
Style
f83aeed
Add docs draft
6e19416
Remove whitespace
caecf0f
Code review recycle
aa01760
Refactor tokenize to string_helpers
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
@@ -1,26 +1,37 @@ | ||
import { ControllerTestCase } from "../cases/controller_test_case" | ||
import { ClassController } from "../controllers/class_controller" | ||
|
||
export default class ValueTests extends ControllerTestCase(ClassController) { | ||
export default class ClassTests extends ControllerTestCase(ClassController) { | ||
fixtureHTML = ` | ||
<div data-controller="${this.identifier}" | ||
data-${this.identifier}-active-class="test--active" | ||
data-${this.identifier}-loading-class="busy" | ||
data-${this.identifier}-success-class="bg-green-400 border border-green-600" | ||
data-loading-class="xxx" | ||
></div> | ||
` | ||
|
||
"test accessing a class property"() { | ||
this.assert.ok(this.controller.hasActiveClass) | ||
this.assert.equal(this.controller.activeClass, "test--active") | ||
this.assert.deepEqual(this.controller.activeClasses, ["test--active"]) | ||
} | ||
|
||
"test accessing a missing class property throws an error"() { | ||
this.assert.notOk(this.controller.hasEnabledClass) | ||
this.assert.raises(() => this.controller.enabledClass) | ||
this.assert.equal(this.controller.enabledClasses.length, 0) | ||
} | ||
|
||
"test classes must be scoped by identifier"() { | ||
this.assert.equal(this.controller.loadingClass, "busy") | ||
} | ||
|
||
"test multiple classes map to array"() { | ||
this.assert.deepEqual(this.controller.successClasses, ["bg-green-400", "border", "border-green-600"]) | ||
} | ||
|
||
"test accessing a class property returns first class if multiple classes are used"() { | ||
this.assert.equal(this.controller.successClass, "bg-green-400"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simpler (and slightly faster) method of doing this is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do add a PR 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR #430