-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from Teamwork/android/xml_sizes
Android: Generate XML sizes and add Teamwork.*.system
- Loading branch information
Showing
5 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
87 changes: 87 additions & 0 deletions
87
android/styledictionary/teamwork-design-system/src/main/res/values/dimens.xml
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,87 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<resources> | ||
<dimen name="border_width_xs">0.5dp</dimen> <!-- type: borderWidth --> | ||
<dimen name="border_width_sm">1dp</dimen> <!-- type: borderWidth --> | ||
<dimen name="border_width_md">2dp</dimen> <!-- type: borderWidth --> | ||
<dimen name="border_width_lg">3dp</dimen> <!-- type: borderWidth --> | ||
<dimen name="border_radius_none">0dp</dimen> <!-- type: borderRadius --> | ||
<dimen name="border_radius_xxs">4dp</dimen> <!-- type: borderRadius --> | ||
<dimen name="border_radius_xs">6dp</dimen> <!-- type: borderRadius --> | ||
<dimen name="border_radius_sm">8dp</dimen> <!-- type: borderRadius --> | ||
<dimen name="border_radius_md">12dp</dimen> <!-- type: borderRadius --> | ||
<dimen name="border_radius_lg">16dp</dimen> <!-- type: borderRadius --> | ||
<dimen name="border_radius_xl">28dp</dimen> <!-- type: borderRadius --> | ||
<dimen name="border_radius_full">100dp</dimen> <!-- type: borderRadius --> | ||
<!-- Ignoring token of type 'fontFamilies' --> | ||
<!-- Ignoring token of type 'fontFamilies' --> | ||
<dimen name="line_height_leading_01">16sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_02">20sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_03">24sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_04">28sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_05">32sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_06">36sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_07">40sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_08">44sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_09">52sp</dimen> <!-- type: lineHeights --> | ||
<dimen name="line_height_leading_10">64sp</dimen> <!-- type: lineHeights --> | ||
<!-- Ignoring token of type 'fontWeights' --> | ||
<!-- Ignoring token of type 'fontWeights' --> | ||
<dimen name="fonts_size_font_size_01">11sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_02">12sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_03">14sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_04">16sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_05">22sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_06">24sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_07">28sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_08">32sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_09">36sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_10">45sp</dimen> <!-- type: fontSizes --> | ||
<dimen name="fonts_size_font_size_11">57sp</dimen> <!-- type: fontSizes --> | ||
<!-- Ignoring token of type 'letterSpacing' --> | ||
<!-- Ignoring token of type 'letterSpacing' --> | ||
<!-- Ignoring token of type 'letterSpacing' --> | ||
<!-- Ignoring token of type 'letterSpacing' --> | ||
<!-- Ignoring token of type 'letterSpacing' --> | ||
<!-- Ignoring token of type 'letterSpacing' --> | ||
<!-- Ignoring token of type 'letterSpacing' --> | ||
<!-- Ignoring token of type 'letterSpacing' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'typography' --> | ||
<!-- Ignoring token of type 'textCase' --> | ||
<!-- Ignoring token of type 'boxShadow' --> | ||
<!-- Ignoring token of type 'boxShadow' --> | ||
<!-- Ignoring token of type 'boxShadow' --> | ||
<!-- Ignoring token of type 'boxShadow' --> | ||
<!-- Ignoring token of type 'boxShadow' --> | ||
<!-- Ignoring token of type 'textDecoration' --> | ||
<dimen name="space_space_01">2dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_02">4dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_03">8dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_04">12dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_05">16dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_06">24dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_07">32dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_08">40dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_09">44dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_10">48dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_11">56dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_12">64dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_13">72dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_14">80dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_15">112dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_16">128dp</dimen> <!-- type: spacing --> | ||
<dimen name="space_space_none">0dp</dimen> <!-- type: spacing --> | ||
</resources> |
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,36 @@ | ||
// the list of token types we accept to generate a size dimen for. Tokens of type that are not in this | ||
// list will not be generated. | ||
const validSizeTokenTypes = { | ||
'borderWidth': { "unit": "dp" }, | ||
'borderRadius': { "unit": "dp" }, | ||
'lineHeights': { "unit": "sp" }, | ||
'fontSizes': { "unit": "sp" }, | ||
'spacing': { "unit": "dp" } | ||
}; | ||
|
||
/** | ||
* Generate some sizes from the Design System such as border_radius, spacing etc. | ||
*/ | ||
module.exports = function ({ dictionary, options }) { | ||
return `<?xml version="1.0" encoding="UTF-8"?> | ||
<resources> | ||
${generateDimens(dictionary.allProperties)} | ||
</resources> | ||
`; | ||
} | ||
|
||
function generateDimens(tokens) { | ||
return "\t" + tokens.map(token => generateDimenForToken(token)).join("\n\t"); | ||
} | ||
|
||
/** | ||
* Generates a `<dimen name="{name}">{value}</dimen>` for the given {@link token}. Outputs a comment for any token type | ||
* not in {@link validSizeTokenTypes}. | ||
*/ | ||
function generateDimenForToken(token) { | ||
const validTypes = Object.keys(validSizeTokenTypes); | ||
|
||
if (!validTypes.includes(token.type)) return `<!-- Ignoring token of type '${token.type}' -->`; | ||
console.log(`token: ${JSON.stringify(token, null, 4)}`); | ||
return `<dimen name="${token.name}">${token.value}${validSizeTokenTypes[token.type].unit}</dimen> <!-- type: ${token.type} -->` | ||
} |