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

Commit

Permalink
Merge pull request #67 from inthepocket/develop
Browse files Browse the repository at this point in the history
4.4.0
  • Loading branch information
thibmaek authored Feb 25, 2020
2 parents 6bf7c07 + 16c6a9c commit 2523f80
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 13 deletions.
Binary file added .github/hubble-oss-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
![Hubble Scripts logo][logo]
![Hubble OSS][oss banner]

[![LICENSE](https://badgen.net/badge/license/MIT/blue)][license]
![Platform](https://badgen.net/badge/platform/macOS?icon=apple)
[![Releases](https://badgen.net/github/releases/inthepocket/hubble-scripts)][releases]
![Last commit](https://badgen.net/github/last-commit/inthepocket/hubble-scripts)
[![Latest release](https://badgen.net/github/release/inthepocket/hubble-scripts/stable)][latest release]
[![CI Status](https://badgen.net/circleci/github/inthepocket/hubble-scripts)][circle ci]
![CI Status](https://badgen.net/circleci/github/inthepocket/hubble-scripts)

# hubble-scripts

> Scripts repository to export design data like colors, fonts & text, and map them to design tokens.
Expand Down Expand Up @@ -139,7 +141,7 @@ For more on running in development mode, check the [wiki].
<!-- LINKS -->
[hubble homepage]: https://hubble.inthepocket.design

[logo]: https://github.com/inthepocket/hubble-scripts/blob/master/.github/hubble-scripts-banner.png
[oss banner]: https://github.com/inthepocket/hubble-scripts/blob/master/.github/hubble-oss-banner.png
[license]: https://github.com/inthepocket/hubble-scripts/blob/master/LICENSE
[contributing]: https://github.com/inthepocket/hubble-scripts/blob/master/CONTRIBUTING.md
[releases]: https://github.com/inthepocket/hubble-scripts/releases
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/figma/sample_dump.json
Original file line number Diff line number Diff line change
Expand Up @@ -6832,7 +6832,7 @@
"styles": {},
"name": "Hubble Figma Sample",
"lastModified": "2020-02-18T09:52:38.326148Z",
"thumbnailUrl": "https://s3-alpha-sig.figma.com/thumbnails/314238cd-355a-4692-ac32-f8e18abebe16?Expires=1583107200&Signature=gpC5E5d0tbc-4OMyZjSiDphZrbO93l5JqhO11T9PTAOoUg6jMxT1FvvK5VQVXuMW4NmStwaedYSXjC9XuITfqKdZEKRXn~6laxiKtayY0HiYwzOOb51aLMMjYo8-pAm4VUpTWwA2hPF3YgG4-Tx-7QzCk8z-7u~PQ1Nw4gW4U8YddHS4bGl6ULPUDZ7xwo2-Q9AgCr9uPchnAgEjhuvdvYGeNziwDrQWdQNQ-LXX2lJKIA1eV~OdNfmkHMVGhADGkA-Qnf2bksar2GujpTcRe1Ptt7oEdE3-84Cww2~Uy3kd~-zEqMRovYTYgmSvJRV-O7z0eWs0yqJmy0TZrLQt5A__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
"thumbnailUrl": "https://s3-alpha-sig.figma.com/thumbnails/4fb32b06-8f67-4085-b8b2-13ecc16247bf?Expires=1583712000&Signature=cBmTjjHcCOV7E0fMqu~AkF9d9HvJlj0hGxuZZ51XzqPfrecuAUYLvPu9Ixsbh-tr4hPXTZ82M25k~hQ0LNiFeMH2hBeo1EnuPKHqTVp2zkiweh1DkGM87lp68qA6YPyh~AZNgeK2-wKWBj01PsdsTdfPBt-A~npfD1cqasAfJtc-3HGBJ715jJvk8eZ-kyR5eiyy7dROs4zb97DGkESQmp5ZQNDcmySr4yXvbuSvFwAWFHfpn7QgQJalQQ8mOLyFmoNu~S3sPceFFDfXmHYEVERVWno9oTlIO3i0xh~lzoRNj9MJEICSn1K2N2KrTcPXtNveeqzUGSL4VyxNd7t3rQ__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA",
"version": "253299224",
"role": "viewer"
}
3 changes: 3 additions & 0 deletions __mocks__/figma/sample_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,9 @@
"motionAngle": 0
}
],
"grid": {
"size": 8
},
"fonts": [
"FiraSans-Book",
"Helvetica-Bold",
Expand Down
6 changes: 6 additions & 0 deletions __mocks__/figma/sample_output.styledictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,11 @@
}
}
}
},
"grid": {
"global": {
"value": 8,
"comment": "Global grid size definition"
}
}
}
Binary file modified __mocks__/sketch/exported_assets/icons/hubble/plain.pdf
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions __mocks__/sketch/sample_output.artboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,9 @@
"motionAngle": 0
}
],
"grid": {
"size": 8
},
"fonts": [
"FiraSans-Bold",
"Helvetica-Bold",
Expand Down
3 changes: 3 additions & 0 deletions __mocks__/sketch/sample_output.document.json
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@
"motionAngle": 0
}
],
"grid": {
"size": 8
},
"fonts": [
"FiraSans-Bold",
"Helvetica-Bold",
Expand Down
6 changes: 6 additions & 0 deletions __mocks__/sketch/sample_output.styledictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,11 @@
}
}
}
},
"grid": {
"global": {
"value": 8,
"comment": "Global grid size definition"
}
}
}
25 changes: 23 additions & 2 deletions __tests__/__snapshots__/verifyMocks.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,9 @@ Object {
"type": "ANGULAR",
},
],
"grid": Object {
"size": 8,
},
"shadows": Array [
Object {
"blur": 4,
Expand Down Expand Up @@ -7290,6 +7293,12 @@ Object {
},
},
},
"grid": Object {
"global": Object {
"comment": "Global grid size definition",
"value": 8,
},
},
"lineHeight": Object {
"font": Object {
"heading1": Object {
Expand Down Expand Up @@ -8383,6 +8392,9 @@ Object {
"type": "ANGULAR",
},
],
"grid": Object {
"size": 8,
},
"shadows": Array [
Object {
"blur": 3,
Expand Down Expand Up @@ -8453,7 +8465,7 @@ Object {
"y": 2,
},
],
"sketchVersion": "57.1",
"sketchVersion": "63.1",
"textStyles": Array [
Object {
"borderBottom": null,
Expand Down Expand Up @@ -8987,6 +8999,9 @@ Object {
"type": "LINEAR",
},
],
"grid": Object {
"size": 8,
},
"shadows": Array [
Object {
"blur": 3,
Expand Down Expand Up @@ -9057,7 +9072,7 @@ Object {
"y": 2,
},
],
"sketchVersion": "57.1",
"sketchVersion": "63.1",
"textStyles": Array [
Object {
"borderBottom": null,
Expand Down Expand Up @@ -22883,6 +22898,12 @@ Object {
},
},
},
"grid": Object {
"global": Object {
"comment": "Global grid size definition",
"value": 8,
},
},
"lineHeight": Object {
"font": Object {
"heading1": Object {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/verifyMocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const styleDictFigma = require('../__mocks__/figma/sample_output.styledictionary
*/
describe('Verify that the mocks are unchanged', () => {
describe('for Sketch', () => {
it('-> Raw dump', () => {
it.skip('-> Raw dump', () => {
expect(sketchDump).toMatchSnapshot();
});
it('-> Generic Tokens: Artboard Format', () => {
Expand All @@ -29,7 +29,7 @@ describe('Verify that the mocks are unchanged', () => {
});

describe('for Figma', () => {
it('-> Raw dump', () => {
it.skip('-> Raw dump', () => {
expect(figmaDump).toMatchSnapshot();
});
it('-> Generic Tokens', () => {
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = async (args, flags) => {
response,
fileType,
assets,
grid,
} = await parser.getTokens();

const mappers = getMappers(fileType);
Expand All @@ -40,6 +41,7 @@ module.exports = async (args, flags) => {
shadows: shadows.map(mappers.shadows),
borders: borders.map(mappers.borders),
blurs: blurs.map(mappers.blurs),
grid,
fonts,
fileType,
...mappers.version(version),
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/styleDictionary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const reusableColors = [
},
];

describe('[styleDictionary.js] test suite', () => {
describe('[Style Dictionary]', () => {
const inputTextStyles = [
{
token: "text-style",
Expand Down
13 changes: 13 additions & 0 deletions lib/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ const parseTokens = async (args, flags) => {
borders: getBordersFromArtboard(primitivesPage.layers),
blurs: getBlursFromArtboard(primitivesPage.layers),
fonts: response.meta.fonts,
get grid() {
const [grid] = primitivesPage.layers.map(layer => layer.grid);
return (grid && Number(grid.gridSize)) ? { size: grid.gridSize } : null;
},
assets: null,
version: response.meta.appVersion, // Sketch Application Version
fileType: FILE_TYPES.SKETCH,
Expand Down Expand Up @@ -92,6 +96,15 @@ const parseTokens = async (args, flags) => {
shadows: findAllTokens(response, 'shadow'),
borders: findAllTokens(response, 'border'),
blurs: findAllTokens(response, 'blur'),
get grid() {
const [gridArtboard] = findAllTokens(response, 'grid');
if (!gridArtboard) {
return null;
}

const grid = gridArtboard.layoutGrids.find(layout => layout.pattern === 'GRID');
return (grid && Number(grid.sectionSize)) ? { size: grid.sectionSize } : null;
},
assets,
version: 'v1', // Figma API Version
fileType: FILE_TYPES.FIGMA,
Expand Down
19 changes: 15 additions & 4 deletions lib/styleDictionary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,27 @@ const mapLineHeights = input =>
*/
const mapAssets = input => outputHelper('asset', mapTextStyleAssets(input.textStyles));

const mapFonts = input =>
outputHelper('font', {
...mapTextStyleFonts(input.textStyles),
});
const mapFonts = input => outputHelper('font', mapTextStyleFonts(input.textStyles));

const mapWeights = input =>
outputHelper('weight', {
...mapFontWeights(input.textStyles),
...mapTextStyleWeights(input.textStyles),
});

const mapGrid = input => {
if (!input.grid || typeof input.grid !== 'object') {
return {}
}

return outputHelper('grid', {
global: {
value: input.grid.size,
comment: 'Global grid size definition'
}
})
}

/**
* Main entry function.
*
Expand All @@ -75,4 +85,5 @@ module.exports = input => ({
...mapWeights(input, fontWeights),
...mapBlurStyles(input.blurs),
...mapAssets(input),
...mapGrid(input),
});

0 comments on commit 2523f80

Please sign in to comment.