From 461dca620574d20ea3d4f3658dd1b861afb41b07 Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Fri, 20 Dec 2024 15:08:49 -0500 Subject: [PATCH] add iconography to documentation live preview (#1290) --- assets/icon-font.woff | Bin 1448 -> 0 bytes assets/icons/README.md | 13 +++++++++ .../dark/swift-documentation-preview.svg | 6 ++++ assets/icons/dark/swift-documentation.svg | 5 ++++ assets/icons/icon-font.woff | Bin 0 -> 1980 bytes .../light/swift-documentation-preview.svg | 6 ++++ assets/icons/light/swift-documentation.svg | 5 ++++ assets/icons/swift-icon.svg | 6 ++++ package.json | 26 ++++++++++++++++-- .../DocumentationPreviewEditor.ts | 12 ++++++++ 10 files changed, 77 insertions(+), 2 deletions(-) delete mode 100644 assets/icon-font.woff create mode 100644 assets/icons/README.md create mode 100644 assets/icons/dark/swift-documentation-preview.svg create mode 100644 assets/icons/dark/swift-documentation.svg create mode 100644 assets/icons/icon-font.woff create mode 100644 assets/icons/light/swift-documentation-preview.svg create mode 100644 assets/icons/light/swift-documentation.svg create mode 100644 assets/icons/swift-icon.svg diff --git a/assets/icon-font.woff b/assets/icon-font.woff deleted file mode 100644 index 892108f5c163e7022bcf0a303ce3f6bf7bfb2cf6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1448 zcmb7E&u~;wl_{h;-&Ty zlPf}1IUsuIp*{3aKmu{#&~t?%6y;Q@|3MYOr4r}fQkidN7ZffiJnPMT?|bjfo0&K3 z_I#;Cj39w$bU@DEdbYqH%ltQ^<3y|r?4r<~gS#WuHR~3*W!M*l>K8Zf*R7V|{)8=J zh4$80HtIW!nPg8Td`1naaeeWsu+&VGjw_Uh?hbHTMpVOP?=C!A<9q5(x1igUF2TJg0n1drVW-J zPRA32ED_V9OoN#i^T=UA#uLMyC9xcWh(it{Wm+6DaWik`C$QcuGVn@U~DW{p@nHaR`z77E#9Pn1QYgVCY*NIFwGa-^@nJHjH7!-}f* zg|0 zTOUcl^LU&{`(TIh-UsOqnGv8He&+j?_bw8p7rvLt@4>5~kVX%Do`XN@V-@(3j|2GX zhkP6azvAOC_0zU^Z)yn4VR$^OP?Uc5F$aI%$13m(9|tH-qdpFTzwP5N=nNYC~?{A{TQF XT!l6;mgT9>AyOR5Kr6*R!YAY%$h_IK diff --git a/assets/icons/README.md b/assets/icons/README.md new file mode 100644 index 000000000..97c92a185 --- /dev/null +++ b/assets/icons/README.md @@ -0,0 +1,13 @@ +# Custom Icons for the Swift extension + +This folder contains custom iconography used in various sections of the Swift extension for VS Code. + +All icons are compiled into a single icon font using [IcoMoon](https://icomoon.io/app). The icons must be placed at the following codes within the font file: + +``` +\\E001 - swift-icon +\\E002 - swift-documentation +\\E003 - swift-documentation-preview +``` + +Any newly added icons will need to be added to the icons contribution point in the [package.json](../../package.json) for them to be usable from within the extension. \ No newline at end of file diff --git a/assets/icons/dark/swift-documentation-preview.svg b/assets/icons/dark/swift-documentation-preview.svg new file mode 100644 index 000000000..db9c8b4f2 --- /dev/null +++ b/assets/icons/dark/swift-documentation-preview.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/icons/dark/swift-documentation.svg b/assets/icons/dark/swift-documentation.svg new file mode 100644 index 000000000..9526fdcc3 --- /dev/null +++ b/assets/icons/dark/swift-documentation.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/icons/icon-font.woff b/assets/icons/icon-font.woff new file mode 100644 index 0000000000000000000000000000000000000000..4b3ccc61781c27aa6553a65755627c03992bf946 GIT binary patch literal 1980 zcmb7FO>7%Q6n<}KfBd($8{4~4;-*_WStn_|i5>r>X-G{~EP@o3mi{6Ya1zIf8rvap zlSV=!;=rY#azLt(IQ0TTq6aD=4n0_?LLeb=H7!rk}r)Cz%FC$P8&*$glu9@T^~!Vq6(on**K2V z%)R0u!z8Uf+9`>C2-Ys^{N3pg2ZT{z>^!lU8zBrdAs~5$cowP*R9ONjo)V@17ssAa z>;;2iita=q39{%|1)f>z-FBS@?}-&dV|;~kbr+&p`BCY(rI%VeBrDw>}<)ta2l#6v+01_y$J#);H$`RLJD zUqDA)@0DaZ=6zd_M$hN-dD?3_u}+)SX`lRHLX!5XU@C^DsHq{lNT@jED*G|+S{BaP z_TEFw+Iwi*8kUJDr_y_EL8Skqvzn*8>p+ z8AH_4$1yw@MJ9!r%tHPCK#$5~M0F&NilZM1sO*Q;wm4ejY89&ZP|n#a)5)8kWo^3f3mQD#ac;O`F&73mW2my6_= zrO}CZL(_kPUnTlFK(96yT+Y^}tb|1sTT>(527 zK8V5qd>%| zRx9gpk&4u)&sC_v`e6dg%|^?rRU6gyN~^kP&2L+?3(dJ^v*AElG}@w8Ym~Ji+OI&1 b) + + + + + diff --git a/assets/icons/light/swift-documentation.svg b/assets/icons/light/swift-documentation.svg new file mode 100644 index 000000000..abe9264d1 --- /dev/null +++ b/assets/icons/light/swift-documentation.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/icons/swift-icon.svg b/assets/icons/swift-icon.svg new file mode 100644 index 000000000..89d4c36d6 --- /dev/null +++ b/assets/icons/swift-icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/package.json b/package.json index 8713558c2..a1def11ac 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,23 @@ "swift-icon": { "description": "The official icon for the Swift programming language", "default": { - "fontPath": "assets/icon-font.woff", + "fontPath": "assets/icons/icon-font.woff", "fontCharacter": "\\E001" } + }, + "swift-documentation": { + "description": "The icon for the Swift documentation preview editor", + "default": { + "fontPath": "assets/icons/icon-font.woff", + "fontCharacter": "\\E002" + } + }, + "swift-documentation-preview": { + "description": "The icon used as a button for showing the Swift documentation preview editor", + "default": { + "fontPath": "assets/icons/icon-font.woff", + "fontCharacter": "\\E003" + } } }, "terminal": { @@ -88,7 +102,8 @@ { "command": "swift.previewDocumentation", "title": "Preview Documentation", - "category": "Swift" + "category": "Swift", + "icon": "$(swift-documentation-preview)" }, { "command": "swift.createNewProject", @@ -779,6 +794,13 @@ "submenu": "swift.editor" } ], + "editor/title": [ + { + "command": "swift.previewDocumentation", + "when": "swift.supportsDocumentationLivePreview && (editorLangId == markdown || editorLangId == tutorial || editorLangId == swift)", + "group": "navigation" + } + ], "swift.editor": [ { "command": "swift.run", diff --git a/src/documentation/DocumentationPreviewEditor.ts b/src/documentation/DocumentationPreviewEditor.ts index 25dcc52c9..e42c1d998 100644 --- a/src/documentation/DocumentationPreviewEditor.ts +++ b/src/documentation/DocumentationPreviewEditor.ts @@ -48,6 +48,18 @@ export class DocumentationPreviewEditor implements vscode.Disposable { ], } ); + webviewPanel.iconPath = { + light: vscode.Uri.file( + extension.asAbsolutePath( + path.join("assets", "icons", "light", "swift-documentation.svg") + ) + ), + dark: vscode.Uri.file( + extension.asAbsolutePath( + path.join("assets", "icons", "dark", "swift-documentation.svg") + ) + ), + }; const webviewBaseURI = webviewPanel.webview.asWebviewUri( vscode.Uri.file(swiftDoccRenderPath) );