Skip to content
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 9 commits into from Jan 31, 2024

Conversation

InsanusMokrassar
Copy link
Contributor

No description provided.

@InsanusMokrassar InsanusMokrassar marked this pull request as draft April 8, 2023 06:01
@InsanusMokrassar InsanusMokrassar marked this pull request as ready for review April 16, 2023 06:27
@InsanusMokrassar
Copy link
Contributor Author

InsanusMokrassar commented Jan 30, 2024

Hello everybody :) Is there any chance to see this patch in the master?

@InsanusMokrassar
Copy link
Contributor Author

@eymar hello, could you please review this PR? It would be very useful to see it in master and in next update of compose (for example, 1.5.13)

Copy link
Collaborator

@eymar eymar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please add new tests for your changes? Perhaps in


and


Apologies for long time without review. Currently compose.html library is in maintenance mode and we mainly keep up to date with new kotlin releases.

) : StyleSheetBuilder, CSSRulesHolder by rulesHolder {
private val boundClasses = mutableMapOf<String, CSSRuleDeclarationList>()
val prefix = prefix ?: "${this::class.simpleName}-"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does prefix need to be public? can it be private?

Also to preserve the compatibility, maybe it's worth to add a public val usePrefix with only getter that returns true when prefix is not null.

I gues val usePrefix didn't need to be public at all, but since it's already here, it's better to avoid breaking changes.

Copy link
Collaborator

@eymar eymar Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to see it in master and in next update of compose

it will likely go into 1.6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I resolved this point

@InsanusMokrassar
Copy link
Contributor Author

@eymar Thank you for your review! ❤️ I have added tests and fixed the points you mentioned above

@@ -17,13 +17,13 @@ class StyleSheetTests {

@Test
fun extendExistingStyleSheet() {
val styleSheet = object : StyleSheet(usePrefix = false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep the old constructor test here too.
Feel free to add a copy of this test with new constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed :)

@@ -38,12 +41,22 @@ class CSSRulesHolderState : CSSRulesHolder {
* ```
*/
open class StyleSheet(
prefix: String?,
Copy link
Collaborator

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 just customPrefix?
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 what prefix is meant here (from constrcutor of the property)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to customPrefix :)

Copy link
Collaborator

@eymar eymar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loos good to me!

@eymar eymar merged commit d9d4bf3 into JetBrains:master Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants