-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MEL]: Application banner #1142
base: main
Are you sure you want to change the base?
Changes from 7 commits
9c7f708
2b14655
0f1fd73
412b796
548a35e
dad6424
ee887d7
744097a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,11 @@ | |
<div | ||
class="container-lg relative h-full mx-auto flex flex-col-reverse justify-between sm:flex-col sm:justify-end" | ||
> | ||
<gn-ui-application-banner | ||
[message]="platformService.translateKey(bannerKey) | async" | ||
class="container-sm" | ||
type="secondary" | ||
></gn-ui-application-banner> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<div | ||
class="py-8 relative z-40 mb-[184px] sm:mb-0" | ||
[ngClass]="{ 'pointer-events-none': expandRatio < 0.2 }" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div *ngIf="message" style="top: 0" class="absolute text-wrap bg-white mt-4"> | ||
cmoinier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div | ||
class="flex flex-row py-2.5 px-5 gap-5 justify-start items-center border" | ||
[ngClass]="classList" | ||
> | ||
<ng-icon [name]="icon"></ng-icon> | ||
<div class="flex flex-col justify-start gap-2.5"> | ||
<span *ngIf="title" class="font-bold">{{ title }}</span> | ||
<span class="font-medium" [innerHTML]="message"></span> | ||
</div> | ||
<button | ||
*ngIf="closeEnabled" | ||
class="self-start" | ||
type="button" | ||
(click)="closeMessage()" | ||
> | ||
<ng-icon name="matCloseOutline"> </ng-icon> | ||
</button> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
import { ApplicationBannerComponent } from './application-banner.component' | ||
|
||
describe('ApplicationBannerComponent', () => { | ||
let component: ApplicationBannerComponent | ||
let fixture: ComponentFixture<ApplicationBannerComponent> | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ApplicationBannerComponent], | ||
}).compileComponents() | ||
|
||
fixture = TestBed.createComponent(ApplicationBannerComponent) | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { | ||
applicationConfig, | ||
componentWrapperDecorator, | ||
Meta, | ||
moduleMetadata, | ||
StoryObj, | ||
} from '@storybook/angular' | ||
import { ApplicationBannerComponent } from './application-banner.component' | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations' | ||
import { importProvidersFrom } from '@angular/core' | ||
|
||
export default { | ||
title: 'Elements/ApplicationBannerComponent', | ||
component: ApplicationBannerComponent, | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [ApplicationBannerComponent], | ||
}), | ||
applicationConfig({ | ||
providers: [importProvidersFrom(BrowserAnimationsModule)], | ||
}), | ||
componentWrapperDecorator( | ||
(story) => `<div style="max-width: 800px">${story}</div>` | ||
), | ||
], | ||
} as Meta<ApplicationBannerComponent> | ||
|
||
export const Default: StoryObj<ApplicationBannerComponent> = { | ||
args: { | ||
message: 'This is a warning message', | ||
closeEnabled: false, | ||
type: 'primary', | ||
}, | ||
} | ||
|
||
export const PrimaryFull: StoryObj<ApplicationBannerComponent> = { | ||
args: { | ||
message: 'This is a warning message', | ||
title: 'Warning', | ||
closeEnabled: true, | ||
type: 'primary', | ||
}, | ||
} | ||
|
||
export const SecondaryFull: StoryObj<ApplicationBannerComponent> = { | ||
args: { | ||
message: 'This is a warning message', | ||
title: 'Warning', | ||
closeEnabled: true, | ||
type: 'secondary', | ||
}, | ||
} | ||
|
||
export const LightFull: StoryObj<ApplicationBannerComponent> = { | ||
args: { | ||
message: 'This is a warning message', | ||
title: 'Warning', | ||
closeEnabled: true, | ||
type: 'light', | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wasn't, I don't know why it's happening like that in the storybook, maybe it's a matter of colors imports? Because in the datahub the right colors are shown when switching to secondary or light :/ |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core' | ||
import { CommonModule } from '@angular/common' | ||
import { | ||
NgIconComponent, | ||
provideIcons, | ||
provideNgIconsConfig, | ||
} from '@ng-icons/core' | ||
import { | ||
matCloseOutline, | ||
matWarningAmberOutline, | ||
} from '@ng-icons/material-icons/outline' | ||
|
||
@Component({ | ||
selector: 'gn-ui-application-banner', | ||
standalone: true, | ||
imports: [CommonModule, NgIconComponent], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
templateUrl: './application-banner.component.html', | ||
styleUrl: './application-banner.component.css', | ||
providers: [ | ||
provideIcons({ | ||
matWarningAmberOutline, | ||
matCloseOutline, | ||
}), | ||
provideNgIconsConfig({ size: '1.5em' }), | ||
], | ||
}) | ||
export class ApplicationBannerComponent { | ||
@Input() message: string | ||
@Input() title: string | ||
@Input() closeEnabled = false | ||
@Input() extraClass = '' | ||
@Input() icon = 'matWarningAmberOutline' | ||
cmoinier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
msgClass = '' | ||
|
||
@Input() set type(value: 'primary' | 'secondary' | 'light') { | ||
switch (value) { | ||
case 'primary': | ||
this.msgClass = 'bg-primary-darkest border-primary text-white' | ||
break | ||
case 'secondary': | ||
this.msgClass = 'bg-primary-opacity-50 border-primary-darker text-black' | ||
break | ||
case 'light': | ||
this.msgClass = | ||
'bg-primary-opacity-10 border-primary-lightest text-black' | ||
break | ||
default: | ||
this.msgClass = 'bg-primary-opacity-50 border-primary-darker text-black' | ||
cmoinier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
break | ||
} | ||
} | ||
|
||
get classList() { | ||
return `${this.msgClass} ${this.extraClass}` | ||
} | ||
|
||
closeMessage() { | ||
this.message = '' | ||
cmoinier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there is an enpoint api to add a new translation key, maybe it will save time to do so as a POST instead of login and navigate in geonetwork admin.
But it works fine as is too, this is a thought about improving e2e runing time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is, and it would also fail a bit less. Will change that, thanks for the suggestion :)