ElkArte Community

Elk Development => Feature Discussion => Topic started by: emanuele on July 23, 2015, 05:52:07 am

Title: SASS or LESS may be an option?
Post by: emanuele on July 23, 2015, 05:52:07 am
I was thinking... would the use of SASS (https://en.wikipedia.org/wiki/Sass_%28stylesheet_language%29) or LESS (https://en.wikipedia.org/wiki/LESS_(stylesheet_language)) (One against the other (https://css-tricks.com/sass-vs-less/)) "at some point" be of interest?

The reasoning behind the proposal is that even though CSS are easy (who the heck said that?), we have some 6/8000 lines of them around, so quite difficult to dig into for anyone apart Ant (and likely Bloc).
Have some kind of "aggregation" of things may help simplify the editing of the theme as a whole, for example change color would not be a hide-and-seek game, but just a "chage-this-few-numbers-here". And so on.

In order to have that, though, we'd need a pure php compiler (there are some) bundled with Elk, and also a way to compile the code when needed.

What do you think? O:-)
Title: Re: SASS or LESS may be an option?
Post by: Flavio93Zena on July 23, 2015, 08:17:07 am
For a css freak like me anything related to it is just more powa ;D
Title: Re: SASS or LESS may be an option?
Post by: radu81 on July 23, 2015, 11:51:08 am
I think could be useful for css geeks ;)
I'm not an expert, but I've used with success a joomla template with LESS. It took me some time to understand how it works but in the end the result was good enough for me.
Title: Re: SASS or LESS may be an option?
Post by: wintstar on July 23, 2015, 02:52:26 pm
It could discourage developers to create new Themes. And it could the professionals developer create the Themes for money.



Title: Re: SASS or LESS may be an option?
Post by: Joshua Dickerson on July 23, 2015, 03:22:37 pm
How would it discourage theme creation? If anything, it makes it much easier and faster.
Title: Re: SASS or LESS may be an option?
Post by: Flavio93Zena on July 23, 2015, 03:30:17 pm
Yep, unless you bring it to the extreme, as google "suggests", by stripping every block on a single line, regardless of how many selectors it has ;D
P.S.: welcome wintstar!
Title: Re: SASS or LESS may be an option?
Post by: emanuele on July 23, 2015, 03:56:39 pm
Quote from: wintstar – It could discourage developers to create new Themes.
Yes and maybe no.
Yes, SASS and LESS are complex beasts, more than CSS alone of course, so it may be people get scared and run for their life. xD
Maybe no, 90% of people are just changing colors, and hopefully change colors with SASS and LESS should be much, much easier than with the current CSS (that requires at least to scan the whole variant css just to find which colors are in use). In addition, use something like that, could be transparent to someone creating a theme, because he can start from the expanded css (so plain css) and build on top of that.

But of course I posted because I'm not entirely convinced myself, and I'd like to hear opinions.

Quote from: wintstar – And it could the professionals developer create the Themes for money.
It's not that make money is a bad thing. :P
Title: Re: SASS or LESS may be an option?
Post by: Joshua Dickerson on July 23, 2015, 04:06:28 pm
Like you said, you can always use CSS instead of SASS. Making sure you comment things comes in handy too. Define the variables early. We can even create a theme editor with it.
Title: SPLIT: Paid extensions
Post by: emanuele on July 23, 2015, 06:01:17 pm
The discussion about paid stuff has been moved to General ElkArte discussions (http://www.elkarte.net/community/index.php?board=6.0)

http://www.elkarte.net/community/index.php?topic=2793.0
Title: Re: SASS or LESS may be an option?
Post by: Bloc on July 23, 2015, 08:47:18 pm
SASS/LESS is a tool to help CSS writers, foremost. It would certainly help those that do themes..not so sure about the average admin though. Unless you build an environment that already "works" and use SASS to alter key variables...or something to that nature, I am not that schooled in either SASS/LESS lol.

What i would recommend - if you are looking to make things easier - is to simplify the CSS as currently stands. Or add admin functions that alter key parts of the CSS file instead, sort of SASS for ElkArte. Since it has a great minifying function, it would make sense to have something like it.

Another way is to have the theme provide lots of options for users to tweak - again utilizing the combine/minimize function and caching it after each tweak. Not sure which is preferable lol, I've done some work in theme options so I tend to favor that since I have total freedom - but it does make it ahrder to be consistant across themes, backwards compatible that is. Not to mention its per-theme(although one could make the options be global/default too).

Mind you, its mostly SMF 2.0 things, but ElkArte shares alot of the theme features/code.

Title: Re: SASS or LESS may be an option?
Post by: Ant59 on July 24, 2015, 10:17:45 am
The Xydre theme stylesheets that I wrote a while back is written in SASS, though I never quite fully exploited it's variables to encompass Elkarte-specific stuff since very little from the default theme made it into the Xydre theme.

I think that using SASS in Elkarte is a fantastic idea. We could easily specify and change colour pallettes and go further with standardising stylings across the software.
Title: Re: SASS or LESS may be an option?
Post by: Ice (NegativeIQ) on August 15, 2015, 01:22:40 am
Well im supporting both ideas, LESS and SASS, mainly because it lets you separate logics (if i can call it like that) and use variables. I dont see why it would discourage anyone as long as he/she searches google for a simple tutorial and documentation. And if ElkArte has already build in compiler that will look for changes in files and automatically compile our less/sass styles than i dont see a reason not to use it...If you think it will slow down big forums well maybe in production we could link to a precompiled CSS?

Also if we used less/sass i think we could simply read variables and allow users to edit them in admin panel. That way picking colors, changing font sizes and such would become piece of cake even for people that have no idea about css language...
Title: Re: SASS or LESS may be an option?
Post by: Joshua Dickerson on May 01, 2017, 08:45:00 pm
Any hope of coming back to this? I don't see how SCSS is any harder than CSS. I'd create a "colors.scss" file that would allow admins to change their colors. Just define a bunch of variables in there and use those variables around the SCSS. Then, you can pretty much get rid of this idea of "variants" (I never liked it). You just give someone your "colors file" and they can use any SCSS compiler online if they don't have one locally. You can create a plugin to do this in PHP inside Elk with scssphp!

Most people, and what I'd consider best practice, is to define your colors separate of everything else. Using variables. Then you create a file that defines breakpoints. That defines the breakpoints for your grid. You define how wide those are in another file for those variables. You move page specific rules to their own files. Then... you compile them all together and create a single, massive CSS file. You distribute that unminified file alongside the SCSS dir. If people want to minify the CSS, they can do it on their own.

Develop an ecosystem for developers. Non-developer admins are just going to install plugins and grab someone's "colors" file and call it a day. Developers know and love SCSS.
Title: Re: SASS or LESS may be an option?
Post by: live627 on May 01, 2017, 09:42:37 pm
I fully support this!

Title: Re: SASS or LESS may be an option?
Post by: emanuele on May 02, 2017, 02:45:22 am
JFDI! :P
I think at that point (RC1) we can branch out 1.1 and let development run wild again, there is already quite a bit of stuff that can be done very quickly. O:-)

