-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 opportunity to use custom prefixes in StyleSheet #3015
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1a892d4
Add opportunity to use custom prefixes in StyleSheet
InsanusMokrassar b32a136
compilation fixes
InsanusMokrassar 505ef28
Merge branch 'JetBrains:master' into patch-3
InsanusMokrassar 0aac3d0
make StyleSheet#prefix protected and get back public StyleSheet#usePr…
InsanusMokrassar bfb7cb1
improve tests for StyleSheet
InsanusMokrassar 727e47b
improve tests for StyleSheet animations
InsanusMokrassar 827d856
rename StyleSheet prefix parameter to customPrefix
InsanusMokrassar 45a4334
use old constructors in StyleSheetTests old test
InsanusMokrassar cff79b5
update kdocs for StyleSheet
InsanusMokrassar 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,13 @@ class StyleSheetTests { | |
|
||
@Test | ||
fun extendExistingStyleSheet() { | ||
val styleSheet = object : StyleSheet(usePrefix = false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's keep the old constructor test here too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed :) |
||
val styleSheet = object : StyleSheet(prefix = "") { | ||
val someClassName by style { | ||
color(Color.red) | ||
} | ||
} | ||
|
||
val childStyleSheet = object : StyleSheet(styleSheet, usePrefix = false) { | ||
val childStyleSheet = object : StyleSheet(prefix = "", styleSheet) { | ||
val someClassName by style { | ||
color(Color.green) | ||
} | ||
|
@@ -42,4 +42,34 @@ class StyleSheetTests { | |
) | ||
} | ||
|
||
@Test | ||
fun stylesheetCorrectlyUsingIncomingPrefix() { | ||
val testPrefixParent = "test_prefix_parent-" | ||
val testPrefixChild = "test_prefix_child-" | ||
|
||
val styleSheet = object : StyleSheet(prefix = testPrefixParent) { | ||
val someClassName by style { | ||
color(Color.red) | ||
} | ||
} | ||
|
||
val childStyleSheet = object : StyleSheet(prefix = testPrefixChild, styleSheet) { | ||
val someClassName by style { | ||
color(Color.green) | ||
} | ||
} | ||
|
||
assertContentEquals( | ||
listOf(".${testPrefixParent}someClassName { color: red;}", ".${testPrefixChild}someClassName { color: green;}"), | ||
styleSheet.serializeRules(), | ||
"styleSheet rules" | ||
) | ||
|
||
assertContentEquals( | ||
listOf(".${testPrefixParent}someClassName { color: red;}", ".${testPrefixChild}someClassName { color: green;}"), | ||
childStyleSheet.serializeRules(), | ||
"childStyleSheet rules" | ||
) | ||
} | ||
|
||
} |
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.
Does it make sense in your opinion to name this constructor parameter something like
customNamePrefix
or justcustomPrefix
?So it's not confused with
protected val prefix: String
...Then it will be easier with this line:
val usePrefix: Boolean = prefix == null
// by looking at this line it's not clear right away whatprefix
is meant here (from constrcutor of the property)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.
renamed to
customPrefix
:)