Skip to content

Commit c586f4e

Browse files
devin-ai-integration[bot]anabye
authored andcommitted
feat(page): adiciona tipos de header e layout de ações
Inclui propriedades `p-header-type` e `p-actions-layout`. Adiciona propriedade `kind` em `PoPageAction`. fixes DTHFUI-12541
1 parent f32ef9f commit c586f4e

17 files changed

Lines changed: 840 additions & 213 deletions

projects/portal/src/styles.css

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ html.potheme-light-AAA #logo-totvs {
1919
content: url('./assets/graphics/logo-totvs-preto.png');
2020
}
2121

22-
html.potheme-dark-AA .po-header-nav,
23-
html.potheme-dark-AAA .po-header-nav {
24-
--stroke-color: var(--color-brand-01-dark);
25-
}
26-
2722
.dot {
2823
border-radius: 50%;
2924
display: inline-block;
@@ -400,6 +395,13 @@ sample-po-menu-panel-customer .po-wrapper-menu-panel .po-toolbar {
400395
padding-right: 50px;
401396
}
402397

398+
.docs-sample-container .po-page-content {
399+
left: 0px !important;
400+
margin-top: 0px !important;
401+
position: relative !important;
402+
width: 100% !important;
403+
}
404+
403405
.docs-sample-container .po-page-bottom-container {
404406
width: calc(100% - 48px) !important;
405407
}
@@ -851,40 +853,3 @@ blockquote {
851853
display: none;
852854
}
853855
}
854-
855-
sample-po-context-menu-basic-view .docs-sample-container .po-context-menu-wrapper,
856-
sample-po-context-menu-labs-view .docs-sample-container .po-context-menu-wrapper {
857-
height: 384px !important;
858-
min-height: 384px !important;
859-
max-height: 384px !important;
860-
overflow: hidden;
861-
border: var(--border-width-sm) solid;
862-
border-color: var(--color-neutral-light-20);
863-
}
864-
865-
sample-po-context-menu-user-view .docs-sample-container {
866-
border: 1px solid #ccc;
867-
padding: 0px;
868-
}
869-
870-
sample-po-context-menu-user-view .docs-sample-container .po-context-menu-wrapper {
871-
height: 384px !important;
872-
min-height: 384px !important;
873-
max-height: 384px !important;
874-
overflow: hidden;
875-
}
876-
877-
sample-po-context-menu-user-view po-context-tabs .po-tabs-container {
878-
margin-left: 0 !important;
879-
margin-right: 0 !important;
880-
}
881-
882-
sample-po-context-menu-user-view .docs-sample-container .po-page {
883-
height: 100% !important;
884-
}
885-
886-
sample-po-context-menu-user-view .docs-sample-container .po-page .po-page-content {
887-
height: auto !important;
888-
min-height: 0;
889-
overflow-y: auto;
890-
}

projects/ui/src/lib/components/po-icon/po-icon-dictionary.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const AnimaliaIconDictionary: { [key: string]: string } = {
66
ICON_ALIGN_LEFT: 'an an-text-align-left',
77
ICON_ALIGN_RIGHT: 'an an-text-align-right',
88
ICON_ARROW_ARC_LEFT: 'an an-arrow-arc-left',
9+
ICON_ARROW_BACK: 'an an-arrow-left',
910
ICON_ARROW_DOWN: 'an an-caret-down',
1011
ICON_OTHER_ARROW_DOWN: 'an an-arrow-down',
1112
ICON_ARROW_LEFT: 'an an-caret-left',

projects/ui/src/lib/components/po-page/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export * from './po-page-default/enums/po-page-actions-layout.enum';
2+
export * from './po-page-default/enums/po-page-header-type.enum';
13
export * from './po-page-default/po-page-default.component';
24
export * from './po-page-default/po-page-default.interface';
35
export * from './po-page-default/po-page-default-literals.interface';

projects/ui/src/lib/components/po-page/interfaces/po-page-action.interface.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,42 @@ import { PoDropdownAction } from '../../po-dropdown';
22

33
/**
44
* @description
5-
* Interface para as ações dos componentes po-page-default e po-page-list.
65
*
7-
* > Quando o array de actions possui quatro ou mais registros, os dois últimos e os seguintes são automaticamente agrupados no po-dropdown.
8-
* A partir desse ponto, as propriedades `selected`, `separator`, `type` e `subItems` passam a ter efeito apenas nas ações exibidas dentro do dropdown, ou seja, a partir da terceira ação.
9-
* Dessa forma, o uso de subItems (agrupadores dentro do dropdown) só terá efeito quando houver pelo menos quatro ações definidas.
6+
* Interface para as ações dos componentes `po-page-default` e `po-page-list`.
107
*
11-
* @docsExtends PoDropdownAction
8+
* As ações são exibidas como botões no cabeçalho e, caso excedam o limite de exibição ou o layout
9+
* seja configurado para tal, são agrupadas automaticamente em um *dropdown*.
10+
*
11+
* **Regras de exibição e agrupamento:**
12+
* - Propriedades como `selected`, `separator`, `type` e `subItems` possuem efeito apenas quando a ação
13+
* está dentro do *dropdown*.
14+
* - O uso de `subItems` (agrupadores) só é renderizado quando a ação é movida para o menu de overflow.
15+
* - O limite de botões visíveis (fora do *dropdown*) varia conforme o tamanho da tela ou a
16+
* propriedade `p-page-actions-layout`.
1217
*
1318
* @ignoreExtendedDescription
1419
*
1520
* @usedBy PoPageDefaultComponent, PoPageListComponent
1621
*/
17-
export interface PoPageAction extends PoDropdownAction {}
22+
export interface PoPageAction extends PoDropdownAction {
23+
/**
24+
* @description
25+
*
26+
* Define o estilo visual da ação quando ela é exibida como botão fora do *dropdown*.
27+
*
28+
* Valores permitidos:
29+
* - `primary`: Botão com maior destaque visual.
30+
* - `secondary`: Estilo padrão para a maioria das ações.
31+
*
32+
* > Valores inválidos são ignorados, mantendo o valor padrão da posição da ação.
33+
*
34+
* > Aplicável apenas a ações exibidas como botões (fora do *dropdown*). Ações dentro do *dropdown* não utilizam esta propriedade.
35+
*
36+
* > Funciona independentemente da posição da ação e com qualquer `PoPageHeaderType` ou `PoPageActionsLayout`.
37+
*
38+
* **Valores padrão por posição (quando `kind` não é definido):**
39+
* - Layout `default`: primeira ação = `primary`, demais = `secondary`.
40+
* - Layout `mixed`: primeira ação = `primary` (header primary) ou `secondary` (header secondary/tertiary).
41+
*/
42+
kind?: string;
43+
}

projects/ui/src/lib/components/po-page/po-page-content/po-page-content-base.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
*
66
* O componente **po-page-content** é utilizado como o container para o conteúdo da página.
77
*/
8-
export class PoPageContentBaseComponent {}
8+
export class PoPageContentBaseComponent {
9+
// Classe base mantida por compatibilidade.
10+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @usedBy PoPageDefaultComponent
3+
*
4+
* @description
5+
*
6+
* Enum que define os layouts de ações disponíveis no `po-page-default`.
7+
*
8+
* > Compatível com todos os valores de `PoPageHeaderType` (`primary`, `secondary` e `tertiary`).
9+
*
10+
* Define os layouts de exibição das ações no cabeçalho.
11+
*/
12+
export enum PoPageActionsLayout {
13+
/**
14+
* Comportamento padrão: as ações são exibidas como botões (até 3 em desktop e 2 em mobile)
15+
* e as demais são agrupadas no *dropdown*.
16+
*/
17+
default = 'default',
18+
19+
/** Todas as ações são agrupadas exclusivamente dentro do menu *dropdown*. */
20+
dropdown = 'dropdown',
21+
22+
/**
23+
* A primeira ação é exibida como um botão de destaque e todas as demais são movidas para o *dropdown*.
24+
*/
25+
mixed = 'mixed'
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @usedBy PoPageDefaultComponent
3+
*
4+
* @description
5+
*
6+
* Define os tipos de cabeçalho disponíveis, alterando a hierarquia visual e os elementos de navegação.
7+
*/
8+
export enum PoPageHeaderType {
9+
/**
10+
* Layout padrão que permite o uso de `p-breadcrumb`. As ações seguem o estilo definido
11+
* em suas propriedades individuais (padrão: `primary` para a primeira ação).
12+
*/
13+
primary = 'primary',
14+
15+
/**
16+
* Exibe um botão de retorno (voltar) ao lado do título e oculta o `p-breadcrumb`.
17+
* Por padrão, as ações assumem o estilo `secondary`.
18+
*/
19+
secondary = 'secondary',
20+
21+
/**
22+
* Layout simplificado sem botões de navegação e sem `p-breadcrumb`.
23+
* Assim como no tipo `secondary`, as ações assumem o estilo `secondary` por padrão.
24+
*/
25+
tertiary = 'tertiary'
26+
}

projects/ui/src/lib/components/po-page/po-page-default/po-page-default-base.component.spec.ts

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Directive } from '@angular/core';
2+
import { TestBed } from '@angular/core/testing';
23

34
import { expectPropertiesValues } from '../../../util-test/util-expect.spec';
45
import { poLocaleDefault } from './../../../services/po-language/po-language.constant';
@@ -18,10 +19,12 @@ describe('PoPageDefaultBaseComponent:', () => {
1819
let languageService: PoLanguageService;
1920
let component: PoPageDefaultComponent;
2021

21-
beforeEach(() => {
22+
beforeEach(async () => {
23+
await TestBed.configureTestingModule({}).compileComponents();
24+
2225
languageService = new PoLanguageService();
2326

24-
component = new PoPageDefaultComponent(languageService);
27+
component = TestBed.runInInjectionContext(() => new PoPageDefaultComponent(languageService));
2528
});
2629

2730
it('should be created', () => {
@@ -108,6 +111,58 @@ describe('PoPageDefaultBaseComponent:', () => {
108111
expectPropertiesValues(component, 'actions', validValues, validValues);
109112
});
110113

114+
describe('p-page-header-type:', () => {
115+
it('should set `pageHeaderType` to `primary` when receiving `primary`.', () => {
116+
component.pageHeaderType = 'primary';
117+
expect(component.pageHeaderType).toBe('primary');
118+
});
119+
120+
it('should set `pageHeaderType` to `secondary` when receiving `secondary`.', () => {
121+
component.pageHeaderType = 'secondary';
122+
expect(component.pageHeaderType).toBe('secondary');
123+
});
124+
125+
it('should set `pageHeaderType` to `tertiary` when receiving `tertiary`.', () => {
126+
component.pageHeaderType = 'tertiary';
127+
expect(component.pageHeaderType).toBe('tertiary');
128+
});
129+
130+
it('should default `pageHeaderType` to `primary` with invalid values.', () => {
131+
const invalidValues = ['invalid', '', null, undefined, 'other'];
132+
133+
invalidValues.forEach(value => {
134+
component.pageHeaderType = value;
135+
expect(component.pageHeaderType).toBe('primary');
136+
});
137+
});
138+
});
139+
140+
describe('p-page-actions-layout:', () => {
141+
it('should set `pageActionsLayout` to `default` when receiving `default`.', () => {
142+
component.pageActionsLayout = 'default';
143+
expect(component.pageActionsLayout).toBe('default');
144+
});
145+
146+
it('should set `pageActionsLayout` to `dropdown` when receiving `dropdown`.', () => {
147+
component.pageActionsLayout = 'dropdown';
148+
expect(component.pageActionsLayout).toBe('dropdown');
149+
});
150+
151+
it('should set `pageActionsLayout` to `mixed` when receiving `mixed`.', () => {
152+
component.pageActionsLayout = 'mixed';
153+
expect(component.pageActionsLayout).toBe('mixed');
154+
});
155+
156+
it('should default `pageActionsLayout` to `default` with invalid values.', () => {
157+
const invalidValues = ['invalid', '', null, undefined, 'other'];
158+
159+
invalidValues.forEach(value => {
160+
component.pageActionsLayout = value;
161+
expect(component.pageActionsLayout).toBe('default');
162+
});
163+
});
164+
});
165+
111166
describe('p-components-size', () => {
112167
beforeEach(() => {
113168
document.documentElement.removeAttribute('data-a11y');

0 commit comments

Comments
 (0)