Skip to content

Commit 5b855dc

Browse files
feat: auto fit and adjust lint
1 parent 892f52e commit 5b855dc

5 files changed

Lines changed: 56 additions & 37 deletions

File tree

eslint.config.mjs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
import typescriptEslint from "@typescript-eslint/eslint-plugin";
22
import tsParser from "@typescript-eslint/parser";
33

4-
export default [{
4+
export default [
5+
{
56
files: ["**/*.ts"],
6-
}, {
7+
},
8+
{
9+
ignores: ["**/templates/**"],
10+
},
11+
{
712
plugins: {
8-
"@typescript-eslint": typescriptEslint,
13+
"@typescript-eslint": typescriptEslint,
914
},
1015

1116
languageOptions: {
12-
parser: tsParser,
13-
ecmaVersion: 2022,
14-
sourceType: "module",
17+
parser: tsParser,
18+
ecmaVersion: 2022,
19+
sourceType: "module",
1520
},
1621

1722
rules: {
18-
"@typescript-eslint/naming-convention": ["warn", {
19-
selector: "import",
20-
format: ["camelCase", "PascalCase"],
21-
}],
23+
"@typescript-eslint/naming-convention": [
24+
"warn",
25+
{
26+
selector: "import",
27+
format: ["camelCase", "PascalCase"],
28+
},
29+
],
2230

23-
curly: "warn",
24-
eqeqeq: "warn",
25-
"no-throw-literal": "warn",
26-
semi: "warn",
31+
curly: "warn",
32+
eqeqeq: "warn",
33+
"no-throw-literal": "warn",
34+
semi: "warn",
2735
},
28-
}];
36+
},
37+
];

src/previewPanel.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export class AndroidVectorDrawablePreviewPanel {
8787

8888
public update(document: vscode.TextDocument) {
8989
this._document = document;
90-
this._panel.title = `Preview: ${document.fileName.split("/").pop()}`;
90+
91+
// Show relative path if a folder is opened, otherwise just the filename
92+
const displayPath = vscode.workspace.workspaceFolders
93+
? vscode.workspace.asRelativePath(document.uri)
94+
: path.basename(document.fileName);
95+
96+
this._panel.title = `Preview: ${displayPath}`;
9197
this._panel.webview.html = this._getHtmlForWebview(document);
9298
}
9399

src/templates/scripts/preview.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ function zoomOut() {
108108

109109
function resetZoom() {
110110
// Calculate zoom to fit the container (with minimal padding)
111-
const containerWidth = previewContainer.clientWidth - 40;
112-
const containerHeight = previewContainer.clientHeight - 40;
111+
const containerWidth = previewContainer.clientWidth - 80;
112+
const containerHeight = previewContainer.clientHeight - 80;
113113

114114
const scaleX = containerWidth / baseWidth;
115115
const scaleY = containerHeight / baseHeight;
116116

117-
// Allow upscaling for small images, cap at 5x for very small icons
117+
// Use the min dimension for default size
118118
currentZoom = Math.min(scaleX, scaleY, maxZoom);
119119
applyZoom();
120120
}
@@ -148,9 +148,9 @@ function updateRulers() {
148148
// Determine tick interval based on zoom level
149149
let interval = 5;
150150

151-
if (currentZoom > 8) {
151+
if (currentZoom > 10) {
152152
interval = 2;
153-
} else if (currentZoom > 4) {
153+
} else if (currentZoom > 5) {
154154
interval = 5;
155155
} else if (currentZoom > 2) {
156156
interval = 10;
@@ -243,3 +243,8 @@ document.addEventListener('keydown', (e) => {
243243
resetZoom();
244244
}
245245
});
246+
247+
// Handle window resize to update rulers
248+
window.addEventListener('resize', () => {
249+
updateRulers();
250+
});

tsconfig.json

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
{
2-
"compilerOptions": {
3-
"module": "Node16",
4-
"target": "ES2022",
5-
"outDir": "out",
6-
"lib": [
7-
"ES2022"
8-
],
9-
"sourceMap": true,
10-
"rootDir": "src",
11-
"strict": true, /* enable all strict type-checking options */
12-
/* Additional Checks */
13-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
14-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
15-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
16-
}
2+
"compilerOptions": {
3+
"module": "Node16",
4+
"target": "ES2022",
5+
"outDir": "out",
6+
"lib": ["ES2022"],
7+
"sourceMap": true,
8+
"rootDir": "src",
9+
"strict": true /* enable all strict type-checking options */
10+
/* Additional Checks */
11+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
12+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
13+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
14+
},
15+
"exclude": ["src/templates/**"]
1716
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@
615615
resolved "https://registry.yarnpkg.com/@types/sarif/-/sarif-2.1.7.tgz#dab4d16ba7568e9846c454a8764f33c5d98e5524"
616616
integrity sha512-kRz0VEkJqWLf1LLVN4pT1cg1Z9wAuvI6L97V3m2f5B76Tg8d413ddvLBPTEHAZJlnn4XSvu0FkZtViCQGVyrXQ==
617617

618-
"@types/vscode@^1.104.0":
618+
"@types/vscode@^1.80.0":
619619
version "1.104.0"
620620
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.104.0.tgz#6e4d041d1ff5722db72c688518b330fcfb6fc658"
621621
integrity sha512-0KwoU2rZ2ecsTGFxo4K1+f+AErRsYW0fsp6A0zufzGuhyczc2IoKqYqcwXidKXmy2u8YB2GsYsOtiI9Izx3Tig==

0 commit comments

Comments
 (0)