Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Commit

Permalink
3.2.0: Fix a bug where line height was parsed incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
thibmaek committed Mar 14, 2019
1 parent ee9fb72 commit 803b3df
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lib/mappers/__tests__/mapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ describe('[mapper.js] test suite', () => {
expect(Object.keys(style))
.toEqual(expect.arrayContaining(['family', 'id', 'token', 'size', 'weight']));
});

const heading1 = textStyles.find(ts => ts.id === 'heading1');
expect(heading1).toMatchObject({ lineHeight: 57.6 });

const quote = textStyles.find(ts => ts.id === 'quote');
expect(quote).toMatchObject({
paragraphSpacing: 0,
kerning: 0.6,
});

const heading2 = textStyles.find(ts => ts.id === 'heading2');
expect(heading2.lineHeight).toBe(parseFloat((heading2.size * 1.2).toFixed(2)))
});
});

Expand Down
5 changes: 3 additions & 2 deletions lib/mappers/textstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ const getFontWeight = (family) => {
const getParagraphStyle = (style) => {
if (!style.paragraphStyle) return {};

const { maximumLineHeight, paragraphSpacing } = style.paragraphStyle
return {
lineHeight: style.maximumLineHeight
lineHeight: maximumLineHeight
? parseFloat(style.paragraphStyle.maximumLineHeight.toFixed(2))
: parseFloat(
(style.MSAttributedStringFontAttribute.attributes.size * 1.2).toFixed(2)
),
paragraphSpacing: style.paragraphSpacing
paragraphSpacing: paragraphSpacing
? parseFloat(style.paragraphStyle.paragraphSpacing.toFixed(2))
: 0,
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hubble-scripts",
"description": "Scripts repository to export design data like colors, fonts & text, and map them to design tokens.",
"version": "3.2.0",
"version": "3.2.1",
"homepage": "https://hubble-design-system.netlify.com",
"repository": "inthepocket/hubble-scripts",
"author": "In The Pocket",
Expand Down

0 comments on commit 803b3df

Please sign in to comment.