mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-06 17:23:53 -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 * as azdata from 'azdata';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
|
||||
export interface ConnectionProviderProperties {
|
||||
providerId: string;
|
||||
@@ -180,24 +179,24 @@ ExtensionsRegistry.registerExtensionPoint<ConnectionProviderProperties | Connect
|
||||
function resolveIconPath(extension: IExtensionPointUser<any>): void {
|
||||
if (!extension || !extension.value) { return undefined; }
|
||||
|
||||
let toAbsolutePath = (iconPath: any, baseDir: string) => {
|
||||
let toAbsolutePath = (iconPath: any) => {
|
||||
if (!iconPath || !baseDir) { return; }
|
||||
if (Array.isArray(iconPath)) {
|
||||
for (let e of iconPath) {
|
||||
e.path = {
|
||||
light: URI.file(path.join(baseDir, e.path.light)),
|
||||
dark: URI.file(path.join(baseDir, e.path.dark))
|
||||
light: resources.joinPath(extension.description.extensionLocation, e.path.light),
|
||||
dark: resources.joinPath(extension.description.extensionLocation, e.path.dark)
|
||||
};
|
||||
}
|
||||
} else if (typeof iconPath === 'string') {
|
||||
iconPath = {
|
||||
light: URI.file(path.join(baseDir, iconPath)),
|
||||
dark: URI.file(path.join(baseDir, iconPath))
|
||||
light: resources.joinPath(extension.description.extensionLocation, iconPath),
|
||||
dark: resources.joinPath(extension.description.extensionLocation, iconPath)
|
||||
};
|
||||
} else {
|
||||
iconPath = {
|
||||
light: URI.file(path.join(baseDir, iconPath.light)),
|
||||
dark: URI.file(path.join(baseDir, iconPath.dark))
|
||||
light: resources.joinPath(extension.description.extensionLocation, iconPath.light),
|
||||
dark: resources.joinPath(extension.description.extensionLocation, iconPath.dark)
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -206,9 +205,9 @@ function resolveIconPath(extension: IExtensionPointUser<any>): void {
|
||||
let properties: ConnectionProviderProperties = extension.value;
|
||||
if (Array.isArray<ConnectionProviderProperties>(properties)) {
|
||||
for (let p of properties) {
|
||||
toAbsolutePath(p['iconPath'], baseDir);
|
||||
toAbsolutePath(p['iconPath']);
|
||||
}
|
||||
} 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.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createCSSRule } from 'vs/base/browser/dom';
|
||||
import { createCSSRule, asCSSUrl } from 'vs/base/browser/dom';
|
||||
import { hash } from 'vs/base/common/hash';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
@@ -15,8 +15,8 @@ class IconRenderer {
|
||||
let iconPath: IconPath = this.toIconPath(path);
|
||||
let iconUid: string = this.getIconUid(iconPath);
|
||||
if (!this.iconRegistered.has(iconUid)) {
|
||||
createCSSRule(`.icon#${iconUid}`, `background: url("${iconPath.light.toString()}") center center no-repeat`);
|
||||
createCSSRule(`.vs-dark .icon#${iconUid}, .hc-black .icon#${iconUid}`, `background: url("${iconPath.dark.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: ${asCSSUrl(iconPath.dark)} center center no-repeat`);
|
||||
this.iconRegistered.add(iconUid);
|
||||
}
|
||||
return iconUid;
|
||||
|
||||
Reference in New Issue
Block a user