Skip to content

Commit

Permalink
chore: migrate to dtcg
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Viteri committed Aug 19, 2024
1 parent ab7d6b8 commit 19ec846
Show file tree
Hide file tree
Showing 116 changed files with 43,115 additions and 42,909 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.10.0
20 changes: 0 additions & 20 deletions Changelog.md

This file was deleted.

73 changes: 32 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ All other formats should consult the changelog for a migration path.
2. `npm install`
3. `npm run build` (output tokens)

Tokens are generated using [Style Dictionary](https://amzn.github.io/style-dictionary/#/).
Tokens are generated using [Style Dictionary v4](https://styledictionary.com/).

### Project structure
The project is made of these files and folders:
Expand Down Expand Up @@ -56,8 +56,8 @@ We follow the basic structure of style-dictionary with the exception being that
The following properties can be added to tokens to support different options

```
value # *required* The token value (most token values should be referenced from options)
category # *required* The tokens category (used to transform values for their specific platform)
$value # *required* The token value (most token values should be referenced from options)
$type # *required* The tokens category (used to transform values for their specific platform)
docs # Object to define meta data for docs
category # The category tokens are grouped in on the examples page
type # The sub category tokens are grouped in on the examples page
Expand All @@ -80,12 +80,12 @@ Options are skipped and do not get exported for consumers. However they can be [
options: { // <-- anything beneath this will be ignored in output
color: {
'easily-excited': {
value: '#3278ae',
category: 'color',
'$value': '#3278ae',
'$type': 'color',
},
'heart-of-darkness': {
value: '#292929',
category: 'color',
'$value': '#292929',
'$type': 'color',
},
// ...
},
Expand All @@ -105,12 +105,12 @@ Token names are defined by the hierarchy of the object:
body: {
default: {
size: {
value: '23px',
category: 'font-size',
'$value': '23px',
'$type': 'fontSize',
},
height: {
value: '25px',
category: 'size',
'$value': '25px',
'$type': 'size',
},
},
},
Expand All @@ -130,13 +130,13 @@ Token output of above:
Categories define how style-dictionary should transform values between platforms.

For example, a category of "size" will transform to 'rem' for SCSS/LESS but 'dp' for Android. A category of "font-size" will still transform values to 'rem' for SCSS/LESS but 'sp' for Android.
For example, a category of "size" will transform to 'rem' for SCSS/LESS but 'dp' for Android. A category of "fontSize" will still transform values to 'rem' for SCSS/LESS but 'sp' for Android.

Categories are one of the following:

- `size`: Anything that would have a value in px. With the exception of font-size
- `font-size`: Anything that defines a text size
- `letter-spacing`: exists too?
- `dimension`: Anything that would have a value in px. With the exception of fontSize
- `fontSize`: Anything that defines a text size
- `letterSpacing`: Anything that defined a letter spacing
- `color`: Anything that defines a color
- `time`: Anything the defines a timing
- Values without a category will not be transformed: Anything that is a string like `'normal'` or `'italic'`
Expand All @@ -151,8 +151,8 @@ See [attribute referencing](https://amzn.github.io/style-dictionary/#/properties
text: {
primary: {
'on-dark': {
value: '{options.color.heart-of-darkness}',
category: 'color',
'$value': '{options.color.heart-of-darkness}',
'$type': 'color',
docs: {
category: 'colors',
type: 'text',
Expand Down Expand Up @@ -185,19 +185,19 @@ docs: {

Deprecated tokens should be moved to a seprate file (or into the existing file) which corresponds to the release cycle in which they will be deprecated.

For example, if tokens will be considered deprecated in the "Winter 2019" release they would be moved into a file called `deprecated-2019-winter.json5` in whichever directory they currently reside. Structure for naming the file is : `deprecated-<year>-<release>`
For example, if tokens will be considered deprecated in the "Winter 2019" release they would be moved into a file called `deprecated-2024-summer.json5` in whichever directory they currently reside. Structure for naming the file is : `deprecated-<year>-<release>`

Additionally, the contents will be wrapped inside an object with a key that corresponds to the release as well (so we can auto generate some deprecation warnings with the correct release). The key matches the naming of the file. See below for an example.

```js
{
'deprecated-2019-winter`: { // <-------- `deprecated-<year>-<release>`
color: {
text: {
primary: {
'on-dark': {
value: '{options.color.heart-of-darkness}',
category: 'color',
'deprecated-2019-winter': { // <-------- `deprecated-<year>-<release>`
color: {
text: {
primary: {
'on-dark': {
'$value': '{options.color.heart-of-darkness}',
'$type': 'color',
docs: {
category: 'colors',
type: 'text',
Expand All @@ -218,12 +218,12 @@ When tokens are deprecated they can also be provided a new token name or new mix

```js
{
'deprecated-2019-winter': {
'deprecated-2024-summer': {
text: {
header: {
'1': {
family: {
value: '{options.font.family.serif.value}',
'$value': '{options.font.family.serif.$value}',
mixin: 'textHeader1',
property: 'font-family',
newMixin: 'new-mixin-name', //<--- a new mixin name to use instead of the deprecated one
Expand Down Expand Up @@ -253,38 +253,29 @@ All actions, configs, formats, etc are imported in this file and it [extends](ht

Found in `style-dictionary/actions`

See API for [creating an action](https://amzn.github.io/style-dictionary/#/api?id=registeraction)
See [actions docs](https://amzn.github.io/style-dictionary/#/actions)
See API for [creating an action](https://styledictionary.com/reference/hooks/actions/)

#### Configs

Found in `style-dictionary/configs`

See [config docs](https://amzn.github.io/style-dictionary/#/config).
See [config docs](https://styledictionary.com/reference/config/#configuration-file-formats).

Configs follow standard config options. They are organized separately by platform and are required into the `_index.js` file where they all have a filter for options applied.

#### Formats

Found in `style-dictionary/formats`

See API for [creating a format](https://amzn.github.io/style-dictionary/#/api?id=registerformat)
See [format docs](https://amzn.github.io/style-dictionary/#/formats).
See API for [creating a format](https://styledictionary.com/reference/hooks/formats/)

#### Transform Groups

Found in `style-dictionary/transformGroups`
See API for [creating a transform group](https://amzn.github.io/style-dictionary/#/api?id=registertransformgroup)
See [transform group docs](https://amzn.github.io/style-dictionary/#/transform_groups).
See API for [creating a transform group](https://styledictionary.com/reference/hooks/transform-groups/)

#### Transforms

Found in `style-dictionary/transforms`

See API for [creating a transform](https://amzn.github.io/style-dictionary/#/api?id=registertransform)
See API for [creating a transform](https://styledictionary.com/reference/hooks/transforms/)

See [transform docs](https://amzn.github.io/style-dictionary/#/transforms).
1 change: 1 addition & 0 deletions dist/docsite/android/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>


<resources>
<color name="cdr_color_text_button_primary">#fff9f8f6</color>
<color name="cdr_color_text_button_primary_hover">#ff1f513f</color>
Expand Down
12 changes: 1 addition & 11 deletions dist/docsite/android/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>


<resources>
<dimen name="cdr_form_input_height_default">40.00dp</dimen>
<dimen name="cdr_form_input_height_large">48.00dp</dimen>
Expand Down Expand Up @@ -87,26 +88,15 @@
<dimen name="cdr_space_inset_four_x_squish_left_right">64.00dp</dimen>
<dimen name="cdr_space_inset_four_x_stretch_top_bottom">96.00dp</dimen>
<dimen name="cdr_space_inset_four_x_stretch_left_right">64.00dp</dimen>
<dimen name="cdr_text_default_display1_size">34.00sp</dimen>
<dimen name="cdr_text_default_display1_line_spacing">40.00dp</dimen>
<dimen name="cdr_text_default_title1_size">26.00sp</dimen>
<dimen name="cdr_text_default_title1_line_spacing">36.00dp</dimen>
<dimen name="cdr_text_default_title2_size">24.00sp</dimen>
<dimen name="cdr_text_default_title2_line_spacing">32.00dp</dimen>
<dimen name="cdr_text_default_title3_size">19.00sp</dimen>
<dimen name="cdr_text_default_title3_line_spacing">28.00dp</dimen>
<dimen name="cdr_text_default_headline_size">17.00sp</dimen>
<dimen name="cdr_text_default_headline_line_spacing">24.00dp</dimen>
<dimen name="cdr_text_default_subheadline_size">15.00sp</dimen>
<dimen name="cdr_text_default_subheadline_line_spacing">20.00dp</dimen>
<dimen name="cdr_text_default_body1_size">15.00sp</dimen>
<dimen name="cdr_text_default_body1_line_spacing">20.00dp</dimen>
<dimen name="cdr_text_default_body2_size">12.00sp</dimen>
<dimen name="cdr_text_default_body2_line_spacing">18.00dp</dimen>
<dimen name="cdr_text_default_caption1_size">12.00sp</dimen>
<dimen name="cdr_text_default_caption1_line_spacing">16.00dp</dimen>
<dimen name="cdr_text_default_caption2_size">11.00sp</dimen>
<dimen name="cdr_text_default_caption2_line_spacing">16.00dp</dimen>
<dimen name="cdr_text_default_button_size">15.00sp</dimen>
<dimen name="cdr_text_default_button_line_spacing">24.00dp</dimen>
</resources>
1 change: 1 addition & 0 deletions dist/docsite/android/font_dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>


<resources>
<dimen name="cdr_text_default_display1_size">34.00sp</dimen>
<dimen name="cdr_text_default_title1_size">26.00sp</dimen>
Expand Down
Loading

0 comments on commit 19ec846

Please sign in to comment.