Quote from: Joshua Dickerson – You just give someone your "colors file" and they can use any SCSS compiler online if they don't have one locally. You can create a plugin to do this in PHP inside Elk with scssphp!
I would provide a way to compile it inside Elk, something like:
http://leafo.net/scssphp/
Title: Re: SASS or LESS may be an option?
Post by: Joshua Dickerson on May 02, 2017, 05:26:26 pm
I think you should do that with a plugin. Node.js has many libraries (gulp, webpack, etc) that handle this for people already. I'd just use webpack and watch the scss dir if I was developing. I wouldn't want to do it manually.
Title: Re: SASS or LESS may be an option?
Post by: emanuele on May 02, 2017, 06:00:49 pm
If you have a VPS you can do the way you want. :)
If you are on a shared, a button "compile" and a php library is likely the only thing that works (somehow) reliably.
Title: Re: SASS or LESS may be an option?
Post by: Frenzie on May 05, 2017, 12:27:09 pm
Quote from: Joshua Dickerson – Any hope of coming back to this? I don't see how SCSS is any harder than CSS. I'd create a "colors.scss" file that would allow admins to change their colors. Just define a bunch of variables in there and use those variables around the SCSS. Then, you can pretty much get rid of this idea of "variants" (I never liked it). You just give someone your "colors file" and they can use any SCSS compiler online if they don't have one locally. You can create a plugin to do this in PHP inside Elk with scssphp!
What exactly is it you don't like about variants? Variants may be largely colors but just colors isn't even remotely the same thing at all. I think the theme variants and custom_blabla.css are quite elegant if there's no need to duplicate a theme completely; especially if the CSS is all you're going to change. However, overrides should preferably already be integrated while generating the minified CSS, as opposed to leaving the extra processing to the browser. And of course something like SCSS allows you to use variables (https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) in a backward-compatible manner.

So if you used colors file as a shorthand for overrides and additions,
[1] never mind. But otherwise I'm fairly sure I've got some kind of objection. :)
Which would mostly consist of various colors, fonts, background images, and units of size, but could also include position, display, float, generated content, etc. All relatively minor things that can still hugely impact the general look and feel of a page.
Title: Re: SASS or LESS may be an option?
Post by: Cody on May 07, 2017, 06:54:50 pm
Mediawiki uses LESS and its parsed when style sheets are combined and such.  Certainly makes minor changes easier...assuming variables are where you need them.
Title: Re: SASS or LESS may be an option?
Post by: Joshua Dickerson on May 08, 2017, 12:34:05 am
@Frenzie most people define their fonts in a file called "fonts" and their colors with the same name. I just used "colors" as an example. The idea of variants is that the structure stays the same and the skin changes, but it is a weird word. Most people use skin in the software industry.
Title: Re: SASS or LESS may be an option?
Post by: Frenzie on May 10, 2017, 05:31:35 am
@Joshua Dickerson But what exactly is it you dislike about the idea of variants? Is it just the name then?