Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

.menu-item {
@include popover-menu-item;

&.disabled {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, we really should make this a global style

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanted to do that. but there are quite a few out there. some without the cursor change. So, need to audit all of them before doing a global change.

opacity: 0.4;
cursor: not-allowed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,24 @@ describe('Menu Item Component', () => {
expect(spectator.query(IconComponent)?.icon).toBe(IconType.MoreHorizontal);
expect(spectator.query(IconComponent)?.color).toBe(Color.Gray1);
}));

test('should disable menu item as expected', fakeAsync(() => {
const spectator = createHost(
'<ht-menu-item [icon]="icon" [label]="label" [iconColor]="iconColor" [disabled]="disabled"></ht-menu-item>',
{
hostProps: {
icon: IconType.MoreHorizontal,
label: 'Item',
iconColor: Color.Gray1,
disabled: true
}
}
);
expect(spectator.query('.menu-item')).toExist();
expect(spectator.query('.icon')).toExist();
expect(spectator.query('.label')).toHaveText('Item');
expect(spectator.query(IconComponent)?.icon).toBe(IconType.MoreHorizontal);
expect(spectator.query(IconComponent)?.color).toBe(Color.Gray1);
expect(spectator.query('.menu-item')?.classList.contains('disabled')).toBe(true);
}));
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { IconSize } from '../../icon/icon-size';
selector: 'ht-menu-item',
changeDetection: ChangeDetectionStrategy.OnPush,
styleUrls: ['./menu-item.component.scss'],
template: `<div class="menu-item">
<ht-icon
class="icon"
*ngIf="this.icon"
[icon]="this.icon"
size="${IconSize.Small}"
[color]="this.iconColor"
></ht-icon>
<span class="label">{{ this.label }}</span>
</div>`
template: `<ht-event-blocker event="click" class="menu-item-container" [enabled]="this.disabled"
><div class="menu-item" [ngClass]="this.getStyleClasses()">
<ht-icon
class="icon"
*ngIf="this.icon"
[icon]="this.icon"
size="${IconSize.Small}"
[color]="this.iconColor"
></ht-icon>
<span class="label">{{ this.label }}</span>
</div></ht-event-blocker
>`
})
export class MenuItemComponent {
@Input()
Expand All @@ -26,4 +28,11 @@ export class MenuItemComponent {

@Input()
public iconColor?: string;

@Input()
public disabled?: boolean;

public getStyleClasses(): string[] {
return this.disabled ? ['disabled'] : [];
}
}