Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated Sass division #60

Merged
merged 1 commit into from
Feb 6, 2024
Merged

Conversation

notlee
Copy link
Contributor

@notlee notlee commented Feb 5, 2024

Sass currently treats / as a division operation in some contexts and a separator in others. This makes it difficult for Sass users to tell what any given / will mean, and makes it hard to work with new CSS features that use / as a separator. It will be removed in a future version of Sass.
https://sass-lang.com/documentation/breaking-changes/slash-div/

As such it is causing annoying warnings for all projects which include this project.

Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($spacing-unit, 2) or calc($spacing-unit / 2)

More info and automated migrator: https://sass-lang.com/d/slash-div

   ╷
78 │         padding: $spacing-unit/2 $spacing-unit;
   │                  ^^^^^^^^^^^^^^^
   ╵
    node_modules/@financial-times/dotcom-ui-header/node_modules/n-topic-search/main.scss 78:12  nTopicSearch()
    node_modules/@financial-times/dotcom-ui-header/styles.scss 14:1                             @import
    stdin 49:9                                                                                  root stylesheet

Instead we can:

  1. Use a plain CSS calc funciton
  2. Use multiplication
  3. Use math.div
@use "sass:math";

// WRONG, will not work in future Sass versions.
@debug (12px/4px); // 3

// RIGHT, will work in future Sass versions.
@debug math.div(12px, 4px); // 3

In this case I went for option 2, because that's what the Sass migrator did for me: https://sass-lang.com/documentation/cli/migrator/

sass-migrator division  main.scss --load-path node_modules/

But really, I'd advocate 1 (plain CSS) in the future :D https://origami.ft.com/blog/2024/01/24/sass-build-times/

Sass currently treats / as a division operation in some contexts and a separator in others. This makes it difficult for Sass users to tell what any given / will mean, and makes it hard to work with new CSS features that use / as a separator.
It will be removed in a future version of Sass.
https://sass-lang.com/documentation/breaking-changes/slash-div/

As such it is causing annoying warnings for all projects which include this project.

```
eprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($spacing-unit, 2) or calc($spacing-unit / 2)

More info and automated migrator: https://sass-lang.com/d/slash-div

   ╷
78 │         padding: $spacing-unit/2 $spacing-unit;
   │                  ^^^^^^^^^^^^^^^
   ╵
    node_modules/@financial-times/dotcom-ui-header/node_modules/n-topic-search/main.scss 78:12  nTopicSearch()
    node_modules/@financial-times/dotcom-ui-header/styles.scss 14:1                             @import
    stdin 49:9                                                                                  root stylesheet
```

Instead we can:

1. Use a plain CSS `calc` funciton
2. Use multiplication
3. Use `math.div`

```scss
@use "sass:math";

// WRONG, will not work in future Sass versions.
@debug (12px/4px); // 3

// RIGHT, will work in future Sass versions.
@debug math.div(12px, 4px); // 3
```

In this case I went for option 2, because that's what the Sass migrator did for me:
https://sass-lang.com/documentation/cli/migrator/

```
sass-migrator division  main.scss --load-path node_modules/
```

But really, I'd advocate 1 (plain CSS) in the future :D
https://origami.ft.com/blog/2024/01/24/sass-build-times/
@notlee notlee requested a review from a team as a code owner February 5, 2024 16:09
@metart43 metart43 merged commit de3b3aa into main Feb 6, 2024
8 checks passed
@metart43 metart43 deleted the remove-deprecated-sass-division branch February 6, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants