-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
340 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...les-angular/projects/ui-particles-angular/src/lib/gio-banner/README.stories.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Meta, ArgsTable, PRIMARY_STORY } from '@storybook/addon-docs'; | ||
|
||
<Meta title="Components / Banner / README" /> | ||
|
||
# Gio Banner | ||
|
||
TODO by :gmaisse-psychédélique: |
36 changes: 36 additions & 0 deletions
36
...ticles-angular/projects/ui-particles-angular/src/lib/gio-banner/gio-banner.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!-- | ||
Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<div | ||
class="banner" | ||
[class.info]="type === 'info'" | ||
[class.error]="type === 'error'" | ||
[class.warning]="type === 'warning'" | ||
[class.success]="type === 'success'" | ||
> | ||
<div class="banner__icon"> | ||
<div [ngSwitch]="type"> | ||
<mat-icon *ngSwitchCase="'info'">info</mat-icon> | ||
<mat-icon *ngSwitchCase="'error'">error</mat-icon> | ||
<mat-icon *ngSwitchCase="'warning'">warning</mat-icon> | ||
<mat-icon *ngSwitchCase="'success'">check_circle</mat-icon> | ||
</div> | ||
</div> | ||
<div class="banner__content"> | ||
<ng-content></ng-content> | ||
</div> | ||
</div> |
72 changes: 72 additions & 0 deletions
72
...ticles-angular/projects/ui-particles-angular/src/lib/gio-banner/gio-banner.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
@use 'sass:map'; | ||
@use '@angular/material' as mat; | ||
|
||
@use '../../scss' as gio; | ||
|
||
$background: map-get(gio.$mat-theme, background); | ||
|
||
// Map for palette by type | ||
$types: ( | ||
error: gio.$mat-error-palette, | ||
info: gio.$mat-info-palette, | ||
success: gio.$mat-success-palette, | ||
warning: gio.$mat-warning-palette, | ||
); | ||
|
||
:host { | ||
display: block; | ||
margin: 8px 0px; | ||
} | ||
|
||
.banner { | ||
padding: 0 16px; | ||
display: flex; | ||
align-items: center; | ||
border-radius: 4px; | ||
|
||
@each $typeName, $typePalette in $types { | ||
&.#{$typeName} { | ||
color: mat.get-color-from-palette($typePalette, darker); | ||
background-color: mat.get-color-from-palette($background, card); | ||
border: 1px solid mat.get-color-from-palette($typePalette, medium); | ||
|
||
box-shadow: 8px 0px 0px 0px mat.get-color-from-palette($typePalette, light, 0.12) inset; | ||
|
||
$typeTarget: &; // current css target | ||
// when banner is inside mat-card | ||
:host-context(.mat-card) { | ||
#{$typeTarget} { | ||
box-shadow: none; | ||
background-color: mat.get-color-from-palette($typePalette, light, 0.12); | ||
} | ||
} | ||
} | ||
} | ||
|
||
&__icon { | ||
padding-top: 8px; | ||
margin-right: 16px; | ||
opacity: 0.9; | ||
} | ||
|
||
&__content { | ||
flex: 1 1 auto; | ||
line-height: normal; | ||
padding: 8px 0; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...articles-angular/projects/ui-particles-angular/src/lib/gio-banner/gio-banner.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
export type GioBannerTypes = 'error' | 'info' | 'success' | 'warning'; | ||
|
||
@Component({ | ||
selector: 'gio-banner', | ||
templateUrl: './gio-banner.component.html', | ||
styleUrls: ['./gio-banner.component.scss'], | ||
}) | ||
export class GioBannerComponent { | ||
@Input() | ||
type: GioBannerTypes = 'info'; | ||
} | ||
|
||
@Component({ | ||
selector: 'gio-banner-error', | ||
templateUrl: './gio-banner.component.html', | ||
styleUrls: ['./gio-banner.component.scss'], | ||
}) | ||
export class GioBannerErrorComponent extends GioBannerComponent { | ||
type = 'error' as GioBannerTypes; | ||
} | ||
|
||
@Component({ | ||
selector: 'gio-banner-info', | ||
templateUrl: './gio-banner.component.html', | ||
styleUrls: ['./gio-banner.component.scss'], | ||
}) | ||
export class GioBannerInfoComponent extends GioBannerComponent { | ||
type = 'info' as GioBannerTypes; | ||
} | ||
|
||
@Component({ | ||
selector: 'gio-banner-success', | ||
templateUrl: './gio-banner.component.html', | ||
styleUrls: ['./gio-banner.component.scss'], | ||
}) | ||
export class GioBannerSuccessComponent extends GioBannerComponent { | ||
type = 'success' as GioBannerTypes; | ||
} | ||
|
||
@Component({ | ||
selector: 'gio-banner-warning', | ||
templateUrl: './gio-banner.component.html', | ||
styleUrls: ['./gio-banner.component.scss'], | ||
}) | ||
export class GioBannerWarningComponent extends GioBannerComponent { | ||
type = 'warning' as GioBannerTypes; | ||
} |
37 changes: 37 additions & 0 deletions
37
...ticles-angular/projects/ui-particles-angular/src/lib/gio-banner/gio-banner.module.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { GioBannerComponent } from './gio-banner.component'; | ||
import { GioBannerModule } from './gio-banner.module'; | ||
|
||
describe('GioBannerComponent', () => { | ||
let fixture: ComponentFixture<GioBannerComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [NoopAnimationsModule, GioBannerModule], | ||
}); | ||
fixture = TestBed.createComponent(GioBannerComponent); | ||
}); | ||
|
||
it('should display error banner', () => { | ||
fixture.componentInstance.type = 'error'; | ||
fixture.detectChanges(); | ||
expect(fixture.nativeElement.querySelector('.banner.error')).toBeDefined(); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
ui-particles-angular/projects/ui-particles-angular/src/lib/gio-banner/gio-banner.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
|
||
import { | ||
GioBannerComponent, | ||
GioBannerErrorComponent, | ||
GioBannerInfoComponent, | ||
GioBannerSuccessComponent, | ||
GioBannerWarningComponent, | ||
} from './gio-banner.component'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, MatIconModule], | ||
declarations: [GioBannerComponent, GioBannerErrorComponent, GioBannerInfoComponent, GioBannerSuccessComponent, GioBannerWarningComponent], | ||
exports: [GioBannerComponent, GioBannerErrorComponent, GioBannerInfoComponent, GioBannerSuccessComponent, GioBannerWarningComponent], | ||
entryComponents: [ | ||
GioBannerComponent, | ||
GioBannerErrorComponent, | ||
GioBannerInfoComponent, | ||
GioBannerSuccessComponent, | ||
GioBannerWarningComponent, | ||
], | ||
}) | ||
export class GioBannerModule {} |
81 changes: 81 additions & 0 deletions
81
ui-particles-angular/projects/ui-particles-angular/src/lib/gio-banner/gio-banner.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { Meta, moduleMetadata } from '@storybook/angular'; | ||
import { Story } from '@storybook/angular/dist/ts3.9/client/preview/types-7-0'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
|
||
import { GioBannerModule } from './gio-banner.module'; | ||
import { GioBannerComponent } from './gio-banner.component'; | ||
|
||
export default { | ||
title: 'Components / Banner', | ||
component: GioBannerComponent, | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [GioBannerModule, MatCardModule], | ||
}), | ||
], | ||
render: () => ({}), | ||
} as Meta; | ||
|
||
export const All: Story = { | ||
render: () => ({ | ||
template: ` | ||
<gio-banner-error>Error <br> Second line <br> Wow another one</gio-banner-error> | ||
<br> | ||
<gio-banner-info>This is an info banner!</gio-banner-info> | ||
<br> | ||
<gio-banner-success>This is a success banner!</gio-banner-success> | ||
<br> | ||
<gio-banner-warning>This is a warning banner!</gio-banner-warning> | ||
`, | ||
}), | ||
}; | ||
|
||
export const AllInMatCard: Story = { | ||
render: () => ({ | ||
template: ` | ||
<mat-card> | ||
<gio-banner-error>Error <br> Second line <br> Wow another one</gio-banner-error> | ||
<br> | ||
<gio-banner-info>This is an info banner!</gio-banner-info> | ||
<br> | ||
<gio-banner-success>This is a success banner!</gio-banner-success> | ||
<br> | ||
<gio-banner-warning>This is a warning banner!</gio-banner-warning> | ||
</mat-card>`, | ||
}), | ||
}; | ||
|
||
export const AllWithTypeInput: Story = { | ||
render: () => ({ | ||
template: ` | ||
<gio-banner type="error">Error <br> Second line <br> Wow another one</gio-banner> | ||
<br> | ||
<gio-banner type="info">This is an info banner!</gio-banner> | ||
<br> | ||
<gio-banner type="success">This is a success banner!</gio-banner> | ||
<br> | ||
<gio-banner type="warning">This is a warning banner!</gio-banner> | ||
`, | ||
}), | ||
}; | ||
|
||
export const Default: Story = { | ||
render: () => ({ | ||
template: `<gio-banner>This is an Default banner!</gio-banner>`, | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters