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

Converted CSS to SASS #1349

Merged
merged 10 commits into from
Jan 27, 2017
Merged

Converted CSS to SASS #1349

merged 10 commits into from
Jan 27, 2017

Conversation

heartsucker
Copy link
Contributor

I wanted to a add new features and CSS and is terrible to work with compared to SASS. This PR includes:

  • Convert all CSS to SASS
  • Combine duplicate SASS rules
  • Add SASS compilation to Ansible / builds

@heartsucker heartsucker force-pushed the sass branch 7 times, most recently from 7e56a35 to 5dd1d7c Compare July 3, 2016 13:41
@garrettr
Copy link
Contributor

garrettr commented Jul 5, 2016

Thanks for this PR, @heartsucker! I've been wanting to do this for a long time, since I agree CSS is terrible to work with compared to alternatives such as SASS. I'll review this by the end of the week.

@heartsucker
Copy link
Contributor Author

Hey guys. This is in need of some rebasing, but before I get to it, can someone take a look and let me know if this seems to be a good candidate for merge?

Copy link
Contributor

@garrettr garrettr left a comment

Choose a reason for hiding this comment

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

A quick question:

  • Do you prefer using SASS over SCSS? We're comfortable with either format, but SCSS seems to be slightly more popular these days.

Overall, this PR looks great. If you rebase it and fix the other comments from this review, we will merge it.

'cyan'),
lambda: DevServerProcess('SASS Compiler',
['sass', '--watch', 'sass:static/css'],
'magenta'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it necessary to add lambdas and change DevServerProcessMonitor.__init__? The commit message in 688b747 was unclear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If one of the subprocesses fails to start or throws and exception, the monitor will leave the other processes dangling. Each call to DevServerProccess needs a try/except around it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@heartsucker Thanks for the explanation! I'll take a look at this myself - I think there might be a way to more gracefully handle that case within DevServerProcess.

* HACK: Firefox likes to add non-existent leading and/or trailing whitespace
* to <span>s, but never does it to <p>s. This hack uses a <p> for the
* codename so we can get the right copy behavior, and uses inline-block plus
* tweaks the margin to make it look like a span
Copy link
Contributor

Choose a reason for hiding this comment

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

Close this comment.

font-size: 14px

p
*
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not? I'm not a CSS expert, so I made as few changes as possible when porting it to SASS.

Copy link
Contributor

Choose a reason for hiding this comment

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

@heartsucker Gotcha. Let's leave it in for now, it can be addressed in a follow-up if necessary.

{% assets filters="cssmin", output="gen/source.css",
"css/normalize.css", "css/source.css", "css/font-awesome.css" %}

{# TODO why doesn't a link to /static/source.css work? #}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should resolve this TODO before merging. It's best not to leave TODOs in merged code, if possible.

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'll take a look at this since there have been some updates to some of the dependencies since I wrote this and the behavior might have changed. Also, suggestions welcome since this one seems a bit non-intuitive.

args:
chdir: /tmp/{{ securedrop_app_code_deb }}/var/www/securedrop/
# register: sass_compile_result
# changed_when: sass_compile_result.stdout != ''
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is commented out, can it be removed?

@heartsucker
Copy link
Contributor Author

@garrettr I'm not really a web frontend guy, but more a guy who can do some frontend stuff when he needs. I happened to do it in SASS because that's what I know, but some poking around does seem to indicate that there are more advantages to SCSS. If y'all want that, I can make those change along with all of the rest of this.

@psivesely
Copy link
Contributor

I'm not really a web frontend guy

Me either.

poking around does seem to indicate that there are more advantages to SCSS.

From a little research, I saw a decent amount of opinion to that point as well. E.g., http://thesassway.com/editorial/sass-vs-scss-which-syntax-is-better.

If y'all want that, I can make those change along with all of the rest of this.

If that isn't too much work for you, it seems to me like that might be good, just because it seems like SCSS might be better for other contributors to work with in the future. Since I don't do much myself with the frontend codebase myself, I'm not going to make an absolute call one way or the other. Unless one of the other SD team members has strong opinions, we'll leave the decision up to you.

@garrettr
Copy link
Contributor

garrettr commented Dec 2, 2016

I happened to do it in SASS because that's what I know, but some poking around does seem to indicate that there are more advantages to SCSS. If y'all want that, I can make those change along with all of the rest of this.

@heartsucker I think SASS is fine. I polled some front-end folks that I know and people seem to be pretty evenly split on which one is "better". If we end up deciding to change to SCSS later, that seems to be trivial to do via sass-convert.

@heartsucker heartsucker force-pushed the sass branch 2 times, most recently from a8e974a to 039088b Compare December 3, 2016 14:57
@heartsucker
Copy link
Contributor Author

heartsucker commented Dec 3, 2016

This was tested on the dev VM, but it's not passing Travis because of this mystery:

TASK: [development | Install sass Ruby gem] *********************************** 
<localhost> state=latest name=sass
changed: [localhost] => {"changed": true, "name": "sass", "state": "latest", "version": "3.4.22"}

TASK: [development | Compile sass to css] ************************************* 
<localhost> chdir=/home/travis/build/freedomofpress/securedrop/securedrop
failed: [localhost] => {"changed": true, "cmd": "sass --update sass:static/css", "delta": "0:00:00.004013", "end": "2016-12-03 15:14:05.668050", "rc": 127, "start": "2016-12-03 15:14:05.664037", "warnings": []}
stderr: /bin/sh: 1: sass: not found

It's saying the gem was installed (globally), but then it's not on the path. Anyone have any experience debugging the Travis environment? Also, I added verbosity to build in hopes that it might tell us something, but alas.

This appears to be related: travis-ci/travis-ci#5861

@heartsucker heartsucker force-pushed the sass branch 5 times, most recently from 0914b4b to 35daa9d Compare December 4, 2016 10:27
@redshiftzero
Copy link
Contributor

redshiftzero commented Dec 7, 2016

Hey @heartsucker, I took a peek at this PR yesterday and it does look to be a weird PATH issue: one way to troubleshoot is to add a couple of post-install tasks in that Ansible play before you try to execute sass, e.g.:

- name: Check sass is in gem list
  command: gem list

- name: Check where gems are being installed
  command: gem environment

Since you put those -vv verbosity flags (good call) you can inspect the output and see what's going on with the PATH. This might not be the Best Way to debug this but it’s what I do ¯\(ツ)/¯. Give that a whirl, if things still look confusing let me know and I’ll take a deeper look.

@heartsucker
Copy link
Contributor Author

@redshiftzero I already did most of that (and them some), but even when putting calls sass with the full path /usr/lib/gems/sass (or whatever it was), it still fails. I've never dealt with Ruby, so whatever seems to be going on with RVM is new to me. Anywho. I can probably get to this this weekend.

@heartsucker
Copy link
Contributor Author

Pinging for review/merge.

@heartsucker
Copy link
Contributor Author

Doubling down on the request for merge because there are a bunch of UI tickets that got opened today, and it would be nice to do this first.

@heartsucker
Copy link
Contributor Author

@garrettr? @fowlslegs? @redshiftzero? Bueller?

@conorsch
Copy link
Contributor

Whoa, sorry about the lag on this one, @heartsucker! Thanks for your persistence, getting this in pronto. (Yes, the hack in b9c78be is indeed adventurous approach, but it works well enough for the dev env!)

@conorsch conorsch merged commit 0ed80f8 into freedomofpress:develop Jan 27, 2017
@heartsucker heartsucker deleted the sass branch January 28, 2017 15:03
This was referenced Jan 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants