Search Unity

Sassy CSS

Discussion in 'UI Toolkit' started by Devi-User, Dec 2, 2018.

  1. Devi-User

    Devi-User

    Joined:
    Apr 30, 2016
    Posts:
    61
    Does Unity plan to further develop the format into something like sassy css?
    I know that we can add this format on our own, but maybe it will just waste our time and Unity has such plans?

    Speaking about scss I mean it is the element that is associated with the generation. Import, cycles, variables e t.c.
     
  2. I hope they don't.
     
    AcidArrow likes this.
  3. Devi-User

    Devi-User

    Joined:
    Apr 30, 2016
    Posts:
    61
    why not? uss in its current form is noodles
     
    Stardog likes this.
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    I do wonder, is there anything significant, that scss may bring, over css?
     
  5. Devi-User

    Devi-User

    Joined:
    Apr 30, 2016
    Posts:
    61
    uss is an analogue of css.
    scss is a css in which there are operations to simplify.
    For example, specifying constants and expressions support.
    Code (csharp):
    1. $blue: #3bbfce;
    2. $margin: 16px;
    3.  
    4. .content-navigation {
    5.   border-color: $blue;
    6.   color: darken($blue, 9%);
    7. }
    8.  
    9. .border {
    10.   padding: $margin / 2;
    11.   margin: $margin / 2;
    12.   border-color: $blue;
    13. }
    Import
    Code (csharp):
    1. @import "template";
    selector nesting
    Code (csharp):
    1. #some {
    2.   border: 1px solid red;
    3.   .some { background: white; }
    4. }
    5.  
    and @if, @each e t.c.

    In my opinion this is a good thing, as it makes the style files clearer - they do not contain "magic numbers", at least. And their description is more concise
    It also allows you to split the markup into several files (for example, a common stylesheet and a specific implementation) without specifying each file in C #.

    I am really surprised that the attitude towards scss is so negative. Why?
     
    Last edited: Dec 3, 2018
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    Thx for explanation.

    But don't be surprised.
    Seams like little improvement, for quite a lot of work, on side of Unity.
    I am not saying it is good, or bad.

    Personally, don't seams I would be even using in web dev.
    There was time I needed some variables in CSS. I used JS, or PHP for that purpose, depending on project.

    Other than that, I got impression from reading, that SCSS have not took much of traction.
    Hence I think is a bit pointless, to trying attracting Unity to that subject.

    Don't know to be honest, if it got support in all browsers, but if not, that means testing, or porting existing CSS files templates, may become very tedious.
     
  7. Devi-User

    Devi-User

    Joined:
    Apr 30, 2016
    Posts:
    61
    Code (CSharp):
    1. Seams like little improvement, for quite a lot of work, on side of Unity.
    This is a little untrue. For scss, there are quite a few solutions available on the git hub. The result of scss is the generation of css code anyway.
    Since stylistically these are languages of one family, it is quite possible, there is no difference and no additional work at all.
    The class of styles in Unity actually gets fed to it by uss (as string). Therefore, the work may come down to adding a new importer. That is why I wrote:
    >I know what we can add this format on our own

    Again, because of the ease of implementation - I was going to do it. I just wanted to be sure that this will not duplicate the steps that Unity plans in developing uss.
     
    MechEthan likes this.
  8. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    I am quite skeptical, they do.
    Hence you are pretty free to go with your project.
     
  9. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    There are plans to eventually support proper USS variables but not for 2019.1. For SCSS specifically, no plans to support it directly out of the box. However, the scripted importer will be your friend in this case. You should be able to script your own SCSS->USS pipe if you wish. We actually have an internal team doing something similar for their use of USS.
     
    MechEthan, mdrotar and Antypodish like this.
  10. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    I am Web developer and using always scss. In one of my projects the final css bundle has 17.000 lines (using minimizing and compression in production for reduce the filesize)
     
    Stardog likes this.
  11. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    What kind of combine are you running? :)
    Word press is considered as packed with styles, but it has up to 10k lines of css opened at the time.
     
  12. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    13.000 line are are from customized bootstrap and fontawesome. Bootstrap is written in scss and you can easy customize it with scss and include it in the bundle.
     
  13. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    To me sounds like massive over engineered overkill.
    But that is no my project, so I don't know details. ;)

    Edit:
    I just checked Ebay CSS files loaded at some selected product.
    Fair enough, they got rougly 27k lines uncompressed spread over 4 files, with one file of that with 17k.

    But still CSS.
     
    Last edited: Dec 6, 2018
  14. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    Browers do not unterstand scss, is transpiled to css.
    With scss you can make functions to autogenerate some css parts as example variants of buttons.
    In bootstrap you define the theme colors, and it make all the components based on the colors: buttons, alterts, backgrounds and more.
     
    Devi-User and Antypodish like this.
  15. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    Please try to support nesting too.