Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show number in the badge #195744

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 6 additions & 21 deletions src/vs/workbench/browser/parts/compositeBarActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { toDisposable, DisposableStore, disposeIfDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IThemeService, IColorTheme } from 'vs/platform/theme/common/themeService';
import { TextBadge, NumberBadge, IBadge, IActivity, IconBadge, ProgressBadge } from 'vs/workbench/services/activity/common/activity';
import { NumberBadge, IBadge, IActivity, ProgressBadge } from 'vs/workbench/services/activity/common/activity';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { DelayedDragHandler } from 'vs/base/browser/dnd';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
Expand Down Expand Up @@ -314,15 +314,15 @@ export class CompoisteBarActionViewItem extends BaseActionViewItem {
classes.push('progress-badge');
}

else if (this.options.compact) {
show(this.badge);
}

// Number
else if (badge instanceof NumberBadge) {
if (badge.number) {
let number = badge.number.toString();
if (badge.number > 999) {
if (this.options.compact) {
if (badge.number > 99) {
number = '';
}
} else if (badge.number > 999) {
const noOfThousands = badge.number / 1000;
const floor = Math.floor(noOfThousands);
if (noOfThousands > floor) {
Expand All @@ -336,19 +336,6 @@ export class CompoisteBarActionViewItem extends BaseActionViewItem {
}
}

// Text
else if (badge instanceof TextBadge) {
this.badgeContent.textContent = badge.text;
show(this.badge);
}

// Icon
else if (badge instanceof IconBadge) {
const clazzList = ThemeIcon.asClassNameArray(badge.icon);
this.badgeContent.classList.add(...clazzList);
show(this.badge);
}

if (classes.length) {
this.badge.classList.add(...classes);
this.badgeDisposable.value = toDisposable(() => this.badge.classList.remove(...classes));
Expand Down Expand Up @@ -518,8 +505,6 @@ export class CompositeOverflowActivityActionViewItem extends CompoisteBarActionV
let suffix: string | number | undefined;
if (badge instanceof NumberBadge) {
suffix = badge.number;
} else if (badge instanceof TextBadge) {
suffix = badge.text;
}

if (suffix) {
Expand Down
12 changes: 6 additions & 6 deletions src/vs/workbench/browser/parts/media/paneCompositePart.css
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,20 @@
.monaco-workbench .pane-composite-part > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.icon .badge.compact .badge-content {
position: absolute;
top: 13px;
right: 2px;
right: 0px;
font-size: 9px;
font-weight: 600;
min-width: 10px;
min-width: 12px;
height: 10px;
padding: 0 4px;
padding: 0 2px;
border-radius: 16px;
text-align: center;
}

.monaco-workbench .pane-composite-part > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .action-item.icon .badge.compact.progress-badge .badge-content::before {
mask-size: 10px;
-webkit-mask-size: 10px;
top: 4px;
mask-size: 12px;
-webkit-mask-size: 12px;
top: 2px;
}

/* active item indicator */
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@
}

.monaco-workbench .part.titlebar > .titlebar-container > .titlebar-right > .global-actions-container .monaco-action-bar .action-item.icon .badge.compact .badge-content::before {
mask-size: 10px;
-webkit-mask-size: 10px;
top: 4px;
mask-size: 12px;
-webkit-mask-size: 12px;
top: 2px;
}

.monaco-workbench .part.titlebar > .titlebar-container > .titlebar-right > .global-actions-container .monaco-action-bar .action-item.icon .badge.compact .badge-content {
Expand All @@ -448,10 +448,10 @@
right: 0px;
font-size: 9px;
font-weight: 600;
min-width: 10px;
min-width: 12px;
height: 10px;
line-height: 10px;
padding: 0 4px;
padding: 0 2px;
border-radius: 16px;
text-align: center;
}
Expand Down
7 changes: 0 additions & 7 deletions src/vs/workbench/services/activity/common/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ export class NumberBadge extends BaseBadge {
}
}

export class TextBadge extends BaseBadge {

constructor(readonly text: string, descriptorFn: () => string) {
super(descriptorFn);
}
}

export class IconBadge extends BaseBadge {
constructor(readonly icon: ThemeIcon, descriptorFn: () => string) {
super(descriptorFn);
Expand Down