Re: [community-group] Add a `$private` property for tokens (#110)

What if you just prefix the JSON property with an underscore?

* This is a pretty common convention among many programming languages to denote "private" members in a class/module.
* It's shorter to type than an explicit `$private` property.
* It won't affect alias lookup (`{_foo.bar}` and `{fizz._buzz}` would still work as expected).
* Whatever label you give it, the intent is to exclude tokens from direct consumption in translated output.
    * For languages that have module encapsulation, "private" tokens are those that are not exported from the module.
    * For languages that don't have module encapsulation, translation tools may choose to omit "private" tokens and resolve private aliases to their final value. Alternatively, translation tools may do nothing different and let things fall where they may.


```json
{
  "_green": {
    "$type": "color",
    "$value": "#00ff00"
  },
  "red": {
    "$type": "color",
    "$value": "#ff0000"
  },
  "blue": {
    "$type": "color",
    "$value": "#0000ff"
  },
  "grass": {
    "$value": "{_green}"
  }
}
```

* `_green` is "private" (internal) due to naming convention.


## Examples
### JavaScript

_ESM Format_
```javascript
const _green = '#00ff00';

export const red = '#ff0000';
export const blue = '#0000ff';
export const grass = _green;
```

_CJS Format_
```javascript
const _green = '#00ff00';

const red = '#ff0000';
const blue = '#0000ff';
const grass = _green;

module.exports = {
  red,
  blue,
  grass,
}
```

### SCSS Module

```scss
$_green: #00ff00;

$red: #ff0000;
$blue: #0000ff;
$grass: $_green;
```

### CSS 

_exclude "private"_
```css
:root {
  --red: #ff0000;
  --blue: #0000ff;
  --grass: #00ff00;
}
```

_include "private"_
```css
:root {
  --_green: #00ff00;

  --red: #ff0000;
  --blue: #0000ff;
  --grass: var(--_green);
}
```

### Flutter

```dart
import 'package:flutter/material.dart';

const Color _green = Color(0xff00ff00);

class MyColors {
  MyColors._();

  static const red = Color(0xffff0000);
  static const blue = Color(0xff0000ff);
  static const grass = _green;
}
```

-- 
GitHub Notification of comment by CITguy
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/110#issuecomment-1148941702 using your GitHub account


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

Received on Tuesday, 7 June 2022 17:09:10 UTC