File tree 5 files changed +78
-3
lines changed
5 files changed +78
-3
lines changed Original file line number Diff line number Diff line change 1
1
# CODING Toolkit Sketch Plugin
2
2
3
- <img src =' https://user-images.githubusercontent.com/5106039/80296781-61060600-87b0 -11ea-8dd4-d9a15d29d9cd .png ' width =' 674px ' >
3
+ <img src =' https://user-images.githubusercontent.com/5106039/80345374-9c313380-889b -11ea-9686-2e3d2d6ee4ac .png ' width =' 839px ' >
4
4
5
5
## 插件命令
6
+ Dev Library 分类中的命令主要用于开发 Sketch Library 时使用。
6
7
7
8
### 1. Update Icon 升级图标
8
9
用于替换旧版 CODING Icon 至新版 CODING Icon,在设计稿中选中来自旧版的 CODING Icon Library 的 symbol 然后执行此命令即可自动替换为对应的新版 CODING ICON,并且保留原来 icon 覆盖的颜色。
11
12
用与在 CODING Icon Library 文件中修改或添加 icon 后重新生成 icon 集合,以便在 Abstract 中查找 icon。执行此命令将会自动删除原 Page 1 中的 icon collection 画板然后重新生成新的画板。
12
13
更新 CODING Icon 的具体方法请查看此 [ Wiki] ( https://codingcorp.coding.net/p/Design-Center/wiki/1495 )
13
14
15
+ ### 3. Create Symbol Instance 通过选中的 Symbol Master 创建 Instance
16
+ 选中一个或多个 Symbol Master 后执行此命令,可自动在 Symbol Master 下方创建对应的 instance,用于快速预览和检查 Symbol Master 的使用效果与 Overrides 配置。
17
+
14
18
## Installation
15
19
16
20
- [ Download] ( ../../releases/latest/download/coding-toolkit.sketchplugin.zip ) the latest release of the plugin
Original file line number Diff line number Diff line change
1
+ import sketch from 'sketch'
2
+
3
+ export default function ( ) {
4
+ const document = sketch . getSelectedDocument ( )
5
+ const selection = document . selectedLayers . layers
6
+ const SymbolInstance = sketch . SymbolInstance
7
+
8
+ const currentPage = document . selectedPage
9
+ const notSymbolArrary = [ ]
10
+
11
+ // Create symbol instance under selected symbol
12
+ selection . map ( symbolMaster => {
13
+ if ( symbolMaster . symbolId ) {
14
+ let instance = new SymbolInstance ( {
15
+ name : symbolMaster . name ,
16
+ parent : currentPage ,
17
+ frame : symbolMaster . frame ,
18
+ symbolId : symbolMaster . symbolId ,
19
+ } )
20
+ instance . frame . y = instance . frame . y + instance . frame . height
21
+ } else {
22
+ notSymbolArrary . push ( symbolMaster . name )
23
+ }
24
+ } )
25
+
26
+ // Show the layers which not symbol
27
+ if ( notSymbolArrary . length > 0 ) {
28
+ sketch . UI . message ( `‼️ Error: Layer '${ notSymbolArrary . join ( ', ' ) } ' not a symbol !` )
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ import sketch from 'sketch'
2
+
3
+ export default function ( ) {
4
+ const document = sketch . getSelectedDocument ( )
5
+ const selection = document . selectedLayers . layers
6
+ const SymbolInstance = sketch . SymbolInstance
7
+
8
+ const currentPage = document . selectedPage
9
+ const notSymbolArrary = [ ]
10
+
11
+ // Create symbol instance under selected symbol
12
+ selection . map ( symbolMaster => {
13
+ if ( symbolMaster . symbolId ) {
14
+ let instance = new SymbolInstance ( {
15
+ name : symbolMaster . name ,
16
+ parent : currentPage ,
17
+ frame : symbolMaster . frame ,
18
+ symbolId : symbolMaster . symbolId ,
19
+ } )
20
+ instance . frame . y = instance . frame . y + instance . frame . height
21
+ } else {
22
+ notSymbolArrary . push ( symbolMaster . name )
23
+ }
24
+ } )
25
+
26
+ // Show the layers which not symbol
27
+ if ( notSymbolArrary . length > 0 ) {
28
+ sketch . UI . message ( `‼️ Error: '${ notSymbolArrary . join ( ', ' ) } ' is not a symbol !` )
29
+ }
30
+ }
File renamed without changes.
Original file line number Diff line number Diff line change 10
10
{
11
11
"name" : " Generate Icon Library Collection" ,
12
12
"identifier" : " coding-toolkit.generate-icons-collection" ,
13
- "script" : " ./generate-icons-collection.js"
13
+ "script" : " ./dev-library/generate-icons-collection.js"
14
+ },
15
+ {
16
+ "name" : " Create Symbol Instance" ,
17
+ "identifier" : " coding-toolkit.create-symbol-instance" ,
18
+ "script" : " ./dev-library/create-symbol-instance.js"
14
19
}
15
20
],
16
21
"menu" : {
17
22
"title" : " 🐤 CODING Toolkit" ,
18
23
"items" : [
19
24
" coding-toolkit.update-icon" ,
20
- " coding-toolkit.generate-icons-collection"
25
+ {
26
+ "title" : " Dev Library" ,
27
+ "items" : [
28
+ " coding-toolkit.generate-icons-collection" ,
29
+ " coding-toolkit.create-symbol-instance"
30
+ ]
31
+ }
21
32
]
22
33
}
23
34
}
You can’t perform that action at this time.
0 commit comments