mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
proper icon rendering (#7337)
* proper icon rendering * address comments
This commit is contained in:
@@ -11,8 +11,7 @@ import { Event, Emitter } from 'vs/base/common/event';
|
|||||||
import { deepClone } from 'vs/base/common/objects';
|
import { deepClone } from 'vs/base/common/objects';
|
||||||
|
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as path from 'vs/base/common/path';
|
import * as resources from 'vs/base/common/resources';
|
||||||
import { URI } from 'vs/base/common/uri';
|
|
||||||
|
|
||||||
export interface ConnectionProviderProperties {
|
export interface ConnectionProviderProperties {
|
||||||
providerId: string;
|
providerId: string;
|
||||||
@@ -180,24 +179,24 @@ ExtensionsRegistry.registerExtensionPoint<ConnectionProviderProperties | Connect
|
|||||||
function resolveIconPath(extension: IExtensionPointUser<any>): void {
|
function resolveIconPath(extension: IExtensionPointUser<any>): void {
|
||||||
if (!extension || !extension.value) { return undefined; }
|
if (!extension || !extension.value) { return undefined; }
|
||||||
|
|
||||||
let toAbsolutePath = (iconPath: any, baseDir: string) => {
|
let toAbsolutePath = (iconPath: any) => {
|
||||||
if (!iconPath || !baseDir) { return; }
|
if (!iconPath || !baseDir) { return; }
|
||||||
if (Array.isArray(iconPath)) {
|
if (Array.isArray(iconPath)) {
|
||||||
for (let e of iconPath) {
|
for (let e of iconPath) {
|
||||||
e.path = {
|
e.path = {
|
||||||
light: URI.file(path.join(baseDir, e.path.light)),
|
light: resources.joinPath(extension.description.extensionLocation, e.path.light),
|
||||||
dark: URI.file(path.join(baseDir, e.path.dark))
|
dark: resources.joinPath(extension.description.extensionLocation, e.path.dark)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else if (typeof iconPath === 'string') {
|
} else if (typeof iconPath === 'string') {
|
||||||
iconPath = {
|
iconPath = {
|
||||||
light: URI.file(path.join(baseDir, iconPath)),
|
light: resources.joinPath(extension.description.extensionLocation, iconPath),
|
||||||
dark: URI.file(path.join(baseDir, iconPath))
|
dark: resources.joinPath(extension.description.extensionLocation, iconPath)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
iconPath = {
|
iconPath = {
|
||||||
light: URI.file(path.join(baseDir, iconPath.light)),
|
light: resources.joinPath(extension.description.extensionLocation, iconPath.light),
|
||||||
dark: URI.file(path.join(baseDir, iconPath.dark))
|
dark: resources.joinPath(extension.description.extensionLocation, iconPath.dark)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -206,9 +205,9 @@ function resolveIconPath(extension: IExtensionPointUser<any>): void {
|
|||||||
let properties: ConnectionProviderProperties = extension.value;
|
let properties: ConnectionProviderProperties = extension.value;
|
||||||
if (Array.isArray<ConnectionProviderProperties>(properties)) {
|
if (Array.isArray<ConnectionProviderProperties>(properties)) {
|
||||||
for (let p of properties) {
|
for (let p of properties) {
|
||||||
toAbsolutePath(p['iconPath'], baseDir);
|
toAbsolutePath(p['iconPath']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toAbsolutePath(properties['iconPath'], baseDir);
|
toAbsolutePath(properties['iconPath']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { createCSSRule } from 'vs/base/browser/dom';
|
import { createCSSRule, asCSSUrl } from 'vs/base/browser/dom';
|
||||||
import { hash } from 'vs/base/common/hash';
|
import { hash } from 'vs/base/common/hash';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@ class IconRenderer {
|
|||||||
let iconPath: IconPath = this.toIconPath(path);
|
let iconPath: IconPath = this.toIconPath(path);
|
||||||
let iconUid: string = this.getIconUid(iconPath);
|
let iconUid: string = this.getIconUid(iconPath);
|
||||||
if (!this.iconRegistered.has(iconUid)) {
|
if (!this.iconRegistered.has(iconUid)) {
|
||||||
createCSSRule(`.icon#${iconUid}`, `background: url("${iconPath.light.toString()}") center center no-repeat`);
|
createCSSRule(`.icon#${iconUid}`, `background: ${asCSSUrl(iconPath.light || iconPath.dark)} center center no-repeat`);
|
||||||
createCSSRule(`.vs-dark .icon#${iconUid}, .hc-black .icon#${iconUid}`, `background: url("${iconPath.dark.toString()}") center center no-repeat`);
|
createCSSRule(`.vs-dark .icon#${iconUid}, .hc-black .icon#${iconUid}`, `background: ${asCSSUrl(iconPath.dark)} center center no-repeat`);
|
||||||
this.iconRegistered.add(iconUid);
|
this.iconRegistered.add(iconUid);
|
||||||
}
|
}
|
||||||
return iconUid;
|
return iconUid;
|
||||||
|
|||||||
Reference in New Issue
Block a user