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
Sass port #122
Sass port #122
Conversation
Awesome! It looks like only flexbox, border styles, and tabs are the only things I see in a quick pass through are out of wack. But this is stellar for an initial PR and work in progress on such a major overhaul. I'll take some time to look through the details, but these are just my initial comments. Great stuff! |
I agree with @rhyneav, this is a great improvement and thank you for making this! |
Thanks 😄 👍 @rhyneav radios and checkboxes are not working as intended, too. I'll get those things out of the way as soon as I can. Things left to do on my list:
|
That all sounds great! @Fraham will know more about the tests, but I believe they are just testing the compiled CSS. Ideally, the tests should still pass after the refactor without needing to alter the tests. |
Just a suggestion. Can we not put everything in the |
Sure. /* PaperCSS Core */
@import 'core/config';
@import 'core/reset';
/* Layout Styling */
@import 'layout/flexbox';
@import 'layout/fonts';
@import 'layout/container';
@import 'layout/shadows';
@import 'layout/borders';
/* Components */
@import 'components/forms';
@import 'components/buttons';
@import 'components/lists';
@import 'components/code';
@import 'components/tables';
@import 'components/images';
@import 'components/utilities';
@import 'components/popovers';
@import 'components/cards';
@import 'components/badges';
@import 'components/alerts';
@import 'components/tabs';
@import 'components/article';
@import 'components/modals'; Or do you have a better directory structure in mind? |
I agree with @MunifTanjim and it's clearly better now. Every framework work like this. |
Some numbers after the refactor: LESSBuild time with
|
@koester Looks great. Maybe we can move things around a little more. e.g.
It's up to you. btw, great work! 👍 😃 |
Thanks 😄 I added your suggested folder structure and regenerated the package-lock.json for a 1.4.0 release. |
After some testing and I'd say the SCSS port looks stable. Everythings working as expected. SCSS port overviewYou can see and test the compiled CSS of this SCSS port at https://deploy-preview-122--astronaut-pig-36111.netlify.com The refactor for this port got pretty big and the project structure changed quite a bit. I hope this will help maintainers to get a quick overview of the changes and the new additions. Any mentions of 1.4.0 will refer to this SCSS port and 1.3.x to the current LESS version. Project structureThe structure of the project changed to build upon the modular approach introduced with 1.3.x and further enhance it. In 1.3.x: src
├── alerts.less
├── article.less
├── badges.less
├── borders.less
├── boxreset.less
├── buttons.less
├── cards.less
├── code.less
├── colors.less
├── container.less
├── flexbox.less
├── fonts.less
├── forms.less
├── images.less
├── lists.less
├── modals.less
├── popovers.less
├── reset.less
├── shadows.less
├── styles.less
├── tables.less
├── tabs.less
└── utilities.less
0 directories, 23 files In 1.4.0: src
├── components
│ ├── _alerts.scss
│ ├── _article.scss
│ ├── _badges.scss
│ ├── _buttons.scss
│ ├── _cards.scss
│ ├── _forms.scss
│ ├── _modals.scss
│ ├── _popovers.scss
│ ├── _tabs.scss
│ └── _utilities.scss
├── content
│ ├── _code.scss
│ ├── _fonts.scss
│ ├── _images.scss
│ ├── _lists.scss
│ └── _tables.scss
├── core
│ ├── _config.scss
│ └── _reset.scss
├── layout
│ ├── _container.scss
│ └── _flexbox.scss
├── utilities
│ ├── _borders.scss
│ └── _shadows.scss
└── styles.scss
5 directories, 22 files So instead of all
When we build the CSS only A common problem: Lets say I'm building a wordpress theme and I really like the PaperCSS design of tabs and articles, but dont want to pollute my CSS with all the other components that I will never use. How can we solve this? Easy: /* PaperCSS core */
@import 'core/config';
/* Utilities */
@import 'utilities/borders';
@import 'utilities/shadows';
/* Components */
@import 'components/article';
@import 'components/tabs'; This will compile only the CSS I really need. If I'm already working with SCSS in my project I could also just The other components are still inside the project. But since they are Partials they wont compile into CSS (as long as you dont @import them somewhere).
The current project structure is more like a first draft and should be further changed down the road to address our needs. But as it is its working pretty well and should solve most use cases right off the bat. 23 LESS files but only 22 SCSS files?? The configThis new core/_config.scss holds pretty much every Every variable and mixin inside this config will be gloablly accessible from any other component. MixinsMixins in SCSS are not really different from what you know from LESS, except that they provide some added functionality in SCSS. For this refactor I added a bunch of useful mixins. I will explain the important ones as the simple helper mixins like border-style/**
Assign a border style to a component selector.
@param integer
@default 1
*/
@mixin border-style($style: 1) {
@if $style==1 {
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius: 15px 255px;
}
@if $style==2 {
border-top-left-radius: 125px 25px;
border-top-right-radius: 10px 205px;
border-bottom-right-radius: 20px 205px;
border-bottom-left-radius: 185px 25px;
}
@if $style==3 {
border-top-left-radius: 15px 225px;
border-top-right-radius: 255px 15px;
border-bottom-left-radius: 225px 15px;
border-bottom-right-radius: 15px 255px;
}
@if $style==4 {
border-top-left-radius: 15px 225px;
border-top-right-radius: 25px 150px;
border-bottom-left-radius: 25px 115px;
border-bottom-right-radius: 155px 25px;
}
@if $style==5 {
border-top-left-radius: 250px 15px;
border-top-right-radius: 25px 80px;
border-bottom-left-radius: 20px 115px;
border-bottom-right-radius: 15px 105px;
}
@if $style==6 {
border-top-left-radius: 28px 125px;
border-top-right-radius: 100px 30px;
border-bottom-right-radius: 20px 205px;
border-bottom-left-radius: 15px 225px;
}
} This mixin is used for the different border styles. It helps us to set the border-style of a component on the fly. Input: button,
.paper-btn,
[type="button"] {
@include border-style();
} Output: button,
.paper-btn,
[type="button"] {
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius: 15px 255px;
} The default value is set to 1. You can include this mixin with any number from 1-6 or add a new border-style to the project. This will also ensure that border-styles will always stay consistent throughout the project. If you change any of the border-radius inside this mixin it will reflect for every import its used. I mainly used this for utilities/_borders.scss. resp// Responsive breakpoints
$large-screen: 1200px !default;
$medium-screen: 992px !default;
$small-screen: 768px !default;
$xsmall-screen: 480px !default;
/**
Mixin for setting responsive breakpoints
@param string | integer
@default null
*/
@mixin resp($max:null, $min:null) {
@if $max == large or $max == lg { $max: $large-screen; }
@if $max == medium or $max == md { $max: $medium-screen; }
@if $max == small or $max == sm { $max: $small-screen; }
@if $max == xsmall or $max == xs { $max: $xsmall-screen; }
@if ($min != null and $max != null) {@media only screen and (max-width: $max) and (min-width: $min) { @content; }}
@else if($max != null and $min == null){@media only screen and (max-width: $max) { @content; }}
@else if($min != null and $max == null){@media only screen and (min-width: $min) { @content; }}
@else { @error "no matching size found";}
} Who likes to write those tedious The usage is pretty straight forward: Input: .parent {
width: 50%;
@include resp(md) {
width: 25%;
}
.custom-breakpoint {
@include resp(666px) {
width: 66%;
}
}
} Output: .parent {
width: 50%;
}
@media only screen and (max-width: 992px) {
.parent {
width: 25%;
}
}
@media only screen and (max-width: 666px) {
.parent .custom-breakpoint {
width: 66%;
}
} I already used this mixin to set every responsive breakpoint we need. Another cool side effect that comes with this is that you could change the values of the screen-size variables and it will automagically reflect for the whole project. Your sm breakpoint is not at 768px but 800px? Change the shadow/**
Set the shadow type for a component
@param string
@default regular
*/
@mixin shadow($type: regular) {
@if $type == hover {
box-shadow: $shadow-hover;
@include translate(0, 2px);
} @else if $type == small {
transition: all .5s ease;
box-shadow: $shadow-small;
} @else if $type == regular {
transition: all .5s ease;
box-shadow: $shadow-regular;
} @else if $type == large {
transition: all .5s ease;
box-shadow: $shadow-large;
} @else {
@error "@mixin shadow(input) does not exist"
}
} This is pretty much the same as Input: .shadow {
@include shadow();
&.shadow-large {
@include shadow(large);
}
&.shadow-small {
@include shadow(small);
}
&.shadow-hover {
&:hover {
@include shadow(hover);
}
}
} Output: .shadow {
transition: all .5s ease;
box-shadow: 15px 28px 25px -18px rgba(0, 0, 0, 0.2);
}
.shadow.shadow-large {
transition: all .5s ease;
box-shadow: 20px 38px 34px -26px rgba(0, 0, 0, 0.2);
}
.shadow.shadow-small {
transition: all .5s ease;
box-shadow: 10px 19px 17px -13px rgba(0, 0, 0, 0.2);
}
.shadow.shadow-hover:hover {
box-shadow: 2px 8px 8px -5px rgba(0, 0, 0, 0.3);
-webkit-transform: translate(0, 2px);
-ms-transform: translate(0, 2px);
transform: translate(0, 2px);
} ThemesAs mentioned earlier the new approach of this refactor does enable us to do some pretty neat shit. When I saw #112 I immediately thought why not do modular themes? My idea for this looks something like this:
To test this idea I created new light-theme branch and added the changes: Thats all the code it takes to change the appearance of every component and it took me about 5 minutes to create this. Preparations for 1.4.0I already prepared a few things for a 1.4.0 release:
Maybe someone could check the README.md and add a new section with more informations about the scss refactor and the new possibilities (like themes)? So whats left to do now? Also: @afzalsayed96 the accordion component should be refactored to SCSS so we don't lose a component on the way. I can do this later today or you could do it yourself to get familiar with the new scss approach. Any questions left? Ask away, I'm happy to help. 🎉 🎉 👍 |
My jaw is on the floor @koester! Amazing work, and your write up about the changes is pure gold! I'll spend some time today (now that the holidays are over) going through more of the details, but I think this is just about ready to go! Once merged into master, I think it would be really interesting if you published a write up on Medium or a blog on how you tackled the refactor from LESS to SCSS. I'd definitely read it, and it might be something worth submitting to freeCodeCamp to publish :) |
I am seeing no issues with merging this with develop, could you please update the base branch? Since this is the only branch with the port, it doesn't make sense to merge it into papercss:scss-conversion and then develop. Thank you for all of your hard work on this! The workflow for getting it into master will be
|
And she is merged into develop! I went ahead and got the accordion bits converted as well :) |
Brief description 🎉
resolves #33
SCSS Port of PaperCSS
Developer Certificate of Origin
Further details
see #122 (comment)
🎉 🎉 🎉