Giter Site home page Giter Site logo

scssphp's Introduction

This repo has been archived


scssphp

License

scssphp is a compiler for SCSS written in PHP.

Running Tests

scssphp uses PHPUnit for testing.

Run the following command from the root directory to run every test:

vendor/bin/phpunit tests

There are several tests in the tests/ directory:

  • ApiTest.php contains various unit tests that test the PHP interface.
  • ExceptionTest.php contains unit tests that test for exceptions thrown by the parser and compiler.
  • FailingTest.php contains tests reported in Github issues that demonstrate compatibility bugs.
  • InputTest.php compiles every .scss file in the tests/inputs directory then compares to the respective .css file in the tests/outputs directory.
  • ScssTest.php extracts (ruby) scss tests from the tests/scss_test.rb file.
  • ServerTest.php contains functional tests for the Server class.

When changing any of the tests in tests/inputs, the tests will most likely fail because the output has changed. Once you verify that the output is correct you can run the following command to rebuild all the tests:

BUILD=1 vendor/bin/phpunit tests

This will compile all the tests, and save results into tests/outputs.

To enable the scss compatibility tests:

TEST_SCSS_COMPAT=1 vendor/bin/phpunit tests

Coding Standard

scssphp source conforms to PSR2.

Run the following command from the root directory to check the code for "sniffs".

vendor/bin/phpcs --standard=PSR2 bin src tests

scssphp's People

Contributors

aaukt avatar brainfoolong avatar caiosm1005 avatar cerdic avatar clue avatar cyberalien avatar darkain avatar designerno1 avatar dleffler avatar edwinveldhuizen avatar guilhermeblanco avatar gwillings avatar hason avatar icereaper avatar jamesshannon avatar leafo avatar lucvn avatar micranet avatar nextend avatar noxifoxi avatar okj579 avatar oyejorge avatar robocoder avatar s7eph4n avatar sergeylukin avatar siwinski avatar teiling88 avatar timelsass avatar vladimmi avatar zimzat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scssphp's Issues

Exception: unknow op ==

I'm passing Foundations' SCSS through the parser and getting the message:

color: unknow op ==: failed at `}` /Library/WebServer/WebSites/c56-latest/web/packages/lerteco_foundation/themes/lerteco_foundation/vendor/foundation/foundation/components/_panels.scss on line 42

The offending line is:

@if $bg-lightness >= 50% and $bg == blue { h1,h2,h3,h4,h5,h6,p { color: $panel-font-color-alt; } }

There are several other lines (in _forms.scss) that cause the same error.

I haven't been able to get my head around the code, yet, but it seems like it's trying to evaluate the second half of the if() as an operation.

I tried to wrap both comparisons in parens, but no luck. I changed the "and" to an &&, and it seems to work... I'm not sure about the proper output, but at least no errors.

I note that "and" is listed as an operator, but && is not.

Phamlp and Compass ?

