Skip to content

Commit

Permalink
feat(sass linter): fixing at-rule-conditional-no-parentheses rule
Browse files Browse the repository at this point in the history
  • Loading branch information
manoncarbonnel authored and dpellier committed Oct 13, 2023
1 parent e5619cc commit bc70eac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"color-function-notation": "legacy",
"hue-degree-notation": "number",
"scss/no-global-function-names": null,
"scss/at-rule-conditional-no-parentheses": null,
"selector-class-pattern": [
"^[a-z]([-_]{0,2}?[a-z0-9]+)*(__[a-z0-9]([-]?[a-z0-9]+)*)?(--[a-z0-9]([-]?[a-z0-9]+)*)?$",
{
Expand Down
15 changes: 14 additions & 1 deletion packages/common/theming/color/ods-component-color.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,36 @@
/// @param {String} $hue - the hue to apply like '500' or '500-contrasted'
/// @return {Variable} - a CSS variable corresponding to the color defined in the theme
@function ods-get-color-variable($intent-name: null, $palette-name: null, $hue, $alpha: 1) {
@if($intent-name == null and $palette-name == null) {
@if not ($intent-name and $palette-name) {
@error 'You must set $intent-name or $palette-name at least';
}

$name: if($intent-name, $intent-name, $palette-name);

@if($intent-name and not map-has-key($ods-color-intents, $intent-name)) {
@if ($DEBUG) {
@debug ods-get-available-intent-names();
}

@error 'the intent name does not exists in ODS theming! $intent-name=#{$intent-name} not in #{ods-get-available-intent-names()}';
}

@if($palette-name and not map-has-key($ods-palette-definitions, $palette-name)) {
@if ($DEBUG) {
@debug ods-get-available-palette-names();
}

@error 'the palette name does not exists in ODS theming! $palette-name=#{$palette-name} not in #{ods-get-available-palette-names()}';
}

$color: null;

@if($alpha != 1) {
$color: hsla(var(--ods-color-#{$name}-#{$hue}-list), unquote($alpha));
} @else {
$color: var(--ods-color-#{$name}-#{$hue});
}

@return $color;
}

Expand Down Expand Up @@ -136,13 +142,16 @@

// by default, color default
$colors: ();

@each $property, $hue in $hues {
$color: null;

@if(type-of($hue) == map) {
$color: ods-get-color-variable($intent-name: default, $hue: map-get($hue, 'tone'), $alpha: map-get($hue, 'alpha'));
} @else {
$color: ods-get-color-variable($intent-name: default, $hue: $hue);
}

$colors: map-merge($colors, ($property: $color));
}
#{$and-selector}:not([color]) {
Expand All @@ -153,14 +162,18 @@
@each $intent-name, $palette-config in $ods-color-intents {
#{$and-selector}[color^=#{$intent-name}] {
$colors: ();

@each $property, $hue in $hues {
$color: null;

@if(type-of($hue) == map) {
$color: ods-get-color-variable($intent-name: $intent-name, $hue: map-get($hue, 'tone'), $alpha: map-get($hue, 'alpha'));
} @else {
$color: ods-get-color-variable($intent-name: $intent-name, $hue: $hue);
}

$colors: map-merge($colors, ($property: $color));

@if ($DEBUG) {
@debug '$color=#{$color}';
@debug '$colors=';
Expand Down
12 changes: 6 additions & 6 deletions packages/themes/blue-jeans/src/spacing/spacing-concepts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $border-radius-concept: (
@each $size, $value in $stack-concept {
$result: calc(#{$size-base * $value}rem * var(--ods-size-ratio));

@if $size == "06" {
@if ($size == "06") {
--ods-size-stack-default: #{$result};
--ods-size-stack-n-default: calc(-1 * var(--ods-size-stack-default));
}
Expand All @@ -52,7 +52,7 @@ $border-radius-concept: (
@each $size, $value in $inline-concept {
$result: calc(#{$size-base * $value}rem * var(--ods-size-ratio));

@if $size == "06" {
@if ($size == "06") {
--ods-size-inline-default: #{$result};
--ods-size-inline-n-default: calc(-1 * var(--ods-size-inline-default));
}
Expand All @@ -64,7 +64,7 @@ $border-radius-concept: (
@each $size, $value in $inset-concept {
$result: calc(#{$size-base * $value}rem * var(--ods-size-ratio));

@if $size == "06" {
@if ($size == "06") {
--ods-size-inset-default: #{$result};
--ods-size-inset-default-x: #{$result};
--ods-size-inset-default-y: #{$result};
Expand All @@ -81,7 +81,7 @@ $border-radius-concept: (
$result: calc(#{$size-base * $value}rem * var(--ods-size-ratio));
$larger-result: calc(#{$size-base * $value * 1.5}rem * var(--ods-size-ratio));

@if $size == "06" {
@if ($size == "06") {
--ods-size-squish-default: #{$result} #{$larger-result};
--ods-size-squish-default-x: #{$larger-result};
--ods-size-squish-default-y: #{$result};
Expand All @@ -98,7 +98,7 @@ $border-radius-concept: (
$result: calc(#{$size-base * $value}rem * var(--ods-size-ratio));
$larger-result: calc(#{$size-base * $value * 1.5}rem * var(--ods-size-ratio));

@if $size == "06" {
@if ($size == "06") {
--ods-size-stretch-default: #{$larger-result} #{$result};
--ods-size-stretch-default-x: #{$result};
--ods-size-stretch-default-y: #{$larger-result};
Expand All @@ -114,7 +114,7 @@ $border-radius-concept: (
@each $size, $value in $border-radius-concept {
$result: calc(#{$size-base * $value}rem * var(--ods-size-ratio));

@if $size == "06" {
@if ($size == "06") {
--ods-size-border-radius-default: #{$result};
}

Expand Down

0 comments on commit bc70eac

Please sign in to comment.