-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
feat: stylization shorthands #283
Conversation
4b33e14
to
f8a6b10
Compare
Codecov Report
@@ Coverage Diff @@
## main #283 +/- ##
==========================================
+ Coverage 82.71% 82.95% +0.24%
==========================================
Files 36 37 +1
Lines 7360 7476 +116
==========================================
+ Hits 6088 6202 +114
- Misses 1272 1274 +2
|
f8a6b10
to
b011d1d
Compare
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.
I'd like to see how this works for styled things outside this module. What imports are needed to make it work, and what do the calls for real-ish ui code look like? E.g. #241 (comment))
Can you please add some integration test for this in tests/stylize.rs
?
I suspect that it might make sense to move the impl Styled
code to e.g. paragraph.rs
etc.
095b8d7
to
4452bd4
Compare
All the necessary tests are already in |
My thinking behind this was that usually I'd organize tests which deal with just the things defined in a module within that module (e.g. here it's just the traits, which don't actually need tests of themselves - which probably means that they could just be added in style.rs perhaps?) Whereas the stylized methods are only really part of the { Does that make sense or am I overthinking it? Edit: Put a simpler way, unit tests show that the individual types in a specific module work. Integration tests show that modules work together from the perspective of someone using them. |
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.
This is looking pretty good.
I'd like some of the other devs to sanity check this (ping @sayanarijit @orhun), but I think it will be good once the missing tests and docs are added.
When adding the tests, have a think about the user of this and what the imports look like. I think it might make more sense for a use to find and import this feature as style::Stylize" instead of
text::Stylize`. If so, let's move the entire stylized file under the style mod and re-export the trait(s).
If this is the preferred way of stylizing text, I think it would be nice to convert examples to use those changes. This would also show how the changes would look like from the user's perspective. |
93e77d9
to
368c251
Compare
Looking at the examples convinces me that this is really useful (and that What documentation is necessary to help users find and understand this feature in the generated docs? (Happy to make that another PR if that would work better?) |
368c251
to
870f88a
Compare
870f88a
to
dda06fd
Compare
It's neither here nor there whether people use inline, variables or the easier methods. Each has their pros and cons. |
Thanks for your effort in this. |
fix: #241
This PR adds the ability to use style shorthands to
str
,Span
, andParagraph
.Examples