Skip to content

Commit

Permalink
fix(SharedStyle): delegate args to Shared.TextStyle properly (#85)
Browse files Browse the repository at this point in the history
fixes #84
  • Loading branch information
jorgecasar authored Jan 30, 2020
1 parent 4fc6fe2 commit 48f5db5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ module.exports = function BuildSketchWithStyles(dictionary) {
const font = dictionary.properties.component.typography[key];
sketch.addTextStyle({
name: key,
fontSize: font['font-size'].value,
color: font.color.value,
textStyle: {
fontSize: font['font-size'].value,
color: font.color.value,
},
});
});

Expand Down
3 changes: 1 addition & 2 deletions models/SharedStyle/SharedStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/

const uuid = require('uuid-v4');
const TextStyle = require('../TextStyle');
const Style = require('../Style');

class SharedStyle {
Expand All @@ -32,7 +31,7 @@ class SharedStyle {
return new SharedStyle({
name: args.name,
id,
textStyle: new TextStyle(Object.assign(args, { id })),
textStyle: args.textStyle,
});
}

Expand Down
16 changes: 16 additions & 0 deletions models/SharedStyle/SharedStyle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ describe('SharedStyle', () => {
expect(layerStyle.value.fills[0].color.red).toEqual(1);
});
});

describe('TextStyle', () => {
it('should work', () => {
const textStyle = SharedStyle.TextStyle({
name: 'test',
textStyle: {
fontName: 'Arial',
fontSize: 10,
},
});
expect(textStyle.value.textStyle.encodedAttributes.MSAttributedStringFontAttribute.attributes).toEqual({
name: 'Arial',
size: 10,
});
});
});
});

0 comments on commit 48f5db5

Please sign in to comment.