Skip to content

Commit

Permalink
Fix comment. Remove unused var.
Browse files Browse the repository at this point in the history
  • Loading branch information
narin committed Oct 30, 2024
1 parent 40246d2 commit 8a3ccbd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/tokens/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ StyleDictionary.registerFilter({
matcher: (token) => filterFont(token, 'line-height'),
})

/** Filter to tokens of category 'font', type 'font', and npm true */
/** Filter to tokens of category 'font', type 'composite', and npm true */
StyleDictionary.registerFilter({
name: 'filter/font/composite-npm',
matcher: (token) => filterFont(token, 'composite'),
Expand Down Expand Up @@ -191,17 +191,16 @@ StyleDictionary.registerFormat({
/** Custom format to generate font/index.d.ts with exports */
StyleDictionary.registerFormat({
name: 'typescript/es6-declarations/fontIndex',
formatter: function ({ dictionary }) {
formatter: function () {
const files = ['family', 'letterSpacing', 'lineHeight', 'size', 'styles']
let imports = '',
exports = ''

for (const file of files) imports += `import { ${file} } from './${file}'\n`
exports += 'export declare const font: {\n'
for (const file of files) exports += `${file}: typeof ${file},\n`
exports += '}\n\n'

return `${imports}\n${exports}`
return `${imports}\n${exports}}`
},
})

Expand Down Expand Up @@ -268,19 +267,22 @@ StyleDictionary.registerFormat({
}

declaration += `export declare const ${options.exportName}: {\n`
for (const token of dictionary.allTokens) {
for (const token of tokens) {
let docs = `/** `
let valueKeys = '{\n'

// Generate docs line and object of value types
Object.keys(token.value).forEach((key, index) => {
docs += `${index !== 0 ? '| ' : ''}${key}: ${token.value[key]} `
valueKeys += ` ${key}: ${typeof token.value[key]}\n`
})
docs += `*/\n`

docs += `*/\n`
declaration += ` ${docs}`
declaration += ` ${token.name}: ${valueKeys}`
declaration += ` }\n`
}

declaration += '}'
return declaration
},
Expand Down

0 comments on commit 8a3ccbd

Please sign in to comment.