Few questions, I'll put them into separate issues if any of them justify it.
I currently use phamlp (my fork with only some bug fixes, nothing major - https://github.com/tsi/phamlp ), I'd like to know if the two projects share code or this is a complete rewrite of sass into php ?
Second, compass is a must for me, how hard would it be to integrate the phamlp version of compass (under /extension in my fork) into scssphp ?
Last,

It implements the latest version of SCSS (3.1.20).

Sass is currently currently on 3.2.1, is this a typo ? 3.2 featured some new features that are quite important for me so this is quite critical.

Thanks!

mixins with @content parse error (sass 3.2.0 feature)

The latest version of Zurb Foundation (3.2) uses mixins with @content, which is a new feature in Sass 3.2.0. This causes scssphp to fail to compile Foundation with the error: parse error: failed at @content; }`

Are there plans to implement sass 3.2.x features into scssphp? It'd be really nice to be able to use it with Foundation.

Multiple params for mixins

scss:

.some-class {
    @include box-shadow(inset 0 4px 6px -5px #bbb, 0 4px 6px -5px #595959);
}

expected css:

.some-class {
    -webkit-box-shadow: inset 0 4px 6px -5px #bbb, 0 4px 6px -5px #595959;
    -moz-box-shadow: inset 0 4px 6px -5px #bbb, 0 4px 6px -5px #595959;
    box-shadow: inset 0 4px 6px -5px #bbb, 0 4px 6px -5px #595959;
}

actual css:

.some-class {
    -webkit-box-shadow: inset 0 4px 6px -5px #bbb;
    -moz-box-shadow: inset 0 4px 6px -5px #bbb;
    box-shadow: inset 0 4px 6px -5px #bbb;
}

Add test against ruby implementation

Chris Eppstein wrote:

... ports scare me. I need to make a way of testing them against the ruby implementation.

Are there tests that compare scssphp directly against the ruby implementation? Also, would there be value in having an open-ended test available online, similar to what phpsass has?

Leaf and the team, this is an excellent project. Thank you.

@extend working unexpected

#content {

        .social-login {
            display: block;
            float: right;
            margin-right: 15px;
            width: 250px;

                .facebook {
                    display: block;
                    width: 255px;
                    height: 42px;
                    background: transparent url('images/login-btns.png') no-repeat;
                    background-position: 0 0;

                    &:hover {
                        background-position: 0 -43px;
                        }

                    &:focus, &:active {
                        background-position: 0 -86px;
                        }
                }

                .twitter {

                    @extend .facebook;
                    background-position: 0 -129px;

                    &:hover {
                        background-position: 0 -172px;
                    }

                    &:active, &:focus {
                        background-position: 0 -215px;
                    }
                }

        }
}

Compiles to:

#content .social-login .facebook,#content .social-login .social-login .twitter,#content .social-login .social-login .twitter {
display:block;
width:255px;
height:42px;
background:transparent url(images/login-btns.png) no-repeat;
background-position:0 0;
}

Expected :

#content .social-login .facebook, #content .social-login .twitter, #content .social-login .google {
  display: block;
  width: 255px;
  height: 42px;
  background: transparent url("images/login-btns.png") no-repeat;
  background-position: 0 0;
}

I'm not sure I've taken the correct path to do this though, but this is defo bug cause in Ruby it compiles as above.

^^

Variables in alpha-filter not replaced

We use the following mixin:

//
// Opacity
// Make the Bootstrap version of the opacity mixin more consistent with the
// original CSS property, which is defined in values from 0 to 1
@mixin opacity($opacity) {
  // If the given opacity is smaller than 1, it is used directly, otherwise
  // the value will be devided by 100
  @if ($opacity < 1) {
    opacity: $opacity;
    filter: alpha(opacity=$opacity * 100);
  } @else {
    opacity: $opacity / 100;
    filter: alpha(opacity=$opacity);
  }
}

Unfortunately the opacity variable in filter: alpha(opacity=$opacity); will not get replaced.

Function's return value type cannot be specified

// I made a greyscale function to return a greyscale color:
@function g($c){
    @return #{"#"}#{$c}#{$c}#{$c};
}

// And a mixin to create the sharp color effect from photoshop
@mixin sharp-color($color, $alpha : .5){
    color : $color;
    text-shadow : 0 0 1px rgba($color, $alpha);
}

// But if I try to use them, like below:
h3{
    @include sharp-color(g(89));
}

// The output will be:
h3 {
  color : #898989;
  text-shadow : 0 0 1px rgba(0, 1, 0, );
}

// But if I supply #898989 for the mixin parameter, it works fine:
h3 {
  color : #898989;
  text-shadow : 0 0 1px rgba(137, 137, 137, .5);
}

// Even if I give the function to a variable, it will still produce the same error:
h3{
  $c : g(89);
  @include sharp-color($c);
}

I guess the problem is, that the parameter doesn't recognize, that the returned value of the g function is a "color" type, because it is a string.

By the way: I've tried @return rgb( $c, $c, $c ), but it doesn't work with hexadecimal colors.

So what I would like to see is some type forcing method for @return values.

Variables in media queries not replaced

We are using a SASS version of Twitter Bootstrap (https://github.com/jlong/sass-twitter-bootstrap/).

The library contains the following snippet of code

@media (max-width: $navbarCollapseWidth) {

  // UNFIX THE TOPBAR
  // ----------------
  // Remove any padding from the body
  body {
    padding-top: 0;
  }
  // Unfix the navbars
  .navbar-fixed-top,
  .navbar-fixed-bottom {
    position: static;
  }
...

outputs:

@media (max-width: $navbarCollapseWidth) {
  body {
    padding-top: 0; }

  .navbar-fixed-top, .navbar-fixed-bottom {
    position: static; }
...

expected (let's say $navbarCollapseWidth is set to 940px):

@media (max-width: 940px) {
  body {
    padding-top: 0; }

  .navbar-fixed-top, .navbar-fixed-bottom {
    position: static; }
...

Recursive mixins not detected

Causes scssphp to exhaust memory and die. ruby sass ignores it.

Example:

.foo {
    .bar {
        @extend .bar;
        text-indent: 5px;
    }
}

Compiles down to:

.foo {
    .bar {
        text-indent: 5px;
    }
}

if [null] evaluates true

Another one I found from going through Foundation 4. Probably related to #33 .

Basically, it seems that setting a variable to null (in this case via mixin arguments) will evaluate to true if that variable is evaluated.

Notice that, in the following code, $collapse is checked a few times. In the code that calls it (below) it's been set to null. It should fail the first evaluation (approx line 4) which it does, but it should also fail the later evaluation (approx lines 15, 18), which it doesn't. Also note that if I change the calling code to false, then it behaves as expected, with the first evaluation passing, and the latter two not.

Accoding to the SCSS page:
The @if directive takes a SassScript expression and uses the styles nested beneath it if the expression returns anything other than false or null:

@mixin grid-column($columns:false, $last-column:false, $center:false, $offset:false, $push:false, $pull:false, $collapse:false, $float:left) {

    // Gutter padding whenever a column isn't set to collapse
  @if $collapse == false {
    padding-left: $column-gutter / 2;
    padding-right: $column-gutter / 2;
  }

  // If a column number is given, calculate width
  @if $columns {
    width: gridCalc($columns, $total-columns);

    // If last column, float naturally instead of to the right
    @if $last-column { float: $default-opposite; }

    // if collapsed, get rid of gutter padding
    @else if $collapse { padding-left: 0; padding-right: 0; }

  }

  @if $collapse { padding-left: 0; padding-right: 0; }
}

Calling it with @include grid-column($columns:$i,$collapse:null,$float:false);

produces something like:

.row .large-1 {
    width: 8.33333%;
    padding-left: 0;
    padding-right: 0;
    padding-left: 0;
    padding-right: 0;
    /* Grid HTML Classes */
  }

subject selector support

This:

header %component {
  margin-bottom: 0;
}
%component! ol {
  padding-left: 20px;
}

section! .widget { @extend %component; }

should compile to:

header section! .widget {
  margin-bottom: 0; }

section! .widget ol,
section! ol .widget {
  padding-left: 20px; }

(Note: it doesn't currently work with sass 3.2 due to sass/sass#481)

nested strings not unquoted

When compiling Foundation, we ran into a problem with their media query variables (example below). They use nested double quoted-strings to define $small. I don't see a need for the quotes around the interpolated $small-screen variable, but scssphp doesn't unquote the string, leading to a bad media directive in the final css.

Example:

$small-screen: 48em !default;
$small: "only screen and (min-width:"#{$small-screen}")" !default;

@media #{$small} {
    div {
        display: none; } }

scssphp compiles to bad media directive:

@media "only screen and (min-width:"48em")" {
  div {
    display: none; } }

We expect

@media only screen and (min-width:48em) {

Thanks for your work!

Expression evaluation

$form-spacing: 1em;

.row { margin: 0 -$form-spacing / 2; }

ruby scss:

.row {
  margin: -0.5em; } 

scssphp:

.row {
  margin: 0 -1em / 2; }

Adding line numbers of original scss files to compiled css files for debugging

A great feature of CodeKit is that it puts line numbers of the scss-source files to the compiled css for debugging purposes.

Example:

/* line 1, ../scss/_reset.scss */
* {
  vertical-align: baseline;
  font-weight: inherit;
  font-family: inherit;
  font-style: inherit;
  font-size: 100%;
  border: 0 none;
  outline: 0;
  padding: 0;
  margin: 0; }

This makes finding the correct source from the css file a lot easier. Is there any way to add these line numbers to the generated css files?

Wrong media queries

Expected result for

@mixin color {
    color: red;
    .success {
         color: green;
    }
}

div {
    position: absolute;
    $y: 2em;
    @media screen {
        top: 0;
        $x: 5px;
        p {
            margin: $x;
        }
        bottom: 6em + $y;
        @include color;
    }
}

is

div {
  position: absolute; }
  @media screen {
    div {
      top: 0;
      bottom: 8em;
      color: red; }
      div p {
        margin: 5px; }
      div .success {
        color: green; } }

Current wrong result is

div {
  position: absolute; }
  @media screen {
    top: 0;
    bottom: 8em;
    color: red;
  div p {
    margin: 5px; }
  div .success {
    color: green; } }

Variable arguments not working

According to the documentation, the syntax

element {
 @mixin mixin($args...) {
  property: $args;
 }
}

Should compile to:

element {
 property: arg1 arg2 arg3;
}

However, no css appears in the output at all, but the source scss does.

Is there a reason for the "get" method to be protected?

I wanted to create a registered function which will evaluate variable names into values and the only difficulty I came across was adding a public "getVariable" method which basically get proxies the original "get" method.

Could you make this method or a proxy for this method public in future releases?
Is there any reason why not to do so?
Thanks in advance for your reply.

ifTruthy() commit breaks things

Hi All..

I just swapped in the most recent commit and started getting an error. I've tracked it down to 318b54 . If I replace the code with the previous commit, everything works fine.

This is being run on Foundation, and I'm getting the below error.

I'm not sure how to track this down to the line of scss that's causing it, but I can work through it if you have suggestions / need more info.

Fatal error: Maximum function nesting level of '100' reached, aborting! in /Users/jshannon/Documents/Work/Projects/C5 Theme/Repo/packages/lerteco_foundation/libraries/vendor/scss.inc.php on line 1355
Call Stack
#   Time    Memory  Function    Location
1   0.0007  633320  {main}( )   ../index.php:0
2   0.0012  736560  require( '/Library/WebServer/WebSites/concrete5source/c5602/concrete/dispatcher.php' )  ../index.php:2
3   0.0937  17577048    require( '/Library/WebServer/WebSites/concrete5source/c5602/concrete/startup/tools.php' )   ../dispatcher.php:122
4   0.0939  17608736    include( '/Library/WebServer/WebSites/concrete5source/c5602/concrete/tools/css.php' )   ../tools.php:29
5   0.0961  17745464    LertecoFoundationPageTheme->parseStyleSheet( )  ../css.php:25
6   0.0967  17755944    scssc->compile( )   ../foundation_page_theme.php:63
7   0.4282  19200664    scssc->compileRoot( )   ../scss.inc.php:87
8   0.4283  19202968    scssc->compileChildren( )   ../scss.inc.php:280
9   0.5380  19767896    scssc->compileChild( )  ../scss.inc.php:443
10  0.5380  19768784    scssc->compileImport( ) ../scss.inc.php:516
11  0.5382  19768984    scssc->importFile( )    ../scss.inc.php:485
12  0.5568  19819864    scssc->compileChildren( )   ../scss.inc.php:1450
13  0.6718  20240832    scssc->compileChild( )  ../scss.inc.php:443
14  0.6721  20275968    scssc->compileImport( ) ../scss.inc.php:516
15  3.7668  33399496    scssc->compileImport( ) ../scss.inc.php:498
16  3.7670  33399720    scssc->importFile( )    ../scss.inc.php:485
17  3.9667  34184488    scssc->compileChildren( )   ../scss.inc.php:1450
18  3.9688  34197064    scssc->compileChild( )  ../scss.inc.php:443
19  3.9688  34197064    scssc->compileChildren( )   ../scss.inc.php:580
20  3.9688  34197368    scssc->compileChild( )  ../scss.inc.php:443
21  3.9688  34197368    scssc->compileMedia( )  ../scss.inc.php:529
22  3.9689  34200152    scssc->compileChildren( )   ../scss.inc.php:314
23  3.9689  34200544    scssc->compileChild( )  ../scss.inc.php:443
24  3.9689  34200544    scssc->compileBlock( )  ../scss.inc.php:532
25  3.9690  34204728    scssc->compileChildren( )   ../scss.inc.php:351
26  3.9690  34205472    scssc->compileChild( )  ../scss.inc.php:443
27  3.9788  34282312    scssc->compileChild( )  ../scss.inc.php:674
28  3.9862  34301480    scssc->compileChild( )  ../scss.inc.php:674
29  3.9863  34301480    scssc->compileChildren( )   ../scss.inc.php:586
30  3.9865  34301920    scssc->compileChild( )  ../scss.inc.php:443
31  3.9865  34301920    scssc->compileBlock( )  ../scss.inc.php:532
32  3.9866  34308280    scssc->compileChildren( )   ../scss.inc.php:351
33  3.9866  34308584    scssc->compileChild( )  ../scss.inc.php:443
34  3.9868  34311088    scssc->compileChild( )  ../scss.inc.php:674
35  3.9868  34311136    scssc->reduce( )    ../scss.inc.php:579
36  3.9868  34311136    scssc->reduce( )    ../scss.inc.php:852
37  3.9868  34313104    scssc->reduce( )    ../scss.inc.php:861
38  3.9868  34313152    scssc->reduce( )    ../scss.inc.php:852
39  3.9868  34315120    scssc->reduce( )    ../scss.inc.php:861
40  3.9868  34315168    scssc->reduce( )    ../scss.inc.php:852
and another 60 of these...

Release 0.0.7

I'm just opening this issue to remind us to tag a new version regularly after adding fixes. Composer will pick up the tag, but I'll also need to update the website. Feel free to tag a new version and I can update the website.

404 Not Found for Stylesheets

Anytime I point the browser to a stylesheet, nginx gives me a 404 not found where I was expecting a "/* INPUT NOT FOUND scss v0.0.1 */". However, I do get the input not found when I am pointing the browser to just /styles.php.

I have attached an image so you could see and here is my code. I am new to PHP so I think it might be a problem on my end, but I dont know where to start.

404

404 normal

SCSS Compass Transition problem

My transition SCSS is from Compass :) The rest from scssphp-compass.

SCSS

div { @include transition(transform 0.3s ease); }

Output

div {
  -webkit-transition : -0.3s, 0.3s, ease;
  -moz-transition : -0.3s, 0.3s, ease;
  -o-transition : -0.3s, 0.3s, ease;
  transition : transform 0.3s ease; }

Excpected (from http://sass-lang.com/try.html )

div {
  -webkit-transition: -webkit-transform 0.3s ease;
  -moz-transition: -moz-transform 0.3s ease;
  -o-transition: -o-transform 0.3s ease;
  transition: transform 0.3s ease; }

All SCSS during parse. Too verbose I know but should help to narrow it down.

// Usually compass hacks apply to both ie6 & 7 -- set this to false to disable support for both.
$legacy-support-for-ie: true !default;

// Setting this to false will result in smaller output, but no support for ie6 hacks
$legacy-support-for-ie6: $legacy-support-for-ie !default;

// Setting this to false will result in smaller output, but no support for ie7 hacks
$legacy-support-for-ie7: $legacy-support-for-ie !default;

// Setting this to false will result in smaller output, but no support for legacy ie8 hacks
$legacy-support-for-ie8: $legacy-support-for-ie !default;

// @private
// The user can simply set $legacy-support-for-ie and 6, 7, and 8 will be set accordingly,
// But in case the user set each of those explicitly, we need to sync the value of
// this combined variable.
$legacy-support-for-ie: $legacy-support-for-ie6 or $legacy-support-for-ie7 or $legacy-support-for-ie8;

// Whether to output legacy support for mozilla.
// Usually this means hacks to support Firefox 3.6 or earlier.
$legacy-support-for-mozilla: true;

// Support for mozilla in experimental css3 properties (-moz).
$experimental-support-for-mozilla      : true !default;
// Support for webkit in experimental css3 properties (-webkit).
$experimental-support-for-webkit       : true !default;
// Support for webkit's original (non-standard) gradient syntax.
$support-for-original-webkit-gradients : true !default;
// Support for opera in experimental css3 properties (-o).
$experimental-support-for-opera        : true !default;
// Support for microsoft in experimental css3 properties (-ms).
$experimental-support-for-microsoft    : true !default;
// Support for khtml in experimental css3 properties (-khtml).
$experimental-support-for-khtml        : false !default;
// Support for svg in experimental css3 properties.
// Setting this to true might add significant size to your
// generated stylesheets.
$experimental-support-for-svg          : false !default;
// Support for CSS PIE in experimental css3 properties (-pie).
$experimental-support-for-pie          : false !default;

// This mixin provides basic support for CSS3 properties and
// their corresponding experimental CSS2 properties when
// the implementations are identical except for the property
// prefix.
@mixin experimental($property, $value,
  $moz      : $experimental-support-for-mozilla,
  $webkit   : $experimental-support-for-webkit,
  $o        : $experimental-support-for-opera,
  $ms       : $experimental-support-for-microsoft,
  $khtml    : $experimental-support-for-khtml,
  $official : true
) {
  @if $webkit  and $experimental-support-for-webkit    { -webkit-#{$property} : $value; }
  @if $khtml   and $experimental-support-for-khtml     {  -khtml-#{$property} : $value; }
  @if $moz     and $experimental-support-for-mozilla   {    -moz-#{$property} : $value; }
  @if $ms      and $experimental-support-for-microsoft {     -ms-#{$property} : $value; }
  @if $o       and $experimental-support-for-opera     {      -o-#{$property} : $value; }
  @if $official                                        {         #{$property} : $value; }
}

// Same as experimental(), but for cases when the property is the same and the value is vendorized
@mixin experimental-value($property, $value,
  $moz      : $experimental-support-for-mozilla,
  $webkit   : $experimental-support-for-webkit,
  $o        : $experimental-support-for-opera,
  $ms       : $experimental-support-for-microsoft,
  $khtml    : $experimental-support-for-khtml,
  $official : true
) {
  @if $webkit  and $experimental-support-for-webkit    { #{$property} : -webkit-#{$value}; }
  @if $khtml   and $experimental-support-for-khtml     { #{$property} :  -khtml-#{$value}; }
  @if $moz     and $experimental-support-for-mozilla   { #{$property} :    -moz-#{$value}; }
  @if $ms      and $experimental-support-for-microsoft { #{$property} :     -ms-#{$value}; }
  @if $o       and $experimental-support-for-opera     { #{$property} :      -o-#{$value}; }
  @if $official                                        { #{$property} :         #{$value}; }
}

// CSS Transitions
// Currently only works in Webkit.
//
// * expected in CSS3, FireFox 3.6/7 and Opera Presto 2.3
// * We'll be prepared.
//
// Including this submodule sets following defaults for the mixins:
//
//     $default-transition-property : all
//     $default-transition-duration : 1s
//     $default-transition-function : false
//     $default-transition-delay    : false
//
// Override them if you like. Timing-function and delay are set to false for browser defaults (ease, 0s).

$default-transition-property: all !default;

$default-transition-duration: 1s !default;

$default-transition-function: false !default;

$default-transition-delay: false !default;

$transitionable-prefixed-values: transform, transform-origin !default;

// One or more properties to transition
//
// * for multiple, use a comma-delimited list
// * also accepts "all" or "none"

@mixin transition-property($property-1: $default-transition-property,
  $property-2 : false,
  $property-3 : false,
  $property-4 : false,
  $property-5 : false,
  $property-6 : false,
  $property-7 : false,
  $property-8 : false,
  $property-9 : false,
  $property-10: false
) {
  @if type-of($property-1) == string { $property-1: unquote($property-1); }
  $properties: compact($property-1, $property-2, $property-3, $property-4, $property-5, $property-6, $property-7, $property-8, $property-9, $property-10);
  @if $experimental-support-for-webkit    {       -webkit-transition-property : prefixed-for-transition(-webkit, $properties); }
  @if $experimental-support-for-mozilla   {          -moz-transition-property : prefixed-for-transition(-moz,    $properties); }
  @if $experimental-support-for-opera     {            -o-transition-property : prefixed-for-transition(-o,      $properties); }
                                                          transition-property : $properties;
}

// One or more durations in seconds
//
// * for multiple, use a comma-delimited list
// * these durations will affect the properties in the same list position

@mixin transition-duration($duration-1: $default-transition-duration,
  $duration-2 : false,
  $duration-3 : false,
  $duration-4 : false,
  $duration-5 : false,
  $duration-6 : false,
  $duration-7 : false,
  $duration-8 : false,
  $duration-9 : false,
  $duration-10: false
) {
  @if type-of($duration-1) == string { $duration-1: unquote($duration-1); }
  $durations: compact($duration-1, $duration-2, $duration-3, $duration-4, $duration-5, $duration-6, $duration-7, $duration-8, $duration-9, $duration-10);
  @include experimental(transition-duration, $durations,
    -moz, -webkit, -o, not -ms, not -khtml, official
  );
}

// One or more timing functions
//
// * [ ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier(x1, y1, x2, y2)]
// * For multiple, use a comma-delimited list
// * These functions will effect the properties in the same list position

@mixin transition-timing-function($function-1: $default-transition-function,
  $function-2 : false,
  $function-3 : false,
  $function-4 : false,
  $function-5 : false,
  $function-6 : false,
  $function-7 : false,
  $function-8 : false,
  $function-9 : false,
  $function-10: false
) {
  $function-1: unquote($function-1);
  $functions: compact($function-1, $function-2, $function-3, $function-4, $function-5, $function-6, $function-7, $function-8, $function-9, $function-10);
  @include experimental(transition-timing-function, $functions,
    -moz, -webkit, -o, not -ms, not -khtml, official
  );
}

// One or more transition-delays in seconds
//
// * for multiple, use a comma-delimited list
// * these delays will effect the properties in the same list position

@mixin transition-delay($delay-1: $default-transition-delay,
  $delay-2 : false,
  $delay-3 : false,
  $delay-4 : false,
  $delay-5 : false,
  $delay-6 : false,
  $delay-7 : false,
  $delay-8 : false,
  $delay-9 : false,
  $delay-10: false
) {
  @if type-of($delay-1) == string { $delay-1: unquote($delay-1); }
  $delays: compact($delay-1, $delay-2, $delay-3, $delay-4, $delay-5, $delay-6, $delay-7, $delay-8, $delay-9, $delay-10);
  @include experimental(transition-delay, $delays,
    -moz, -webkit, -o, not -ms, not -khtml, official
  );
}

// Transition all-in-one shorthand

@mixin single-transition(
  $property: $default-transition-property,
  $duration: $default-transition-duration,
  $function: $default-transition-function,
  $delay: $default-transition-delay
) {
  @include transition(compact($property $duration $function $delay));
}

@mixin transition(
  $transition-1 : default,
  $transition-2 : false,
  $transition-3 : false,
  $transition-4 : false,
  $transition-5 : false,
  $transition-6 : false,
  $transition-7 : false,
  $transition-8 : false,
  $transition-9 : false,
  $transition-10: false
) {
  @if $transition-1 == default {
    $transition-1 : compact($default-transition-property $default-transition-duration $default-transition-function $default-transition-delay);
  }
  $transitions: false;
  @if type-of($transition-1) == list and type-of(nth($transition-1,1)) == list {
    $transitions: join($transition-1, compact($transition-2, $transition-3, $transition-4, $transition-5, $transition-6, $transition-7, $transition-8, $transition-9, $transition-10), comma);
  } @else {
    $transitions : compact($transition-1, $transition-2, $transition-3, $transition-4, $transition-5, $transition-6, $transition-7, $transition-8, $transition-9, $transition-10);
  }
  $delays: comma-list();
  $has-delays: false;
  $webkit-value: comma-list();
  $moz-value: comma-list();
  $o-value: comma-list();

  // This block can be made considerably simpler at the point in time that
  // we no longer need to deal with the differences in how delays are treated.
  @each $transition in $transitions {
    // Extract the values from the list
    // (this would be cleaner if nth took a 3rd argument to provide a default value).
    $property: nth($transition, 1);
    $duration: false;
    $timing-function: false;
    $delay: false;
    @if length($transition) > 1 { $duration:        nth($transition, 2); }
    @if length($transition) > 2 { $timing-function: nth($transition, 3); }
    @if length($transition) > 3 { $delay:           nth($transition, 4); $has-delays: true; }

    // If a delay is provided without a timing function
    @if is-time($timing-function) and not $delay { $delay: $timing-function; $timing-function: false; $has-delays: true; }

    // Keep a list of delays in case one is specified
    $delays: append($delays, if($delay, $delay, 0s));

    $webkit-value: append($webkit-value, compact(prefixed-for-transition(-webkit, $property) $duration $timing-function));
       $moz-value: append(   $moz-value, compact(prefixed-for-transition(   -moz, $property) $duration $timing-function $delay));
         $o-value: append(     $o-value, compact(prefixed-for-transition(     -o, $property) $duration $timing-function $delay));
  }

  @if $experimental-support-for-webkit    {       -webkit-transition : $webkit-value;
    // old webkit doesn't support the delay parameter in the shorthand so we progressively enhance it.
    @if $has-delays                       { -webkit-transition-delay : $delays;       } }
  @if $experimental-support-for-mozilla   {          -moz-transition : $moz-value;    }
  @if $experimental-support-for-opera     {            -o-transition : $o-value;      }
                                                          transition : $transitions;
}

// coerce a list to be comma delimited or make a new, empty comma delimited list.
@function comma-list($list: ()) {
  @return join((), $list, comma);
}

// Returns `$property` with the given prefix if it is found in `$transitionable-prefixed-values`.
@function prefixed-for-transition($prefix, $property) {
  @if type-of($property) == list {
    $new-list: comma-list();
    @each $v in $property {
      $new-list: append($new-list, prefixed-for-transition($prefix, $v));
    }
    @return $new-list;
  } @else {
    @if index($transitionable-prefixed-values, $property) {
      @return #{$prefix}-#{$property};
    } @else {
      @return $property;
    }
  }
}

// Checks if the value given is a unit of time.
@function is-time($value) {
  @if type-of($value) == number {
    @return not not index(s ms, unit($value));
  } @else {
    @return false;
  }
}


div { @include transition(transform 0.3s ease); }

darken() difference

Is it worth investigating?

.row {
background-color: darken(#2ba6cb, 40%);
}

scssphp:

.row {
  background-color: #071d23; }

ruby scss:

.row {
  background-color: #071c23; }

Does it support Compass

I'm a bit lazy to go through the setup and testing, so my question is pretty simple "Does it support Compass?"

Foundation (from Zurb), has the following in their SCSS:

@import "compass/css3";

Will this be an issue for SCSSPHP?

Thank you!

Interpolation failing on :nth-child()

Now, I haven't had the chance to test this fully to see if it this problem is affecting all selectors, however if I do something like:

$scope: 2;

div.element:nth-child(#{$scope}n)
{
    display: none;
}

...it will compile to:

div.element:nth-child(n)
{
    display: none;
}

...and throw out an error, something along the lines of accessing a property of a non-object property. This is the expected outcome, which is what I get if I compile this script with sassifier on Windows:

div.element:nth-child(2n)
{
    display: none;
}

When I get home from work, I'll try to figure out what is causing this and if possible, try to patch it.

Gradient via compass background-image failes

When i do the following:

@include background-image(linear-gradient(#1e5266, #1c7f92));

The generated output is:

  background-image: -owg(linear-gradient(#1e5266, #1c7f92));
  background-image: -webkit(linear-gradient(#1e5266, #1c7f92));
  background-image: -moz(linear-gradient(#1e5266, #1c7f92));
  background-image: -o(linear-gradient(#1e5266, #1c7f92));
  background-image: linear-gradient(#1e5266, #1c7f92);

This does not work in chrome. The outcome should be:

  background-image: -owg-linear-gradient(#1e5266, #1c7f92);
  background-image: -webkit-linear-gradient(#1e5266, #1c7f92);
  background-image: -moz-linear-gradient(#1e5266, #1c7f92);
  background-image: -o-linear-gradient(#1e5266, #1c7f92);
  background-image: linear-gradient(#1e5266, #1c7f92);

This is the mixin in compass:

// Background image property support for vendor prefixing within values.
@mixin background-image(
  $image-1,
  $image-2: false,
  $image-3: false,
  $image-4: false,
  $image-5: false,
  $image-6: false,
  $image-7: false,
  $image-8: false,
  $image-9: false,
  $image-10: false
) {
  $images: compact($image-1, $image-2, $image-3, $image-4, $image-5, $image-6, $image-7, $image-8, $image-9, $image-10);
  $add-pie-bg: prefixed(-pie,   $images) or -compass-list-size($images) > 1;

  @if $experimental-support-for-svg          and prefixed(-svg,    $images) { background-image:    -svg($images); background-size: 100%; }
  @if $support-for-original-webkit-gradients and prefixed(-owg,    $images) { background-image:    -owg($images); }
  @if $experimental-support-for-webkit       and prefixed(-webkit, $images) { background-image: -webkit($images); }
  @if $experimental-support-for-mozilla      and prefixed(-moz,    $images) { background-image:    -moz($images); }
  @if $experimental-support-for-opera        and prefixed(-o,      $images) { background-image:      -o($images); }
  @if $experimental-support-for-pie          and $add-pie-bg                { @warn "PIE does not support background-image. Use @include background(#{$images}) instead." }
                                                                              background-image:         $images ;
}

Not Importing

Hey,

Not sure if this is a problem on my side or yours but I am hooking scssphp into Wordpress as part of a freebie theme release. The scss is compiling but it is not importing files from inside a folder. I need these since I am using the Foundation grid which has all its files in a foundation folder.

Any idea what is going wrong?

Thanks,

Shane

scss_formatter_compressed doesn't strip CSS comments

When you use the scss_formatter_compressed flag, scss comments are stripped (the // type), but regular CSS comments ( /**/ style) are left in the CSS.

From what I understand this is expected SASS behavior. But when you compress the CSS output, shouldn't it be as small as possible?

Passing varargs to another mixin

@mixin wallpaper($image, $top: 0, $right: 0, $bottom: 0, $left: 0) {
  background: $image;
  position: absolute;
  top: $top;
  right: $right;
  bottom: $bottom;
  left: $left;
}

@mixin logo($offsets...) {
  @include wallpaper(url(/images/logo.png), $offsets...);
}

#please-wait {
  @include logo($top: 3em, $bottom: 3em);
}

should produce:

#please-wait {
  background: url(/images/logo.png);
  position: absolute;
  top: 3em;
  right: 0;
  bottom: 3em;
  left: 0; }

scssphp currently throws an exception Mixin or function doesn't have an argument named $top.

'null' not getting interpolated as empty string

In this mixin:

@mixin Rounded($radius1, $direction: null, $radius2: false) {
    $corner: null;
    @if $direction == TL { $corner: top-left-; }
    @if $direction == TR { $corner: top-right-; }
    @if $direction == BL { $corner: bottom-left-; }
    @if $direction == BR { $corner: bottom-right-; }
    @if $radius2 {
        -webkit-border-#{$corner}radius: $radius1 $radius2;
                border-#{$corner}radius: $radius1 $radius2;
    } @else {
        -webkit-border-#{$corner}radius: $radius1;
                border-#{$corner}radius: $radius1;
    }
}

The value of $corner is written as 'null' instead of an empty string, as indicated by the manual:

Null values are treated as empty strings for string interpolation:
$value: null;
p:before {
content: "I ate #{$value} pies!";
}

Self (&) Selector is broken

.main {
    .message {
        .nice-fonts & {
            font-size: 24px;
        }
    }
}

Compiles to:

.main .nice-fonts .message {
  font-size: 24px; }

Expect:

.nice-fonts .main .message {
  font-size: 24px; }

Weird @extend behavior

When I test the compiler with this input, i found that the behavior of @extend is very weird

.nav-bar {
    background: #eee;
    > .item {
        margin: 0 10px;
    }
}


header ul {
    @extend .nav-bar;
    > li {
        @extend .item;
    }
}

It gives out the following output, notice the repeated "header ul >" in the css selector (pay attention on the comma)

.nav-bar, header ul {
  background: #eee; }
  .nav-bar > .item, header ul > .item, header ul > header ul > li, header ul > header ul > li, .nav-bar > header ul > li, header ul > .nav-bar > li {
    margin: 0 10px; }

While I test the same input in the official compiler http://sass-lang.com/try.html, it gives out the correct output

.nav-bar, header ul {
  background: #eee; }
  .nav-bar > .item, header ul > .item, header ul.nav-bar > li, header ul > li {
    margin: 0 10px; }

Should scss_formatter_compressed minimize output or stay compatible?

When looking at ticket #60 I was wondering whether scss_formatter_compressed should result in minimized CSS output or whether it should try to stay compatible and not introduce any additional minimizations.

I have a current compress working branch which (besides being a bit of a mess) introduces some minor additional APIs to minimize numbers, colors, comments, trailing semicolons, useless whitespace, etc.

Before sending in any PRs, I'd like to ask if you're in favor of adding those minimizations to scss_formatter_compressed, or would rather go with a scss_formatter_minimized or rather not have those features land in scssphp at all.

Feel free to take a look at my branch, it's been a while it's been touched, but it's been working fine for the last ~6 months.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.