-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web): Fix type and breakpoints tokens (#124)
This PR fixes system type and breakpoints tokens. [category:Web Tokens] Release Note: Type tokens have been fixed to refer to system font tokens instead of base. Breakpoints tokens have been fixed to have px value instead of rem. Co-authored-by: Raisa Primerova <[email protected]>
- Loading branch information
1 parent
8e81145
commit 0cab56d
Showing
12 changed files
with
136 additions
and
85 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 |
---|---|---|
@@ -1,15 +1,10 @@ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier', | ||
], | ||
plugins: ['@typescript-eslint'], | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], | ||
rules: { | ||
"@typescript-eslint/no-explicit-any": "off" | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/ban-ts-ignore': 'off', | ||
}, | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import fs from 'fs'; | ||
import {decodeJSONBufferString} from './parse-utils'; | ||
import path from 'path'; | ||
|
||
type Transform = ( | ||
tokens: Record<string, any>, | ||
parsed?: any, | ||
level?: string | ||
) => Record<string, string[]>; | ||
|
||
const transformToRefs: Transform = (tokens, parsed = {}, level = '') => { | ||
const keys = Object.keys(tokens); | ||
|
||
keys.forEach(key => { | ||
const isHighestLevel = /base|brand|sys/.test(key); | ||
if (isHighestLevel) { | ||
parsed[key] = []; | ||
} | ||
|
||
if (keys.includes('value')) { | ||
parsed?.push(level); | ||
return parsed; | ||
} | ||
|
||
transformToRefs( | ||
tokens[key], | ||
isHighestLevel ? parsed[key] : parsed, | ||
isHighestLevel ? '' : level ? `${level}.${key}` : key | ||
); | ||
}); | ||
|
||
return parsed; | ||
}; | ||
|
||
export const generateRefs = async (file: any) => { | ||
const refsFileName = path.resolve(__dirname, '../../packages/canvas-tokens/_refs.json'); | ||
|
||
await fs.readFile(refsFileName, async (err, data) => { | ||
const tokens = transformToRefs(file); | ||
|
||
if (err || !data) { | ||
fs.writeFileSync(refsFileName, JSON.stringify(tokens)); | ||
} else { | ||
const content = decodeJSONBufferString(data as any); | ||
fs.writeFileSync(refsFileName, JSON.stringify({...content, ...tokens})); | ||
} | ||
}); | ||
}; |
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