-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move formats global prop to hooks.formats, align api
- Loading branch information
1 parent
7a384aa
commit 24db531
Showing
49 changed files
with
275 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
'style-dictionary': major | ||
--- | ||
|
||
BREAKING: Formats, when registered, are put inside the `hooks.formats` property now, as opposed to `format`. | ||
The `formatter` handler function has been renamed to `format` for consistency. | ||
|
||
The importable type interfaces have also been renamed, `Formatter` is now `FormatFn` and `FormatterArguments` is now `FormatFnArguments`. | ||
Note that you can also use `Format['format']` instead of `FormatFn`, or `Parameters<Format['format']>` instead of `FormatFnArguments`, so these renames may not matter. | ||
|
||
Before: | ||
|
||
```ts | ||
import StyleDictionary from 'style-dictionary'; | ||
import type { Formatter, FormatterArguments } from 'style-dictionary/types'; | ||
|
||
// register it with register method | ||
StyleDictionary.registerFormat({ | ||
name: 'custom/json', | ||
formatter: ({ dictionary }) => JSON.stringify(dictionary, 2, null), | ||
}) | ||
|
||
export default { | ||
// OR define it inline | ||
format: { | ||
'custom/json': ({ dictionary }) => JSON.stringify(dictionary, 2, null), | ||
}, | ||
platforms: { | ||
json: { | ||
files: [{ | ||
destination: 'output.json', | ||
format: 'custom/json' | ||
}], | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
After: | ||
|
||
```ts | ||
import StyleDictionary from 'style-dictionary'; | ||
import type { FormatFn, FormatFnArguments } from 'style-dictionary/types'; | ||
|
||
// register it with register method | ||
StyleDictionary.registerFormat({ | ||
name: 'custom/json', | ||
format: ({ dictionary }) => JSON.stringify(dictionary, 2, null), | ||
}) | ||
|
||
export default { | ||
// OR define it inline | ||
hooks: { | ||
formats: { | ||
'custom/json': ({ dictionary }) => JSON.stringify(dictionary, 2, null), | ||
}, | ||
}, | ||
platforms: { | ||
json: { | ||
files: [{ | ||
destination: 'output.json', | ||
format: 'custom/json' | ||
}], | ||
}, | ||
}, | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.