Re: [csswg-drafts] [css-conditional-4] Rename @when to @if (#6684)

@simonbuerger indeed the proposed idea was also meant to be fairly easy to implement for sass. If sass really wants to go the extra mile it could implement a per package flag.

strawman proposal `"scss-if": "scss|css"` in the package.json

This would mean that the users and library can choose how its particular code handles `@if`.

|          | action                 | appears in css |
| -------- | ---------------------- | -------------- |
| @if      | depends on package setting | ❌ / ✅        |
| @scss-if | scss as is             | ❌             |
| @css-if  | becomes native @if     | ✅             |

This would result in the following possible scenarios

| User Type           | Used Library Type   | If Behavior |
| ------------------- | ------------------- | ----------- |
| undefined `scss-if` |                     | scss        |
|                     | undefined `scss-if` | scss        |
|                     | `"scss-if": "scss"` | scss        |
|                     | `"scss-if": "css"`  | css         |
| `"scss-if": "scss"` |                     | scss        |
|                     | undefined `scss-if` | scss        |
|                     | `"scss-if": "scss"` | scss        |
|                     | `"scss-if": "css"`  | css         |
| `"scss-if": "css"`  |                     | css         |
|                     | undefined `scss-if` | scss        |
|                     | `"scss-if": "scss"` | scss        |
|                     | `"scss-if": "css"`  | css         |

This means no user or library change is needed as the default is the scss if behavior.

To use the `native` css `@if` a user or library author can
- use `@css-if`
- OR manually opt all `@if` in his package to the native css behavior by setting `"scss-if": "css"` in his package.json    


I'm not familiar enough with the scss codebase to know how feasible this is... but I think it illustrates that it's a logically solvable problem.

It's somewhat comparable to how `"type": "module"` for JavaScript works - although my **guess** is that its complexity should be significantly smaller.

-- 
GitHub Notification of comment by daKmoR
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6684#issuecomment-1069012833 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 16 March 2022 11:16:15 UTC