Skip to content

Commit

Permalink
Merge pull request #25 from design-ops/shared-style-on-modifier
Browse files Browse the repository at this point in the history
Shared style on modifier
  • Loading branch information
cdemetriadis authored Feb 14, 2023
2 parents 08f6dbf + 89ffb5d commit c651b4c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ This Sketch Assistant is to be used when designing theme files for the Natural D

:point_right: or **copy & paste** the following link into a new browser:

`sketch://add-assistant?url=https://github.com/design-ops/nds-sketch-theme-assistant/releases/download/v1.0.0/nds-sketch-theme-assistant-1.0.0.tgz`
`sketch://add-assistant?url=https://github.com/design-ops/nds-sketch-theme-assistant/releases/download/v1.0.2/nds-sketch-theme-assistant-1.0.2.tgz`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nds-sketch-theme-assistant",
"homepage": "https://github.com/design-ops/nds-sketch-theme-assistant",
"version": "1.0.1",
"version": "1.0.2",
"main": "dist/index.js",
"sketch": "dist/sketch.js",
"license": "MIT",
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ test('Modifier structure', async () => {
"nds-sketch-theme-assistant/modifier-structure"
)
expect(violations[0].message).toBe("'background --radius' modifier has too many (2) layers")
expect(violations[1].message).toBe("'header/background --radius' modifier requires a single layer")
expect(violations).toHaveLength(2)
expect(violations[1].message).toBe("'button/background --radius/background' layer is required to have a style attached to it")
expect(violations[2].message).toBe("'header/background --radius' modifier requires a single layer")
expect(violations).toHaveLength(3)
})

test('Sync layer styles', async () => {
Expand Down
Binary file modified src/__tests__/modifier-structure.sketch
Binary file not shown.
2 changes: 2 additions & 0 deletions src/rules/modifier-structure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

In the Natural Design System modifier symbols are used to apply styles that are not present in the style options. Any modifier used in the theme file is required to contain only one layer.

Furthermore, that single layer is required to have a Shared Style attached to it, otherwise Sketch cannot override it.

## Configuration

```js
Expand Down
8 changes: 7 additions & 1 deletion src/rules/modifier-structure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ export const modifierStructure: RuleDefinition = {
context.utils.report('\'' + symbol.name + '\' modifier requires a single layer', symbol);
}

if (numberOfLayers == 1 ) {
if (symbol.layers[0].sharedStyleID == null) {
context.utils.report('\'' + symbol.name + '/' + symbol.layers[0].name + '\' layer is required to have a style attached to it', symbol);
}
}

}
}

},
name: 'nds-sketch-theme-assistant/modifier-structure',
title: 'Modifier Structure',
description: 'Reports if a modifier has more than one or less than one layer.',
description: 'Reports if a modifier has more than one or less than one layer. Also checks if the single layer has a Shared Style.',
}

0 comments on commit c651b4c

Please sign in to comment.