Skip to content

Commit

Permalink
Expand composites (#1169)
Browse files Browse the repository at this point in the history
* feat: allow specifying platform for preprocessors

* feat: allow expanding object value tokens using expand config

* feat: align preprocessor API, adjust expand API
  • Loading branch information
jorenbroekema committed Jun 28, 2024
1 parent 6a6b3cb commit 7713b43
Show file tree
Hide file tree
Showing 27 changed files with 1,736 additions and 362 deletions.
46 changes: 46 additions & 0 deletions .changeset/short-jokes-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
'style-dictionary': major
---

BREAKING: preprocessors must now also be explicitly applied on global or platform level, rather than only registering it. This is more consistent with how the other hooks work and allows applying it on a platform level rather than only on the global level.

`preprocessors` property that contains the registered preprocessors has been moved under a wrapping property called `hooks`.

Before:

```js
export default {
// register it inline or by SD.registerPreprocessor
// applies automatically, globally
preprocessors: {
foo: (dictionary) => {
// preprocess it
return dictionary;
}
}
}
```

After:

```js
export default {
// register it inline or by SD.registerPreprocessor
hooks: {
preprocessors: {
foo: (dictionary) => {
// preprocess it
return dictionary;
}
}
},
// apply it globally
preprocessors: ['foo'],
platforms: {
css: {
// or apply is per platform
preprocessors: ['foo']
}
}
}
```
2 changes: 1 addition & 1 deletion .changeset/sweet-toes-fly.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'style-dictionary': minor
'style-dictionary': major
---

BREAKING: expose getReferences and usesReference utilities as standalone utils rather than requiring them to be bound to dictionary object. This makes it easier to use.
5 changes: 5 additions & 0 deletions .changeset/thick-scissors-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'style-dictionary': minor
---

Allow expanding tokens on a global or platform-specific level. Supports conditionally expanding per token type, or using a function to determine this per individual token.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ This tells the style dictionary build system how and what to build. The default
}
```

| Attribute | Type | Description |
| Property | Type | Description |
| :----------------------------------- | :---------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| source | Array | An array of file path [globs](https://github.com/isaacs/node-glob) to design token files. Style Dictionary will do a deep merge of all of the token files, allowing you to organize your files files however you want. |
| include | Array | An array of file path [globs](https://github.com/isaacs/node-glob) to design token files that contain default styles. The Style Dictionary uses this as a base collection of tokens. The tokens found using the "source" attribute will overwrite tokens found using include. |
Expand Down
1 change: 1 addition & 0 deletions __integration__/async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ describe('integration', async function () {

const sd = new SDExtension({
source: [`__integration__/tokens/**/[!_]*.json?(c)`],
preprocessors: ['foo-processor'],
platforms: {
css: {
transforms: [
Expand Down
Loading

0 comments on commit 7713b43

Please sign in to comment.