Skip to content

Commit

Permalink
fix: Update to new Sass math.div function
Browse files Browse the repository at this point in the history
  • Loading branch information
zastrow committed Oct 8, 2021
1 parent 08cfdaa commit 618de12
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 17 deletions.
2 changes: 2 additions & 0 deletions _systems.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// System Utilities
@use 'sass:math';

// Color System
@import "systems/color/docs";
@import "systems/color/foreground/utility";
Expand Down
2 changes: 2 additions & 0 deletions _tools.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@use 'sass:math';

// Global Function
@import "tools/settings/function";
@import "globals/media-queries/function";
Expand Down
6 changes: 3 additions & 3 deletions mdcss/_mdcss.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ section[id*="grid-demo-"] + section[id*="grid-demo-"] {
$color-2: nth($demo-color, 2);

@for $i from 1 through grid(columns) {
$mix-1: ($i / grid(columns)) * 100%;
$mix-2: 100% - (($i / grid(columns)) * 100%);
$mix-1: math.div($i, grid(columns)) * 100%;
$mix-2: 100% - (math.div($i, grid(columns)) * 100%);

&:nth-child(#{$i}) {
$color: $color-1;
@if ($i / 2) == ceil($i / 2) {
@if math.div($i, 2) == math.ceil(math.div($i, 2)) {
$color: mix($color-1, darken($color-2, 15%), $mix-1);
} @else {
$color: mix(lighten($color-2, 5%), $color-1, $mix-2);
Expand Down
1 change: 1 addition & 0 deletions mdcss/docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// turns off and on the comments used to generate
// the Docs. If this variable is set to false, the
// docs will not generate.
@use "sass:math";
@import "../settings";
$sparkle-show-docs: true;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"mocha": "^8.1.3",
"postcss": "^8.1.0",
"postcss-cli": "^8.0.0",
"sass": "^1.26.11",
"sass": "^1.35.1",
"sass-true": "^6.0.0",
"standard-version": "^9.0.0"
},
Expand Down
20 changes: 10 additions & 10 deletions systems/grid/cells/_mixins.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@mixin sparkle-column-span($count, $span) {
float: left;
width: ($span / $count) * 100%;
width: math.div($span, $count) * 100%;

@supports (display: grid) {
width: auto;
Expand All @@ -13,13 +13,13 @@
$r: '';
$end: '';
$grid-set: '';
@for $i from 1 through floor($count/$iteration) {
@for $i from 1 through math.floor(math.div($count, $iteration)) {
@if $count - $iteration > 0 {
@if $count/2 < $iteration {
@if math.div($count, 2) < $iteration {
$grid-set: $count - $iteration;
$end: '<div class="#{$class}-#{$grid-set}-#{$count}"><span>#{$grid-set}-#{$count}</span></div>';
} @else if ($iteration * floor($count / $iteration)) < $count {
$grid-set: $count - ($iteration * floor($count / $iteration));
} @else if ($iteration * math.floor(math.div($count, $iteration))) < $count {
$grid-set: $count - ($iteration * math.floor(math.div($count, $iteration)));
$end: '<div class="#{$class}-#{$grid-set}-#{$count}"><span>#{$grid-set}-#{$count}</span></div>';
} @else {
$end: '';
Expand All @@ -33,23 +33,23 @@
@function sparkle-grid-class($iteration, $count, $class, $mq) {
$val: '';

@if ($iteration/$count) == (1/4) {
@if math.div($iteration, $count) == math.div(1, 4) {
$val: ".#{$class}-quarter#{$mq}, ";
}

@else if ($iteration/$count) == (1/3) {
@else if math.div($iteration, $count) == math.div(1, 3) {
$val: ".#{$class}-third#{$mq}, ";
}

@else if ($iteration/$count) == (1/2) {
@else if math.div($iteration, $count) == math.div(1, 2) {
$val: ".#{$class}-half#{$mq}, ";
}

@else if ($iteration/$count) == (2/3) {
@else if math.div($iteration, $count) == math.div(2, 3) {
$val: ".#{$class}-two-third#{$mq}, .#{$class}-two-thirds#{$mq}, ";
}

@else if ($iteration/$count) == (3/4) {
@else if math.div($iteration, $count) == math.div(3, 4) {
$val: ".#{$class}-three-quarter#{$mq}, .#{$class}-three-quarters#{$mq}, ";
}

Expand Down
1 change: 1 addition & 0 deletions test/test.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Requirements
@use 'sass:math';
@use '../node_modules/sass-true/sass/true';

// TESTS
Expand Down
2 changes: 1 addition & 1 deletion tools/ratio/_function.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
}

@function ratio($height,$width) {
@return ($height / $width) * 100%;
@return math.div($height, $width) * 100%;
}
2 changes: 1 addition & 1 deletion tools/remify/_function.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@

@function remify($value) {
$value: strip-units($value);
@return ($value / 16) * 1rem;
@return math.div($value, 16) * 1rem;
}
2 changes: 1 addition & 1 deletion tools/strip-units/_function.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
}

@function strip-units($number) {
@return $number / ($number * 0 + 1);
@return math.div($number, ($number * 0 + 1));
}

0 comments on commit 618de12

Please sign in to comment.