question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dealing with css conflicts

See original GitHub issue

The addon I am writing docs for uses a design system that is based on Tachyons. This is causing me problems in a few cases, most notably with the absolute class added to the nav here. The problem is that because I’m importing my css first before the css from this addon my absolute is superseding positioning applied to the nav by the lg:relative class and therefore always positioning the nav absolutely.

I think there might be a way to fix this particular case, but more broadly do you have any advice on how to address this kind of issue?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
samselikoffcommented, Jul 30, 2019

I don’t have time to work on this now, but for anyone who’s motivated here’s what needs to happen:

We need to re-work AddonDocs’ usage of Tailwind to not include Tailwind’s Preflight styles.

These base styles make sites easier & more consistent to work with, but it is possible to use Tailwind’s utilities without them. I believe Adam said the biggest change is that the use of border now needs to be accompanied with a border color and border style. You can read some about that here, as well as other changes Preflight brings along – but note that that link is to 1.0, and AddonDocs currently uses Tailwind v0.

Unfortunately right now, AddonDocs uses ember-cli-tailwind which has the preflight directive hardcoded into its modules.css file. So to actually remove preflight, we need to first either (1) add a config option to ember-cli-tailwind, or (2) remove ember-cli-tailwind altogether, and wire up our own postcss pipeline with ember-cli-postcss that includes tailwindcss. This would also allow us to add purgess to the pipeline, which would be ideal. (This very reason is also why I’m going to deprecate the addon and suggest folks set up a postcss pipeline in their own projects.)

Once we exclude Preflight from our Tailwind build, we’ll then need to update our components to make sure things look good without the reset. We could either include a new reset like vanilla normalize, or include the option for no reset, so visual addons like Ember Styleguide can bring their own global styles and be guaranteed of no collisions with styles provided by AddonDocs.

The only other alternative I can think right now would be to expose an option that doesn’t include any css from AddonDocs, for addons that want full control over styling. Those addons could still use AddonDocs’ components as provider/renderless components, so they have things like the version selector in the header and the navigation index in DocsViewer. Then, those addons could style everything on their own.

I originally wanted to add renderless data-provider components for all the data AddonDocs provided, and then rebuild the UI components with those, so others could opt-out of the visual styles AddonDocs provides and still use the data providers. But I never got around to it.

If anyone wants to take this on and needs any help or direction, I am more than happy to provide some guidance!

https://github.com/embermap/ember-cli-tailwind/blob/master/lib/modules.css

3reactions
samselikoffcommented, May 7, 2018

Yes - we should probably prefix the Tailwind classes we’re using, perhaps with ad- so they don’t conflict.

I also want to get PurgeCSS in here so we don’t ship a bunch of unused classes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Conflict Resolution Rules Explained - Medium
When there are two different declarations for the same element but they focus on different attributes, the styles simply merge, and the element ......
Read more >
CSS Conflicts - Learneroo
If conflicting CSS rules have equal weight (see below), the rule that appears later in the CSS file will 'win'. This type of...
Read more >
Resolving conflicts in CSS made simple - Web Teacher
Things that affect the application of a CSS rule are explained: inheritance, cascade, specificity, the !important selector, and location.
Read more >
Systematically resolve conflicting styles in css - Stack Overflow
CSS doesn't have conflicts, it has cascades. The idea is that you CAN define multiple rules that apply to the same elements and...
Read more >
Avoiding CSS conflicts - Starcounter
BEM in Starcounter apps · Only use BEM class selectors in your stylesheets. · Give meaningful names to the block, element and modifier...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found