Skip to content

Commit

Permalink
Merge branch 'main' into 850-fix-conditionate-mandatory-attributes-on…
Browse files Browse the repository at this point in the history
…-button-config-from-indicator
  • Loading branch information
allan-chagas-brisa authored Oct 2, 2023
2 parents cc0be06 + 38f7db2 commit 222c333
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 22 deletions.
2 changes: 1 addition & 1 deletion projects/ion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brisanet/ion",
"version": "0.0.74",
"version": "0.0.75",
"repository": {
"type": "git",
"url": "git+https://github.com/Brisanet/ion.git"
Expand Down
54 changes: 35 additions & 19 deletions projects/ion/src/lib/alert/alert.component.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
<div
data-testid="ion-alert"
[class]="'ion-alert ' + type + ' closable-' + closable"
[ngClass]="{ 'without-background': hideBackground }"
[ngClass]="{
'without-background': hideBackground,
'with-description': description?.length > 0,
'no-radius': noRadius
}"
#ionAlert
>
<ion-icon
data-testid="status-icon"
class="alert-icon"
[type]="iconType"
></ion-icon>
<span *ngIf="hasPlainText; else customBody" data-testid="ion-alert-message">{{
message
}}</span>
<div class="header">
<div class="message">
<ion-icon
data-testid="status-icon"
class="alert-icon"
[type]="iconType"
></ion-icon>

<ng-template #customBody>
<ng-container [ngTemplateOutlet]="message"></ng-container>
</ng-template>
<span
*ngIf="hasPlainText; else customBody"
data-testid="ion-alert-message"
class="message-text"
>{{ message }}</span
>

<ion-icon
class="close-icon"
data-testid="close-icon"
type="close"
*ngIf="closable"
(click)="closeEvent()"
></ion-icon>
<ng-template #customBody>
<ng-container [ngTemplateOutlet]="message"></ng-container>
</ng-template>
</div>

<ion-icon
class="close-icon"
data-testid="close-icon"
type="close"
*ngIf="closable"
(click)="closeEvent()"
></ion-icon>
</div>

<span *ngIf="description?.length > 0" class="description">
{{ description }}
</span>
</div>
35 changes: 33 additions & 2 deletions projects/ion/src/lib/alert/alert.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

.ion-alert {
display: flex;
flex-direction: row;
align-items: center;
flex-direction: column;
gap: 8px;
border: 1px solid;
border-radius: 8px;
Expand All @@ -31,6 +30,18 @@
}
}

.header {
display: flex;
align-items: center;
justify-content: space-between;
}

.message {
display: flex;
align-items: center;
gap: 8px;
}

.success {
@include alert-style($positive-1, $positive-6);
}
Expand All @@ -47,11 +58,31 @@
@include alert-style($negative-1, $negative-6);
}

.with-description {
border: none !important;
background-color: $neutral-2;
padding: spacing(2) spacing(3) !important;
color: $neutral-7;
gap: 4px;

.message-text {
font-weight: 600;
}

.description {
width: 100%;
}
}

.without-background {
background-color: transparent;
border: none !important;
}

.no-radius {
border-radius: 0;
}

.closable-true {
padding: spacing(1) spacing(2);
}
Expand Down
16 changes: 16 additions & 0 deletions projects/ion/src/lib/alert/alert.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ describe('AlertComponent', () => {
expect(element).toHaveClass('without-background');
});

it('should render with description', async () => {
const description = 'Testing description';
const element = await sut({ ...defaultValue, description });
expect(element).toHaveTextContent(description);
});

it('should render with radius', async () => {
const element = await sut(defaultValue);
expect(element).not.toHaveClass('no-radius');
});

it('should render without radius', async () => {
const element = await sut({ ...defaultValue, noRadius: true });
expect(element).toHaveClass('no-radius');
});

describe('With a string provided', () => {
it('Should have an alert message', async () => {
expect(await sut()).toHaveTextContent(defaultValue.message as string);
Expand Down
2 changes: 2 additions & 0 deletions projects/ion/src/lib/alert/alert.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export class IonAlertComponent implements OnInit, OnChanges {
@Input() type?: StatusType = 'success';
@Input() closable? = false;
@Input() hideBackground? = false;
@Input() noRadius? = false;
@Input() description?: string;

@ViewChild('ionAlert', { static: false }) private ionAlert: ElementRef;

Expand Down
2 changes: 2 additions & 0 deletions projects/ion/src/lib/core/types/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { StatusType } from './status';

export interface IonAlertProps {
message: string | TemplateRef<void>;
description?: string;
type?: StatusType;
closable?: boolean;
hideBackground?: boolean;
noRadius?: boolean;
}
18 changes: 18 additions & 0 deletions stories/Alert.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,21 @@ A partir do paramêtro `hideBackground` pode ser definido se o usuário quer mos
{Template.bind({})}
</Story>
</Canvas>

<Canvas>
<Story
name="type: with description"
args={{
type: 'info',
message: 'Example of alert message',
description: 'Example of description.',
}}
decorators={[
moduleMetadata({
imports: [CommonModule, IonSharedModule],
}),
]}
>
{Template.bind({})}
</Story>
</Canvas>

0 comments on commit 222c333

Please sign in to comment.