Skip to content

Commit

Permalink
add tests for if/else
Browse files Browse the repository at this point in the history
  • Loading branch information
braver committed Feb 17, 2024
1 parent 79faefd commit 4257e22
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions Tests/syntax_test_scss.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1076,3 +1076,66 @@ $accent: #e1d7d2;
}
}
}

//=============================================================================
// If, else
// https://sass-lang.com/documentation/at-rules/control/if/
//=============================================================================
@mixin avatar($size, $circle: false) {
width: $size;
height: $size;

@if $circle {
//^^^^^^^^^^^ meta.at-rule.scss
//^^^ keyword.control.flow.conditional.scss
//^ punctuation.definition.keyword.scss
// ^^^^^^^ variable.other
border-radius: math.div($size, 2);
}
}

// https://sass-lang.com/documentation/at-rules/control/if/#else
@mixin theme-colors($light-theme: true) {
@if $light-theme {
//^^^^^^^^^^^ meta.at-rule.scss
//^^^ keyword.control.flow.conditional.scss
//^ punctuation.definition.keyword.scss
// ^^^^^^^ variable.other

background-color: $light-background;
color: $light-text;
} @else {
// ^^^^^^ meta.at-rule.scss
// ^^^^^ keyword.control.flow.conditional.scss
// ^ punctuation.definition.keyword.scss
background-color: $dark-background;
color: $dark-text;
}
}

// https://sass-lang.com/documentation/at-rules/control/if/#else-if
@mixin triangle($size, $color, $direction) {
height: 0;
width: 0;

border-color: transparent;
border-style: solid;
border-width: math.div($size, 2);

@if $direction == up {
border-bottom-color: $color;
} @else if $direction == right {
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.at-rule.scss
// ^^^^^^^^ keyword.control.flow.conditional.scss
// ^ punctuation.definition.keyword.scss
// ^ variable.other
// ^ keyword.operator
border-left-color: $color;
} @else if $direction == down {
border-top-color: $color;
} @else if $direction == left {
border-right-color: $color;
} @else {
@error "Unknown direction #{$direction}.";
}
}

0 comments on commit 4257e22

Please sign in to comment.