-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Ensure proper and stable CSS insertion ordering #3678
Comments
I don't find an easy way to do that. We need client modules to be added in CSS first because Infima is a client module, and the theme css modules should be able to override Infima. Looks like we need another system to be able to have 3 kind of css:
I'm not sure how we can make this but it's unlikely we can do that using the clientModules API, otherwise Infima would end up overriding theme css modules |
Maybe custom CSS files will include after main CSS file as separate |
this can probably be done but I don't know how yet |
Hm.. what about "lazy" load custom CSS, something like as in Algolia's doc search? |
this only works if that CSS will only be displayed on HTML that is not immediately visible, otherwise it will produce FOUC. |
Agree, so we need to create new webpack entry specially for the custom CSS files? |
I think yes, and find a good api to express that for users, maybe something like siteConfig.customCSS = string | string[] |
I'd rather leave the |
I don't think it's a good idea, because the theme would need a new plugin lifecycle to be able to add this css at the bottom of the stylesheet. |
All right then, I just wanted to avoid another deprecated filed (and use new filed instead), as this is a manual process by the users. |
Yes. I guess we could keep the theme customCss field, but maybe deprecate it in the doc (or at least recommend to use site. customCss field) and add a Joi warning? (afaik it's possible to have Joi validation warnings instead of errors, but I don't think our code can handle warnings already) |
Sounds good, but now we need to figure out how to do what we want 🤔 |
I don't know why but I added "chokidar": "^3.5.1" to the packages.json and now all entries in my custom.css is loaded. |
Clarify the issue: currently, the styles (specified in CSS modules file) of Docusaurus built-in components cannot be overridden, except by applying |
Hello there I think I run into this issue. I (as a non developer/devops engineer ) am using the \src\css\custom.css with more than less success to customize few properties of the site. My current goal is to change the width of the document - TOC rows (inside the docMainContainer) from the default 75% -25% to 85%-15% using css properties. I looked at #3955 , #3879 and more but was not able to generate the proper styling because the element has the 75% !important property which overrides anything I set for it. My workaround for the time is doing a build, then search for the "75% !important" string and replacing the !important part of string with "". That and custom css property at the end of the post solves the issue for me. Thank you for reading this and your efforts for creating this tool. Cheers. .row .col.col--3 { |
Revisiting this issue. I'm not sure how we are to fix it, and the more I think about it the more I believe we can just put the CSS file in I would agree on a |
That also makes sense to me.
But we might still want to have some processing/minification being run on that CSS file |
Added this isssue for the 2.0 milestone (see #6113), as it looks important that we commit to maintaining backward compatibility on CSS ordering |
The problem is not so easy to solve. For v2.0 we'll keep the existing behavior, at least we now have tests to ensure CSS order does not change by mistake. |
…red on build - rc-tooltip: https://www.npmjs.com/package/rc-tooltip - The issue was that two CSS declarations (.rc-tooltip & .rc-tooltip-hidden) appear with one order in development (.rc-tooltip then .rc-tooltip-hidden) and the reverse order in a build (.rc-tooltip-hidden then .rc-tooltip). - See facebook/docusaurus#3678 - This patch fixes the issue by ensuring that the .rc-tooltip-hidden class takes precedence over the .rc-tooltip class.
### Description This PR make some changes on some selectors' specificity. Due to the way Docusaurus build production styles, this could sometimes create a problem through the CSS injection order, making some Infima styles override custom ones. To overcome this, we are using a subtle trick by duplicating the class in our CSS, to increase the specificity of our selectors. It doesn't seem like an easy task to solve in general for Docusaurus. More info in: facebook/docusaurus#3678 It also adds proper styling for the Table of Contents on mobile. This closes #147 ### Preview ![imagen](https://user-images.githubusercontent.com/7753447/230122746-a8eb2d3d-f70b-4bb1-92b2-1ea06ca65563.png) ![imagen](https://user-images.githubusercontent.com/7753447/230122431-ddd3dd06-5b06-4e8b-a91e-1aae1723e5f2.png)
### Description This PR adds a small section with syndication links to the blog posts listing page. It also removes some `TODO` code that has deemed to be not successful for what we wanted to. Basically, after submitting an issue to one of our library dependencies, I thought that by the uses of the CSS Modules `composes` feature, we could avoid the CSS injection order problem present in: #147 #158 facebook/docusaurus#3678 But it doesn't seem to be the case, so we are in the need of the use of the double selector trick to successfully override some Infima selectors styling with our classes. This closes #153 ### Preview ![imagen](https://user-images.githubusercontent.com/7753447/230139114-f5ef7faa-5988-4871-8dd9-60b91caf2352.png)
Edit: this issue is now about ensuring that we have a properly specified CSS insertion ordering with the ability to prevent regressions.
For Docusaurus 2.0 (#6113), CSS insertion ordering should become stable and documented. Upgrading Docusaurus should not lead to a different CSS ordering in particular for user-provided custom CSS.
See also #5987 (comment)
Original bug report below:
🐛 Bug Report
During a little refactoring, I realized that the custom CSS files content is not at the end of final CSS file
styles.css
(as it expected). This makes it impossible to override the Docusaurus component styles without applying the!important
rule (which in turn is bad practice).@slorber could you please investigate this issue? Can we "force" the custom CSS content to be at the end of all other styles?
By the example of Docusaurus website you can see that custom CSS is somewhere in the middle of bundled CSS file.
The text was updated successfully, but these errors were encountered: