Skip to content

Commit 2eb8488

Browse files
feat(widget): alinha botão de ações verticalmente quando tag-position é top
1 parent c59c5f4 commit 2eb8488

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

projects/ui/src/lib/components/po-widget/po-widget.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333

3434
<div class="po-widget-container__content">
3535
@if (hasTitleHelpOrSetting()) {
36-
<div class="po-widget-header">
36+
<div
37+
class="po-widget-header"
38+
[class.po-widget-header--tag-top-actions]="tagLabel && tagPosition() === 'top' && actions?.length"
39+
>
3740
@if (tagLabel && tagPosition() === 'top') {
3841
<div class="po-widget-header__tag-top">
3942
<ng-template [ngTemplateOutlet]="tag"></ng-template>

projects/ui/src/lib/components/po-widget/po-widget.component.spec.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,46 @@ describe('PoWidgetComponent with title and actions', () => {
928928
expect(footer).toBeFalsy();
929929
});
930930

931+
it('should add `po-widget-header--tag-top-actions` class when tagLabel, tagPosition is top and actions exist', () => {
932+
component.tagLabel = 'Sales';
933+
fixture.componentRef.setInput('p-tag-position', 'top');
934+
component.actions = [{ label: 'Test' }];
935+
936+
fixture.detectChanges();
937+
938+
expect(nativeElement.querySelector('.po-widget-header--tag-top-actions')).toBeTruthy();
939+
});
940+
941+
it('should not add `po-widget-header--tag-top-actions` class when tagPosition is not top', () => {
942+
component.tagLabel = 'Sales';
943+
fixture.componentRef.setInput('p-tag-position', 'right');
944+
component.actions = [{ label: 'Test' }];
945+
946+
fixture.detectChanges();
947+
948+
expect(nativeElement.querySelector('.po-widget-header--tag-top-actions')).toBeFalsy();
949+
});
950+
951+
it('should not add `po-widget-header--tag-top-actions` class when there are no actions', () => {
952+
component.tagLabel = 'Sales';
953+
fixture.componentRef.setInput('p-tag-position', 'top');
954+
component.actions = [];
955+
956+
fixture.detectChanges();
957+
958+
expect(nativeElement.querySelector('.po-widget-header--tag-top-actions')).toBeFalsy();
959+
});
960+
961+
it('should not add `po-widget-header--tag-top-actions` class when there is no tagLabel', () => {
962+
component.tagLabel = undefined;
963+
fixture.componentRef.setInput('p-tag-position', 'top');
964+
component.actions = [{ label: 'Test' }];
965+
966+
fixture.detectChanges();
967+
968+
expect(nativeElement.querySelector('.po-widget-header--tag-top-actions')).toBeFalsy();
969+
});
970+
931971
it('should find .po-widget-disabled if disabled is true', () => {
932972
component.disabled = true;
933973

0 commit comments

Comments
 (0)