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

Make whitespace invalid in token names #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.DS_Store
.history
4 changes: 2 additions & 2 deletions technical-reports/format/aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ For example:
```json
{
"group name": {
"token name": {
"token-name": {
"$value": 1234,
"$type": "number"
}
},
"alias name": {
"alias-name": {
"$value": "{group name.token name}"
}
}
Expand Down
10 changes: 6 additions & 4 deletions technical-reports/format/design-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

```json
{
"token name": {
"token-name": {
"$value": "#fff000",
"$type": "color"
}
Expand All @@ -17,6 +17,8 @@ Note: The `$type` property has been added to ensure this example is valid. Pleas

</aside>

The name of your design token must not include any whitespace. Otherwise your design token is considered as invalid.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The name of your design token must not include any whitespace. Otherwise your design token is considered as invalid.
Design tokens are written in kebab-case. Otherwise your design token is considered as invalid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be left as is. Kebab-case is only one way of avoiding whitespace... snake_case or CamelCase are fine too.


An object with a **`$value`** property is a token. Thus, `$value` is a reserved word in our spec, meaning you can't have a token whose name is "$value". The parent object's key is the token name.

The example above therefore defines 1 design token with the following properties:
Expand Down Expand Up @@ -98,7 +100,7 @@ The value of the `$description` property MUST be a plain JSON string, for exampl

```json
{
"Button background": {
"button-background": {
"$value": "#777777",
"$type": "color",
"$description": "The background color for buttons in their normal state."
Expand Down Expand Up @@ -133,7 +135,7 @@ For example:

```json
{
"Button background": {
"button-background": {
"$value": "#777777",
"$type": "color"
}
Expand All @@ -153,7 +155,7 @@ The optional **`$extensions`** property is an object where tools MAY add proprie

```json
{
"Button background": {
"button-background": {
"$value": "#777777",
"$type": "color",
"$extensions": {
Expand Down
28 changes: 14 additions & 14 deletions technical-reports/format/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ A file MAY contain many tokens and they MAY be nested arbitrarily in groups like
"$type": "color"
},
"token group": {
"token dos": {
"token-dos": {
"$value": "2rem",
"$type": "dimension"
},
"nested token group": {
"token tres": {
"token-tres": {
"$value": 33,
"$type": "number"
},
"Token cuatro": {
"Token-cuatro": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Token-cuatro": {
"token-cuatro": {

"$value": 444,
"$type": "fontWeight"
}
Expand Down Expand Up @@ -78,7 +78,7 @@ Group keys without a dollar sign (`$`) prefix denote:
{
"Group of tokens": {
"$description": "This is an example of a group containing a single token",
"Token name": {
"token-name": {
"$value": "#000000"
}
}
Expand All @@ -92,10 +92,10 @@ Group keys without a dollar sign (`$`) prefix denote:
"Group of tokens": {
"$description": "This is an example of a group containing a nested group",
"Subgroup of tokens": {
"Token 1 name": {
"token-1-name": {
"$value": "#aabbcc"
},
"Token 2 name": {
"token-2-name": {
"$value": "#ddeeff"
}
}
Expand All @@ -119,10 +119,10 @@ For example:
"$description": "Design tokens from our brand guidelines",
"color": {
"$description": "Our brand's primary color palette",
"acid green": {
"acid-green": {
"$value": "#00ff66"
},
"hot pink": {
"hot-pink": {
"$value": "#dd22cc"
}
}
Expand Down Expand Up @@ -159,10 +159,10 @@ For example:
"brand": {
"$type": "color",
"color": {
"acid green": {
"acid-green": {
"$value": "#00ff66"
},
"hot pink": {
"hot-pink": {
"$value": "#dd22cc"
}
}
Expand All @@ -187,10 +187,10 @@ For example:
"brand": {
"color": {
"$type": "color",
"acid green": {
"acid-green": {
"$value": "#00ff66"
},
"hot pink": {
"hot-pink": {
"$value": "#dd22cc"
}
},
Expand Down Expand Up @@ -258,10 +258,10 @@ For example, a [=translation tool=] like [Style Dictionary](https://amzn.github.
"brand": {
"color": {
"$type": "color",
"acid green": {
"acid-green": {
"$value": "#00ff66"
},
"hot pink": {
"hot-pink": {
"$value": "#dd22cc"
}
},
Expand Down
8 changes: 4 additions & 4 deletions technical-reports/format/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ For example, initially the color tokens MAY be defined as such:

```json
{
"Majestic magenta": {
"majestic-magenta": {
"$value": "#ff00ff",
"$type": "color"
},
"Translucent shadow": {
"translucent-shadow": {
"$value": "#00000080",
"$type": "color"
}
Expand Down Expand Up @@ -93,11 +93,11 @@ For example:

```json
{
"Primary font": {
"primary-font": {
"$value": "Comic Sans MS",
"$type": "fontFamily"
},
"Body font": {
"body-font": {
"$value": ["Helvetica", "Arial", "sans-serif"],
"$type": "fontFamily"
}
Expand Down