-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Extract Classes to a separate macro #1601
Conversation
Hello @siku2 👋 Here is finally another implementation for the classes that we talk about. Since it is not possible to have the behavior that we have on "class" attributes in Overall it works well and would even reduce the code size (after cleanup). But there are a few caveats:
Since yew is still in version 0.x.y I think it would be okay to make a breaking change to the 0.18. The code would only force people to adapt by prefixing all their classes by <div class=("a", "b") /> To <div class=classes!("a", "b") /> Overall I think it's beneficial and it is worth the change (because the inconsistency bothers me) but you might have a different opinion. What do you think? |
I don't pretend to have always excellent ideas :D don't hesitate to reject! |
This isn't quite what I had in mind when I said "discussion" 🙃. My weak little heart wouldn't be able to reject this after you put in all this work... I do like the idea of a The biggest issue is that this is a super duper mega breaking change. This will force basically every single Yew app to update and it's not always as simple as adding
The problem is that there isn't even a consistent behaviour across components. Here are two approaches I'm comfortable with:
Again, the purist in me is totally in favour of moving classes out of |
Oops! 😓 I didn't mean to force your hand. I felt like I needed to test a bit more my idea to see if it is even possible and how it translates. Really I didn't spend that much time on it. This is fine!
There are 2 things but nothing more:
I see your point. My point is only that it will make things more consistent in general. Not perfect.
This is a good point. It's not exactly removed either...
That is very bad for me. I mean the idea is good and well intended but custom components might accept multiple class props that are applied on different HTML tags (or even other components) in their own component. Here is an example with blueprint having 2 classes property: visibleItemClassName and className (inferred from IProps). For me this is a no go. NB: I don't think copying react is a rule of thumb, I'm very happy with Yew taking its own direction and I personally see already a lot of improvement over react because of that (mostly the state management). I don't not think either that class being exactly a
I wanted to answer first before re-modifying my PR again so I don't jump from one thing to another and have a hard time to explain what happens in my head... but I have an idea 😁 similar to what you proposed. Since The only difference that would still remain is that There might also be a point about treating any attribute that uses the BTW, almost entirely not related. I was wondering why we use
-- Source: https://stackoverflow.com/questions/1321692/how-to-specify-the-order-of-css-classes |
Ready for review cc @siku2 |
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.
GitHub kind of broke because a new commit was added while I was reviewing this. Let's hope it still turned out okay.
Looks like it survived. This should be the last review for the code itself 🎉 (unless the final re-review surfaces some issue I missed, of course)
Co-authored-by: Simon <[email protected]>
Okay that's not really how I imagined it. The code examples are way too verbose now and it's hard to tell what to look at. |
It can be cleaned-up a bit by removing the Boolinator import where it's not used and the struct with the component itself |
@siku2 do you have any idea for this? I an revert to a previous state if you prefer. Or do just as I said (cleanup things a bit) |
Ah sorry, I thought you were still playing around with it to see what's best. I honestly preferred the previous version because the code in the tabs should be as concise as possible (otherwise it distracts from the point of each tab). There was also possibly a misunderstanding because I was thinking about combining the list of
|
Now I understand why they want to rewrite the React's doc 😅 Apparently it gets messy because a lot of people wrote with their own style and at some point it isn't consistent. So... I reverted the latest change and instead I added an example tab for String and another one for Array ref. I'm not sure it would make much sense with Cow... I think the Cow is mostly here to handle the fact that we mix String and literals, I don't see a use case. Let me know what you think with this latest changes. Feel also free to correct by yourself, I really don't mind at all. |
Haha yeah, Yew's documentation is a mess of different styles.
Looks good enough :) |
Description
This PR will extract the code handling the classes from the macro
html!
and put it to its own macroclasses!
.The intention is to keep the super helpful macro for class composition but move it outside so people can create libraries for yew and allow their user to use this macro.
This is not possible at the moment because it is strongly coupled to the
html!
macro and only for base HTML tags (a, div, span, etc...) but not for custom component.Checklist
cargo make pr-flow
Related to #1588