Skip to content

feat(sass): Added Support for Less to Sass Conversion #692

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

Merged
merged 1 commit into from
Dec 15, 2017

Conversation

dtaylor113
Copy link
Member

@dtaylor113 dtaylor113 commented Dec 13, 2017

Description

From the updated README.md:

Less to Sass Conversion

During the build process Less files are converted to Sass files in /dist/sass. Then the Sass files are compiled into /dist/sass/angular-patternfly.css. If you would like to copy the Sass generated css into the main /dist/styles directory, execute:

grunt build --sass

This task will copy /dist/sass/angular-patternfly.css to /dist/styles/angular-patternfly.css. Then the build process will minimize the css in /dist/styles.

The Less to Sass Conversion step will be accomplished and managed as a part of any Pull Request which includes Less file changes. Although contributors may want to build and test their style changes with Sass before submitting a Pull Request, this step should always be tested and validated by reviewers before a style change is merged and released. If a contributor is having issues with Sass conversion that they cannot resolve, Pull Request reviewers will need to ensure that the Sass conversion step is successfully accomplished, tested, and included in the Pull Request before it is approved and merged.

For more detailed information, please read PatternFly Less to Sass Conversion

Note: When a Less file is added/deleted/renamed it needs to be updated in the main Less import file /styles/angular-patternfly.less and the main Sass import file /styles/_angular-patternfly.scss.

New dist/sass directory and files.

image

Fixes: #688

The sass-2-css file is almost identical to the less-2-css file; just diffs in line breaks. The minified versions are identical!

**Thanks to @TheRealJon for leading the way in the less-2-sass conversion process :-)

@dtaylor113 dtaylor113 changed the title chore(sass): Added Support for Less to Sass Conversion [WIP] chore(sass): Added Support for Less to Sass Conversion Dec 13, 2017
@TheRealJon
Copy link
Contributor

Do we want a top level _angular-patternfly.scss file to import the rest of the partials?

@dtaylor113
Copy link
Member Author

Do we want a top level _angular-patternfly.scss file to import the rest of the partials?

Do you mean in addition to styles/build.scss?

@dtaylor113
Copy link
Member Author

Don't know why Travis is failing with:


Running "sass:patternfly" (sass) task
>> 
Error: File to import not found or unreadable: ../node_modules/patternfly/dist/sass/patternfly/_color-variables.scss.
>> 
       Parent style sheet: /home/travis/build/patternfly/angular-patternfly/styles/build.scss
>> 
        on line 1 of styles/build.scss
>> 
>> @import '../node_modules/patternfly/dist/sass/patternfly/_color-variables.scss
>> 
   ^

sass:patternfly runs fine locally. package-lock.json has patternfly at v3.31.2 which should have the ../node_modules/patternfly/dist/sass/patternfly/_color-variables.scss file.

@TheRealJon
Copy link
Contributor

TheRealJon commented Dec 13, 2017

Do we want a top level _angular-patternfly.scss file to import the rest of the partials?

Do you mean in addition to styles/build.scss?

Yes. The build.scss file is for dev/test purposes to build css from the sass (since sass ignores partials by default, you can't compile from a file that starts with _). The _angular-patternfly.scss partial would ship in dist so that it could be consumed. That way consumers don't have to import individual partials. Then build.scss could also just @import 'angular-patternfly';.

@dtaylor113
Copy link
Member Author

The _angular-patternfly.scss partial would ship in dist so that it could be consumed. That way consumers don't have to import individual partials.

Ok, implemented this. May need a little help documenting how app devs are supposed to consume _angular-patternfly.scss. -thanks

@TheRealJon
Copy link
Contributor

@dtaylor113 I just opened a PR on your fork to flatten the dist/sass directory. I also slightly adjusted the includePaths option in your grunt sass task so that the imports in _angular-patternfly.scss can be relative. This was mainly for consistency with the way patternfly core works.

As far as downstream consumption, in most use cases, people should be able to just add node_modules/angular-patternfly/dist/sass to their build tool's search path, then @import 'angular-patternfly'; in their sass.

@dtaylor113
Copy link
Member Author

Awesome! Thanks @TheRealJon !!!

@dtaylor113
Copy link
Member Author

dtaylor113 commented Dec 13, 2017

Arrrrg...Travis still failing with:

Running "sass:patternfly" (sass) task
>> Error: File to import not found or unreadable: patternfly/color-variables.
>>        Parent style sheet: /home/travis/build/patternfly/angular-patternfly/styles/_angular-patternfly.scss
>>         on line 1 of styles/_angular-patternfly.scss
>> >> @import 'patternfly/color-variables';
>>    ^

@TheRealJon
Copy link
Contributor

Yeah, I just noticed this. I don't know why. The build runs fine on my machine. I'll fiddle around with it and see if I can figure something out.

@dtaylor113
Copy link
Member Author

Thanks @TheRealJon the switch to "patternfly": "^3.31.0" did the trick!!!!

@dtaylor113 dtaylor113 changed the title [WIP] chore(sass): Added Support for Less to Sass Conversion chore(sass): Added Support for Less to Sass Conversion Dec 13, 2017
@@ -0,0 +1 @@
@import 'angular-patternfly.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

@dtaylor113 can you remove the .scss extension from this import statement so that all of the imports are standardized?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, done

TheRealJon
TheRealJon previously approved these changes Dec 14, 2017
@@ -11,7 +11,7 @@ globals:
rules:
strict: [2, "function"]
quotes: 0
camelcase: 2
camelcase: 1
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, was throwing an error due to new task in gruntfile 'convert_within_custom_replacements' not being camelcase:

lessToSass: {
        convert_within_custom_replacements: 

@@ -0,0 +1 @@
@import 'angular-patternfly';
Copy link
Member

Choose a reason for hiding this comment

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

I think this file needs to be named angular-patternfly.scss for it to be intuitive for consumption. This likely means moving the partials into a sub-directory or adding all the partials here rather than having an _angular-patternfly.scss

Copy link
Member Author

Choose a reason for hiding this comment

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

@TheRealJon recommended the main partial:
"Yes. The build.scss file is for dev/test purposes to build css from the sass (since sass ignores partials by default, you can't compile from a file that starts with _). The _angular-patternfly.scss partial would ship in dist so that it could be consumed. That way consumers don't have to import individual partials. Then build.scss could also just @import 'angular-patternfly';."

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it needs to begin with a "_" in order to be @import'ed

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't have to start with an underscore, but we are doing it that way in patternfly core, so I figured it would be better to keep things consistent. It's also done similarly in other libraries like bootstrap-sass and font-awesome-sass.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just tested renaming to "angular-patternfly.scss" and css generated correctly. Just want to make sure that "...The angular-patternfly.scss partial would ship in dist so that it could be consumed. That way consumers don't have to import individual partials.." is still correct. In other words, app devs can sill consume (@import?) 'dist/angular-patternfly.scss', even though it doesn't begin with an underscore. -thanks

Copy link
Member

Choose a reason for hiding this comment

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

OK, this is fine then.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just as a reference:

Sass Partials
Sass Imports

Sass does a bit of magic with imports and file names, so those sections definitely cleared some confusion up for me.

@jeff-phillips-18
Copy link
Member

I think this should be a feat. This is worthy of a point release.

@jeff-phillips-18 jeff-phillips-18 changed the title chore(sass): Added Support for Less to Sass Conversion feat(sass): Added Support for Less to Sass Conversion Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add LESS-to-SASS Converter
3 participants