Skip to content
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

Refactored css to avoid need for sass, postcss and autoprefixer #264

Merged
merged 4 commits into from
Sep 2, 2018

Conversation

chrism
Copy link
Contributor

@chrism chrism commented Aug 29, 2018

As per my slack question this is a PR which hopefully addresses issues relating to SASS compilation.

For me, the main one was the missing source map error message which was caused upstream by ember-cli-sass #76 & #113

But I think it could also simplify a lot of the issues people have had in general working with the styling.

Initially I just flattened the selectors in the addon.scss file to remove the need to use any processing and converted it to a css file.

My plan was to then just use processing for the styling of the dummy app.

Unfortunately this wasn't sufficient to use ember-cli-sass purely as a dev dependency (because the addon.scss file gets automatically included in the pipeline by default when ember-cli-sass is installed).

Looking at the styling for the dummy app it showed that SASS was only necessary for some nesting of selectors (and some color variables).

I used the same approach as with the addon.scss file to flatten the selectors and by using native CSS variables it removed the need for SASS completely.

My rationale is that as this styling isn't even used by the addon, purely for the tests and documentation it would be acceptable to require modern browser support.

Doing this allowed me to remove 3 styling addons which are no longer necessary

  • ember-cli-sass
  • autoprefixer
  • ember-cli-postcss

Additionally, in the course of updating the files I noticed that the ember-code-snippet addon was injecting some CSS into the addon.css that wasn't being used by the addon and actually conflicted with the extra CSS from _code.scss in the dummy app.

The current live documentation http://sir-dunxalot.github.io/ember-tooltips/ seems to have some inconsistent code styling and I feel like this might have been a contributing factor.

So I took the opportunity to also clean this up a bit by removing all that unused styling code and then implemented a simple colour scheme that works with the handlebars code (see example below).

screen shot 2018-08-29 at 16 06 43

I also followed the recommendations in the documentation to not use the default highlight.js file and instead a custom one.

The tests all still pass and I've also tested it in an existing app and a new app without any issues.

I'm hoping you agree that this will make the use of this addon more straightforward and reduces the chances of issues due to the styling pipeline.

@maxfierke maxfierke added this to the 2.11.0 milestone Aug 29, 2018
@maxfierke maxfierke added enhancement 2.x ember-tooltips Release series 2.x labels Aug 29, 2018
Copy link
Collaborator

@maxfierke maxfierke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I have one comment about documenting where the vendored highlight.js came. Unless @sir-dunxalot has any objections, I will merge it after that!

@@ -0,0 +1,34 @@
/* Colors */

:root {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe CSS variables here without PostCSS might kinda break the demo site on IE11, but I think that's probably fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope that the second commit should help with this — the variables now only override the default colour scheme so on IE it should display OK but without code highlighting.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am fine with using css variables. I'd be surprised if any devs are using IE11 😛

@@ -37,5 +16,9 @@ module.exports = function(defaults) {
behave. You most likely want to be modifying `./index.js` or app's build file
*/

app.import('vendor/highlight.pack.js', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity's sake, what were the options used for generating this? Might be worth adding a comment above.

@chrism
Copy link
Contributor Author

chrism commented Aug 29, 2018

Thanks @maxfierke I've added the comment explaining the customization.

Copy link
Collaborator

@maxfierke maxfierke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrism just noticed one quick tiny css thing, but other than that, this looks good to go 🚀

h3 {
border-bottom: 1px solid #ccc;
}
.ember-popover h3, p {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed this: should probably be .ember-popover p, right?

@chrism
Copy link
Contributor Author

chrism commented Aug 29, 2018

@maxfierke thanks! well spotted 👍

height: 10px;
margin: -5px;
background: inherit;
transform: rotate(45deg);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main thing to be aware of with the removal of the autoprefixer dep is we drop support for a couple of lesser-used old browsers. To be extra safe, perhaps we can add in -webkit prefixes for transform and transition rules. However, I don't really mind either way since:

  1. This is already supporting graceful fallbacks
  2. We can deal with this if and when an issue is reported

So I'll leave the addition of prefixes up to @chrism's discretion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sir-dunxalot, thanks for the review.

My understanding is that transform & transition only remain unsupported by IE8 and opera mobile.

Using a prefix (such as -webkit) wouldn't solve this for those two browsers (would require polyfilling I think) and as Ember 2.0 itself no longer supports IE8 I'd hoped it wouldn't be necessary to support it in this addon.

Also, another consideration is that as the transform is located in a pseudo element selector (:after) I don't think IE8 supports that anyway.

If I've got some of this wrong I'd be happy to update, but I don't think there is much possible for the reasons I've listed.

Thanks.

@sir-dunxalot
Copy link
Owner

@maxfierke @chrism LGTM. 👍

@maxfierke maxfierke merged commit 5efe9e3 into sir-dunxalot:master Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x ember-tooltips Release series 2.x enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants