From 803b3df8ef04ca295723711cf87c5c594fdb151b Mon Sep 17 00:00:00 2001 From: Thibault Maekelbergh Date: Thu, 14 Mar 2019 13:31:32 +0100 Subject: [PATCH] 3.2.0: Fix a bug where line height was parsed incorrectly --- lib/mappers/__tests__/mapper.test.js | 12 ++++++++++++ lib/mappers/textstyle.js | 5 +++-- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/mappers/__tests__/mapper.test.js b/lib/mappers/__tests__/mapper.test.js index 49c1406..2c1ec01 100644 --- a/lib/mappers/__tests__/mapper.test.js +++ b/lib/mappers/__tests__/mapper.test.js @@ -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))) }); }); diff --git a/lib/mappers/textstyle.js b/lib/mappers/textstyle.js index 74f8d94..56eac6e 100644 --- a/lib/mappers/textstyle.js +++ b/lib/mappers/textstyle.js @@ -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, } diff --git a/package-lock.json b/package-lock.json index bb5e1b9..4432d21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hubble-scripts", - "version": "3.2.0", + "version": "3.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index cf1f20a..861f7b5 100644 --- a/package.json +++ b/package.json @@ -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",