Browse Source

Refactor profile and alert components for cleaner templates

Simplified the HTML structure of manage-profile and page-alert-container components by reducing unnecessary markup and improving readability. Replaced Angular animation usage in manage-profile with a CSS-based fade-in effect for better maintainability.
pull/24579/head
Fahri Gedik 7 months ago
parent
commit
89f873b060
  1. 78
      npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.html
  2. 20
      npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts
  3. 36
      npm/ng-packs/packages/theme-basic/src/lib/components/page-alert-container/page-alert-container.component.html

78
npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.html

@ -5,61 +5,47 @@
<div class="col-12 col-md-3">
<ul class="nav flex-column nav-pills" id="nav-tab" role="tablist">
@if (!hideChangePasswordTab && (profile$ | async)) {
<li class="nav-item" (click)="selectedTab = 0">
<a
class="nav-link"
[class.active]="selectedTab === 0"
role="tab"
href="javascript:void(0)"
>{{ 'AbpUi::ChangePassword' | abpLocalization }}</a
>
</li>
<li class="nav-item" (click)="selectedTab = 0">
<a class="nav-link" [class.active]="selectedTab === 0" role="tab" href="javascript:void(0)">{{
'AbpUi::ChangePassword' | abpLocalization }}</a>
</li>
}
<li class="nav-item mb-2" (click)="selectedTab = 1">
<a
class="nav-link"
[class.active]="selectedTab === 1"
role="tab"
href="javascript:void(0)"
>{{ 'AbpAccount::PersonalSettings' | abpLocalization }}</a
>
<a class="nav-link" [class.active]="selectedTab === 1" role="tab" href="javascript:void(0)">{{
'AbpAccount::PersonalSettings' | abpLocalization }}</a>
</li>
</ul>
</div>
@if (profile$ | async) {
<div class="col-12 col-md-9">
@if (selectedTab === 0) {
<div class="tab-content" [@fadeIn]>
<div class="tab-pane active" role="tabpanel">
<h4>
{{ 'AbpIdentity::ChangePassword' | abpLocalization }}
<hr />
</h4>
<abp-change-password-form
*abpReplaceableTemplate="{
<div class="col-12 col-md-9">
@if (selectedTab === 0) {
<div class="tab-content fade-in">
<div class="tab-pane active" role="tabpanel">
<h4>
{{ 'AbpIdentity::ChangePassword' | abpLocalization }}
<hr />
</h4>
<abp-change-password-form *abpReplaceableTemplate="{
componentKey: changePasswordKey
}"
></abp-change-password-form>
</div>
</div>
}
@if (selectedTab === 1) {
<div class="tab-content" [@fadeIn]>
<div class="tab-pane active" role="tabpanel">
<h4>
{{ 'AbpIdentity::PersonalSettings' | abpLocalization }}
<hr />
</h4>
<abp-personal-settings-form
*abpReplaceableTemplate="{
}"></abp-change-password-form>
</div>
</div>
}
@if (selectedTab === 1) {
<div class="tab-content fade-in">
<div class="tab-pane active" role="tabpanel">
<h4>
{{ 'AbpIdentity::PersonalSettings' | abpLocalization }}
<hr />
</h4>
<abp-personal-settings-form *abpReplaceableTemplate="{
componentKey: personalSettingsKey
}"
></abp-personal-settings-form>
</div>
</div>
}
}"></abp-personal-settings-form>
</div>
</div>
}
</div>
}
</div>
</div>
</div>
</div>

20
npm/ng-packs/packages/account/src/lib/components/manage-profile/manage-profile.component.ts

@ -1,6 +1,5 @@
import { ProfileService } from '@abp/ng.account.core/proxy';
import { fadeIn, LoadingDirective } from '@abp/ng.theme.shared';
import { transition, trigger, useAnimation } from '@angular/animations';
import { LoadingDirective } from '@abp/ng.theme.shared';
import { Component, inject, OnInit } from '@angular/core';
import { eAccountComponents } from '../../enums/components';
import { ManageProfileStateService } from '../../services/manage-profile.state.service';
@ -13,13 +12,24 @@ import { ChangePasswordComponent } from '../change-password/change-password.comp
@Component({
selector: 'abp-manage-profile',
templateUrl: './manage-profile.component.html',
animations: [trigger('fadeIn', [transition(':enter', useAnimation(fadeIn))])],
styles: [
//TODO: move static styles
`
.min-h-400 {
min-height: 400px;
}
.fade-in {
animation: fadeIn 350ms ease both;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
`,
],
imports: [
@ -30,7 +40,7 @@ import { ChangePasswordComponent } from '../change-password/change-password.comp
LocalizationPipe,
ReplaceableTemplateDirective,
LoadingDirective
],
],
})
export class ManageProfileComponent implements OnInit {
protected profileService = inject(ProfileService);

36
npm/ng-packs/packages/theme-basic/src/lib/components/page-alert-container/page-alert-container.component.html

@ -1,26 +1,12 @@
@for (alert of service.alerts$ | async; track i; let i = $index) {
<div
class="alert alert-{{ alert.type }} fade show"
[class.alert-dismissible]="alert.dismissible" [class.fade]="alert.dismissible" [class.show]="alert.dismissible"
role="alert"
>
@if (alert.title) {
<h4
class="alert-heading"
[innerHTML]="alert.title | abpSafeHtml | abpLocalization: alert.titleLocalizationParams"
></h4>
}
<span
[innerHTML]="alert.message | abpSafeHtml | abpLocalization: alert.messageLocalizationParams"
></span>
@if (alert.dismissible) {
<button
type="button"
class="btn-close"
data-dismiss="alert"
aria-label="Close"
(click)="service.remove(i)"
></button>
}
</div>
}
<div class="alert alert-{{ alert.type }} fade show" [class.alert-dismissible]="alert.dismissible" role="alert">
@if (alert.title) {
<h4 class="alert-heading" [innerHTML]="alert.title | abpSafeHtml | abpLocalization: alert.titleLocalizationParams">
</h4>
}
<span [innerHTML]="alert.message | abpSafeHtml | abpLocalization: alert.messageLocalizationParams"></span>
@if (alert.dismissible) {
<button type="button" class="btn-close" data-dismiss="alert" aria-label="Close" (click)="service.remove(i)"></button>
}
</div>
}
Loading…
Cancel
Save