-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Utilities functions mixin #37398
base: main
Are you sure you want to change the base?
Utilities functions mixin #37398
Conversation
@julien-deramond @louismaximepiton @ffoodd Would love your thoughts on this! Kind of a few PRs worth of history to look through for the full context, but would love to add this for v5.3. |
Happy to answer any question about the code 😄 One of the things buried in the previous PRs (sorry for the mess with my branches) is that the code is checked by a test suite (kept on a separate branch as it'd rely on sass-true to have been brought into the project, which is getting sorted in #36029). |
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.
Just few questions, small things to change IMO and as global comments:
Should we introduce default values on each function/mixin ?
Should we check each time for existence of the map ?
What's the future for the maps.scss
file ? I thought it was for this kind of purpose (redefine some maps before using them inside utilities API).
However, this sounds really great to have inside Bootstrap. This doesn't add compiled CSS, might not bring any breaking change, might be really useful when well used ! Great work :)
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.
@louismaximepiton Thanks for the review 😄 I've finally found some time to provide some answers, at least for those related to the internals of the functions/mixins. I can only let you and the Bootstrap team decide on whether functions should be extracted in other files and such 😄 .
I'm not quite sure how to deal with the few amends as it's now @mdo's branch on the Bootstrap repo. A PR towards this branch feels a bit overkill, and it'll likely be much faster if someone with write access moves things around (especially as I don't have as much capacity to contribute nowadays, sorry).
As a side note, now #36029 has been merged, it's likely worth pulling in the tests I had set up on a separate branch for writing these functions and mixins.
- get options, a specific option or a specific value for a given utility - set options, new values or remove values for a given utility - add or remove utilities
e79e7f6
to
2560a59
Compare
Split the utilities-map helpers in their own file to make tests a little more isolated
- use consistent variable name - use consistent code structure for functions that do similar things - remove code duplication for utilities-add
1261f1f
to
5df18c3
Compare
@louismaximepiton I've tidied up the code in the functions and mixins so the variable names are more consistent and removed code duplication. I've also brought in the tests that I had used when writing the code to make sure things stay shipshape. To make the test files not too large, I've split the code for manipulating the utilities map in its own file. I think it's fine for it to have a mix of Sass functions and mixins despite being in the |
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 think it's way better to read and understand now in the right order (in the scss), thanks for that !
For the API page, I think we should at least keep one example of the previous method to show how that it's still feasible.
Some few questions remains for me, but the work done since last time I reviewed it is insane, well done !
Now that you're familiar with how the utilities API works, learn how to add your own custom classes and modify our default utilities. | ||
{{< callout success >}} | ||
**New in v5.3.x!** We've added new mixins and functions to better help you use our utilities API. These replace our previous guidance of using Sass's built-in `map-merge()` function and add new functionality for [composing components with utilities](#get-values-and-options). | ||
{{< /callout >}} |
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 find it a bit weird to use a callout success as it is only used there, wondering if we should only do something like https://deploy-preview-37398--twbs-bootstrap.netlify.app/docs/5.3/customize/sass/#add-to-map.
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.
@louismaximepiton I don't see any special treatment on the "add-to-map" page, so I'm not sure what you mean. I did find a few examples of new features highlighted in 5.2.0:
- with bold text in https://getbootstrap.com/docs/5.2/components/navbar/
- and with a little block in https://getbootstrap.com/docs/5.2/components/badge/#background-colors
Maybe the callout is just the progression for that for when we want not just to say there's a new feature but also add a bit of text to describe what changes? @mdo what was your reason for using a callout?
Updated again, hopefully I didn't miss anything. Thanks for the comments 😊
🤔 Ultimately we'd want to encourage people to use those mixins, not tamper with the
Thanks, though that was mostly bringing the tests that were already waiting in a separate branch for the sass-true PR to be merged, so not as big an edit as the diff makes it look like 😆 |
1dea580
to
7298ae0
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.
Looks fine to me, let's wait for another thought on the way to add some text in a new feature ! Great work 😄
Replaces #37114 because I couldn't push to that PR.