Skip to content

Commit

Permalink
fix: adds transforms for name
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreydelooff committed Aug 23, 2022
1 parent 94da818 commit 0146761
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
35 changes: 14 additions & 21 deletions src/android/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,38 +59,31 @@ export const setup = (config: AndroidConfig) => {
const registerFilter = (name, type) => {
StyleDictionaryPackage.registerFilter({
name,
matcher: token => {
return token.type === type
},
matcher: token => token.type === type,
})
}

registerFilter(typographyTemplate.filter, 'typography')
registerFilter(spacingsTemplate.filter, 'spacing')
registerFilter(colorsTemplate.filter, 'color')

StyleDictionaryPackage.registerTransformGroup({
name: 'tokens-android',
transforms: ['name/ti/camel'],
})

const StyleDictionary = StyleDictionaryPackage.extend({
source: [input],
platforms: {
android: {
transformGroup: 'name/ti/camel',
files: [
{
format: typographyTemplate.formatter,
destination: typographyTemplate.destination,
filter: typographyTemplate.filter,
},
{
format: spacingsTemplate.formatter,
destination: spacingsTemplate.destination,
filter: spacingsTemplate.filter,
},
{
format: colorsTemplate.formatter,
destination: colorsTemplate.destination,
filter: colorsTemplate.filter,
},
],
transformGroup: 'tokens-android',
files: [typographyTemplate, spacingsTemplate, colorsTemplate].map(
template => ({
format: template.formatter,
destination: template.destination,
filter: template.filter,
}),
),
},
},
})
Expand Down
7 changes: 6 additions & 1 deletion src/ios/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ export const setup = (config: IOSConfig) => {
registerFilter(spacingsTemplate.filter, 'spacing')
registerFilter(colorsTemplate.filter, 'color')

StyleDictionaryPackage.registerTransformGroup({
name: 'tokens-ios',
transforms: ['name/ti/camel'],
})

const StyleDictionary = StyleDictionaryPackage.extend({
source: [input],
platforms: {
ios: {
transformGroup: 'name/ti/camel',
transformGroup: 'tokens-ios',
files: [typographyTemplate, spacingsTemplate, colorsTemplate].map(
template => ({
format: template.formatter,
Expand Down

0 comments on commit 0146761

Please sign in to comment.