Skip to content

Commit

Permalink
add iconography to documentation live preview (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbastien authored Dec 20, 2024
1 parent ea16da0 commit 461dca6
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 2 deletions.
Binary file removed assets/icon-font.woff
Binary file not shown.
13 changes: 13 additions & 0 deletions assets/icons/README.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions assets/icons/dark/swift-documentation-preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/icons/dark/swift-documentation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon-font.woff
Binary file not shown.
6 changes: 6 additions & 0 deletions assets/icons/light/swift-documentation-preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/icons/light/swift-documentation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/swift-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 24 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -88,7 +102,8 @@
{
"command": "swift.previewDocumentation",
"title": "Preview Documentation",
"category": "Swift"
"category": "Swift",
"icon": "$(swift-documentation-preview)"
},
{
"command": "swift.createNewProject",
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions src/documentation/DocumentationPreviewEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down

0 comments on commit 461dca6

Please sign in to comment.