提交 b9478c2d 编写于 作者: J Johannes Rieken

deco - make letter be a after-pseudo element

上级 a7b743e0
...@@ -28,7 +28,6 @@ export interface IIconLabelOptions { ...@@ -28,7 +28,6 @@ export interface IIconLabelOptions {
extraClasses?: string[]; extraClasses?: string[];
italic?: boolean; italic?: boolean;
matches?: IMatch[]; matches?: IMatch[];
badge?: ILabelBadgeOptions;
} }
class FastLabelNode { class FastLabelNode {
...@@ -90,7 +89,6 @@ export class IconLabel { ...@@ -90,7 +89,6 @@ export class IconLabel {
private domNode: FastLabelNode; private domNode: FastLabelNode;
private labelNode: FastLabelNode | HighlightedLabel; private labelNode: FastLabelNode | HighlightedLabel;
private descriptionNode: FastLabelNode; private descriptionNode: FastLabelNode;
private badgeNode: HTMLSpanElement;
constructor(container: HTMLElement, options?: IIconLabelCreationOptions) { constructor(container: HTMLElement, options?: IIconLabelCreationOptions) {
this.domNode = new FastLabelNode(dom.append(container, dom.$('.monaco-icon-label'))); this.domNode = new FastLabelNode(dom.append(container, dom.$('.monaco-icon-label')));
...@@ -148,20 +146,6 @@ export class IconLabel { ...@@ -148,20 +146,6 @@ export class IconLabel {
this.descriptionNode.textContent = description || ''; this.descriptionNode.textContent = description || '';
this.descriptionNode.empty = !description; this.descriptionNode.empty = !description;
if (options && options.badge) {
if (!this.badgeNode) {
this.badgeNode = document.createElement('span');
this.element.style.display = 'flex';
this.element.appendChild(this.badgeNode);
}
this.badgeNode.title = options.badge.title;
this.badgeNode.className = `label-badge ${options.badge.className}`;
dom.show(this.badgeNode);
} else if (this.badgeNode) {
dom.hide(this.badgeNode);
}
} }
public dispose(): void { public dispose(): void {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/* ---------- Icon label ---------- */ /* ---------- Icon label ---------- */
.monaco-icon-label { .monaco-icon-label {
display: inline-block; /* required for icons support :before rule */ display: flex; /* required for icons support :before rule */
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
...@@ -44,15 +44,11 @@ ...@@ -44,15 +44,11 @@
font-style: italic; font-style: italic;
} }
.monaco-icon-label > .label-badge { .monaco-icon-label::after {
align-self: center; flex: 1;
height: 12px; opacity: 0.75;
min-width: 10px;
line-height: 125%;
font-size: 90%; font-size: 90%;
margin: 1px 15px 1px auto; font-weight: 600;
padding: 2px 3px; text-align: right;
border-radius: 5px; padding: 0 15px 0 5px;
font-weight: 500;
text-align: center;
} }
...@@ -202,15 +202,16 @@ export class ResourceLabel extends IconLabel { ...@@ -202,15 +202,16 @@ export class ResourceLabel extends IconLabel {
this.options.fileKind !== FileKind.FILE this.options.fileKind !== FileKind.FILE
); );
if (deco && this.options.fileDecorations.colors) { if (deco) {
iconLabelOptions.extraClasses.push(deco.labelClassName); if (deco.title) {
} iconLabelOptions.title = `${deco.title}, ${iconLabelOptions.title}`;
}
if (deco && deco.badgeClassName && this.options.fileDecorations.badges) { if (this.options.fileDecorations.colors) {
iconLabelOptions.badge = { iconLabelOptions.extraClasses.push(deco.labelClassName);
title: deco.title, }
className: deco.badgeClassName, if (this.options.fileDecorations.badges) {
}; iconLabelOptions.extraClasses.push(deco.badgeClassName);
}
} }
} }
......
...@@ -54,7 +54,7 @@ class DecorationRule { ...@@ -54,7 +54,7 @@ class DecorationRule {
createCSSRule(`.focused .selected .${this.labelClassName}`, `color: inherit;`, element); createCSSRule(`.focused .selected .${this.labelClassName}`, `color: inherit;`, element);
// letter // letter
if (letter) { if (letter) {
createCSSRule(`.${this.badgeClassName}::before`, `content: "${letter}"`, element); createCSSRule(`.${this.badgeClassName}::after`, `content: "${letter}";`, element);
} }
} }
...@@ -62,14 +62,11 @@ class DecorationRule { ...@@ -62,14 +62,11 @@ class DecorationRule {
// label // label
const { color } = data[0]; const { color } = data[0];
createCSSRule(`.${this.labelClassName}`, `color: ${theme.getColor(color) || 'inherit'};`, element); createCSSRule(`.${this.labelClassName}`, `color: ${theme.getColor(color) || 'inherit'};`, element);
createCSSRule(`.focused .selected .${this.labelClassName}`, `color: inherit; opacity: inherit;`, element); createCSSRule(`.focused .selected .${this.labelClassName}`, `color: inherit;`, element);
// badge // badge
let letters: string[] = []; let content = data.map(d => d.letter).join(', ');
for (const deco of data) { createCSSRule(`.${this.badgeClassName}::after`, `content: "${content}";`, element);
letters.push(deco.letter);
}
createCSSRule(`.${this.badgeClassName}::before`, `content: "${letters.join(', ')}"`, element);
} }
removeCSSRules(element: HTMLStyleElement): void { removeCSSRules(element: HTMLStyleElement): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册