@carefirst/library 1.3.9 → 1.3.10
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.json +31 -0
- package/ng-package.json +8 -0
- package/package.json +11 -14
- package/src/lib/components/alert/alert.component.html +0 -0
- package/src/lib/components/alert/alert.component.scss +63 -0
- package/src/lib/components/alert/alert.component.spec.ts +23 -0
- package/src/lib/components/alert/alert.component.ts +73 -0
- package/src/lib/components/badge/badge.component.html +5 -0
- package/src/lib/components/badge/badge.component.scss +96 -0
- package/src/lib/components/badge/badge.component.spec.ts +23 -0
- package/src/lib/components/badge/badge.component.ts +61 -0
- package/src/lib/components/button/button.component.html +20 -0
- package/src/lib/components/button/button.component.scss +153 -0
- package/src/lib/components/button/button.component.spec.ts +21 -0
- package/src/lib/components/button/button.component.ts +94 -0
- package/src/lib/components/calendar/calendar.component.html +9 -0
- package/src/lib/components/calendar/calendar.component.scss +34 -0
- package/src/lib/components/calendar/calendar.component.spec.ts +23 -0
- package/src/lib/components/calendar/calendar.component.ts +53 -0
- package/src/lib/components/chat-bubble/chat-bubble.component.html +9 -0
- package/src/lib/components/chat-bubble/chat-bubble.component.scss +31 -0
- package/src/lib/components/chat-bubble/chat-bubble.component.spec.ts +23 -0
- package/src/lib/components/chat-bubble/chat-bubble.component.ts +43 -0
- package/src/lib/components/form-input/form-input.component.html +37 -0
- package/src/lib/components/form-input/form-input.component.scss +23 -0
- package/src/lib/components/form-input/form-input.component.spec.ts +23 -0
- package/src/lib/components/form-input/form-input.component.ts +95 -0
- package/src/lib/components/form-input-select/form-input-select.component.html +27 -0
- package/src/lib/components/form-input-select/form-input-select.component.scss +40 -0
- package/src/lib/components/form-input-select/form-input-select.component.spec.ts +23 -0
- package/src/lib/components/form-input-select/form-input-select.component.ts +61 -0
- package/src/lib/components/form-input-text-area/form-input-text-area.component.html +29 -0
- package/src/lib/components/form-input-text-area/form-input-text-area.component.scss +19 -0
- package/src/lib/components/form-input-text-area/form-input-text-area.component.spec.ts +23 -0
- package/src/lib/components/form-input-text-area/form-input-text-area.component.ts +76 -0
- package/src/lib/components/form-validation/form-validation.component.html +8 -0
- package/src/lib/components/form-validation/form-validation.component.scss +8 -0
- package/src/lib/components/form-validation/form-validation.component.spec.ts +23 -0
- package/src/lib/components/form-validation/form-validation.component.ts +34 -0
- package/src/lib/components/icon/icon.component.html +529 -0
- package/src/lib/components/icon/icon.component.scss +61 -0
- package/src/lib/components/icon/icon.component.spec.ts +21 -0
- package/src/lib/components/icon/icon.component.ts +40 -0
- package/src/lib/components/logo/logo.component.html +10 -0
- package/src/lib/components/logo/logo.component.scss +5 -0
- package/src/lib/components/logo/logo.component.spec.ts +23 -0
- package/src/lib/components/logo/logo.component.ts +21 -0
- package/src/lib/components/notification/notification.component.html +39 -0
- package/src/lib/components/notification/notification.component.scss +20 -0
- package/src/lib/components/notification/notification.component.spec.ts +21 -0
- package/src/lib/components/notification/notification.component.ts +23 -0
- package/src/lib/components/page/page.component.html +5 -0
- package/src/lib/components/page/page.component.scss +35 -0
- package/src/lib/components/page/page.component.spec.ts +21 -0
- package/src/lib/components/page/page.component.ts +42 -0
- package/src/lib/components/spacer/spacer.component.html +4 -0
- package/src/lib/components/spacer/spacer.component.scss +27 -0
- package/src/lib/components/spacer/spacer.component.spec.ts +21 -0
- package/src/lib/components/spacer/spacer.component.ts +43 -0
- package/src/lib/components/spinner/spinner.component.html +1 -0
- package/src/lib/components/spinner/spinner.component.scss +14 -0
- package/src/lib/components/spinner/spinner.component.spec.ts +23 -0
- package/src/lib/components/spinner/spinner.component.ts +33 -0
- package/src/lib/directives/button-loader.directive.spec.ts +8 -0
- package/src/lib/directives/button-loader.directive.ts +77 -0
- package/src/lib/interfaces/alert.interface.ts +20 -0
- package/src/lib/interfaces/icon.interface.ts +62 -0
- package/src/lib/interfaces/input.interface.ts +8 -0
- package/src/lib/interfaces/notification.interface.ts +15 -0
- package/src/lib/interfaces/spacer.interface.ts +6 -0
- package/src/lib/library.module.ts +66 -0
- package/src/lib/utils/attribute.util.ts +66 -0
- package/src/lib/utils/form-validators-utility.ts +186 -0
- package/{public-api.d.ts → src/public-api.ts} +18 -0
- package/tsconfig.lib.json +12 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/carefirst-library.mjs +0 -2
- package/esm2022/lib/components/alert/alert.component.mjs +0 -56
- package/esm2022/lib/components/badge/badge.component.mjs +0 -39
- package/esm2022/lib/components/button/button.component.mjs +0 -87
- package/esm2022/lib/components/calendar/calendar.component.mjs +0 -39
- package/esm2022/lib/components/chat-bubble/chat-bubble.component.mjs +0 -31
- package/esm2022/lib/components/form-input/form-input.component.mjs +0 -87
- package/esm2022/lib/components/form-input-select/form-input-select.component.mjs +0 -46
- package/esm2022/lib/components/form-input-text-area/form-input-text-area.component.mjs +0 -61
- package/esm2022/lib/components/form-validation/form-validation.component.mjs +0 -20
- package/esm2022/lib/components/icon/icon.component.mjs +0 -29
- package/esm2022/lib/components/logo/logo.component.mjs +0 -18
- package/esm2022/lib/components/notification/notification.component.mjs +0 -22
- package/esm2022/lib/components/page/page.component.mjs +0 -31
- package/esm2022/lib/components/spacer/spacer.component.mjs +0 -30
- package/esm2022/lib/components/spinner/spinner.component.mjs +0 -19
- package/esm2022/lib/directives/button-loader.directive.mjs +0 -41
- package/esm2022/lib/interfaces/alert.interface.mjs +0 -2
- package/esm2022/lib/interfaces/icon.interface.mjs +0 -52
- package/esm2022/lib/interfaces/input.interface.mjs +0 -2
- package/esm2022/lib/interfaces/notification.interface.mjs +0 -2
- package/esm2022/lib/interfaces/spacer.interface.mjs +0 -2
- package/esm2022/lib/library.module.mjs +0 -100
- package/esm2022/lib/utils/attribute.util.mjs +0 -34
- package/esm2022/lib/utils/form-validators-utility.mjs +0 -113
- package/esm2022/public-api.mjs +0 -24
- package/fesm2022/carefirst-library.mjs +0 -885
- package/fesm2022/carefirst-library.mjs.map +0 -1
- package/index.d.ts +0 -2
- package/lib/components/alert/alert.component.d.ts +0 -14
- package/lib/components/badge/badge.component.d.ts +0 -15
- package/lib/components/button/button.component.d.ts +0 -30
- package/lib/components/calendar/calendar.component.d.ts +0 -15
- package/lib/components/chat-bubble/chat-bubble.component.d.ts +0 -13
- package/lib/components/form-input/form-input.component.d.ts +0 -37
- package/lib/components/form-input-select/form-input-select.component.d.ts +0 -21
- package/lib/components/form-input-text-area/form-input-text-area.component.d.ts +0 -27
- package/lib/components/form-validation/form-validation.component.d.ts +0 -9
- package/lib/components/icon/icon.component.d.ts +0 -13
- package/lib/components/logo/logo.component.d.ts +0 -7
- package/lib/components/notification/notification.component.d.ts +0 -9
- package/lib/components/page/page.component.d.ts +0 -13
- package/lib/components/spacer/spacer.component.d.ts +0 -14
- package/lib/components/spinner/spinner.component.d.ts +0 -9
- package/lib/directives/button-loader.directive.d.ts +0 -12
- package/lib/interfaces/alert.interface.d.ts +0 -11
- package/lib/interfaces/icon.interface.d.ts +0 -4
- package/lib/interfaces/input.interface.d.ts +0 -4
- package/lib/interfaces/notification.interface.d.ts +0 -11
- package/lib/interfaces/spacer.interface.d.ts +0 -3
- package/lib/library.module.d.ts +0 -25
- package/lib/utils/attribute.util.d.ts +0 -4
- package/lib/utils/form-validators-utility.d.ts +0 -8
package/.eslintrc.json
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"extends": "../../../.eslintrc.json",
|
3
|
+
"ignorePatterns": ["!**/*", "node_modules/**/*"],
|
4
|
+
"overrides": [
|
5
|
+
{
|
6
|
+
"files": ["*.ts"],
|
7
|
+
"rules": {
|
8
|
+
"@angular-eslint/directive-selector": [
|
9
|
+
"error",
|
10
|
+
{
|
11
|
+
"type": "attribute",
|
12
|
+
"prefix": "cf",
|
13
|
+
"style": "camelCase"
|
14
|
+
}
|
15
|
+
],
|
16
|
+
"@angular-eslint/component-selector": [
|
17
|
+
"error",
|
18
|
+
{
|
19
|
+
"type": "element",
|
20
|
+
"prefix": "cf",
|
21
|
+
"style": "kebab-case"
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"files": ["*.html"],
|
28
|
+
"rules": {}
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
package/ng-package.json
ADDED
package/package.json
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carefirst/library",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.10",
|
4
4
|
"author": "Jacques Francois Coetzee",
|
5
5
|
"private": false,
|
6
|
+
"scripts": {
|
7
|
+
"ng": "ng",
|
8
|
+
"build": "ng build",
|
9
|
+
"watch": "ng build --watch --configuration development",
|
10
|
+
"test": "ng test",
|
11
|
+
"lint": "ng lint"
|
12
|
+
},
|
6
13
|
"peerDependencies": {
|
7
14
|
"@angular/common": "^17.x",
|
8
15
|
"@angular/core": "^17.x",
|
@@ -14,17 +21,7 @@
|
|
14
21
|
"tslib": "^2.3.0"
|
15
22
|
},
|
16
23
|
"sideEffects": false,
|
17
|
-
"
|
18
|
-
|
19
|
-
"exports": {
|
20
|
-
"./package.json": {
|
21
|
-
"default": "./package.json"
|
22
|
-
},
|
23
|
-
".": {
|
24
|
-
"types": "./index.d.ts",
|
25
|
-
"esm2022": "./esm2022/carefirst-library.mjs",
|
26
|
-
"esm": "./esm2022/carefirst-library.mjs",
|
27
|
-
"default": "./fesm2022/carefirst-library.mjs"
|
28
|
-
}
|
24
|
+
"devDependencies": {
|
25
|
+
"@ionic/angular": "^7.6.4"
|
29
26
|
}
|
30
|
-
}
|
27
|
+
}
|
File without changes
|
@@ -0,0 +1,63 @@
|
|
1
|
+
//--- Screen size breakpoint
|
2
|
+
$desktop-breakpoint: 768px; //--- Same as ionic md breakpoint
|
3
|
+
|
4
|
+
::ng-deep .care-first-alert {
|
5
|
+
.alert-wrapper {
|
6
|
+
padding: 1.6rem;
|
7
|
+
border-radius: 1.6rem;
|
8
|
+
background-color: var(--cf-app-background-light);
|
9
|
+
|
10
|
+
> * {
|
11
|
+
text-align: center;
|
12
|
+
padding: 0;
|
13
|
+
}
|
14
|
+
.alert-title {
|
15
|
+
font-weight: 900;
|
16
|
+
font-size: 1.8rem;
|
17
|
+
color: var(--cf-app-text-color-default);
|
18
|
+
}
|
19
|
+
|
20
|
+
.alert-message {
|
21
|
+
font-size: 1.4rem;
|
22
|
+
margin-top: 1.2rem;
|
23
|
+
color: var(--cf-app-text-color-default);
|
24
|
+
}
|
25
|
+
|
26
|
+
@media (min-width: $desktop-breakpoint) {
|
27
|
+
.alert-title {
|
28
|
+
font-size: 2.8rem;
|
29
|
+
}
|
30
|
+
|
31
|
+
.alert-message {
|
32
|
+
font-size: 1.8rem;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
.alert-button-group {
|
37
|
+
margin-top: 1.6rem;
|
38
|
+
display: flex;
|
39
|
+
justify-content: center;
|
40
|
+
gap: 4rem;
|
41
|
+
|
42
|
+
@media (min-width: $desktop-breakpoint) {
|
43
|
+
gap: 2rem;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
button.alert-button {
|
48
|
+
font-size: 1.6rem;
|
49
|
+
padding: 0.6rem 2rem;
|
50
|
+
margin: 0px;
|
51
|
+
}
|
52
|
+
|
53
|
+
button.alert-button.alert-button-cancel {
|
54
|
+
color: var(--cf-app-system-color-error);
|
55
|
+
}
|
56
|
+
|
57
|
+
button.alert-button.alert-button-confirm {
|
58
|
+
border-radius: 0.6rem;
|
59
|
+
background-color: var(--cf-app-color-primary);
|
60
|
+
color: var(--cf-app-text-color-light);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
2
|
+
|
3
|
+
import { AlertComponent } from './alert.component';
|
4
|
+
|
5
|
+
describe('AlertComponent', () => {
|
6
|
+
let component: AlertComponent;
|
7
|
+
let fixture: ComponentFixture<AlertComponent>;
|
8
|
+
|
9
|
+
beforeEach(async () => {
|
10
|
+
await TestBed.configureTestingModule({
|
11
|
+
imports: [AlertComponent]
|
12
|
+
})
|
13
|
+
.compileComponents();
|
14
|
+
|
15
|
+
fixture = TestBed.createComponent(AlertComponent);
|
16
|
+
component = fixture.componentInstance;
|
17
|
+
fixture.detectChanges();
|
18
|
+
});
|
19
|
+
|
20
|
+
it('should create', () => {
|
21
|
+
expect(component).toBeTruthy();
|
22
|
+
});
|
23
|
+
});
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/**
|
2
|
+
* CareFirst Library Alert
|
3
|
+
*
|
4
|
+
* @file alert.component
|
5
|
+
* @description Contains all the logic for generating a CareFirst Alert
|
6
|
+
* @author Arno Jansen van Vuuren
|
7
|
+
* @since 2023 - 11 - 30
|
8
|
+
* @usage <cf-alert data="{heading, message, buttonTrue, buttonFalse}" (alertEvent)></cf-alert>
|
9
|
+
*/
|
10
|
+
|
11
|
+
import { Component, Input, Output, type OnChanges, type SimpleChanges, EventEmitter } from '@angular/core';
|
12
|
+
import { AlertController } from '@ionic/angular';
|
13
|
+
import type { AlertDataI, AlertEventI } from '../../interfaces/alert.interface';
|
14
|
+
|
15
|
+
@Component({
|
16
|
+
selector: 'cf-alert',
|
17
|
+
templateUrl: './alert.component.html',
|
18
|
+
styleUrl: './alert.component.scss',
|
19
|
+
})
|
20
|
+
export class AlertComponent implements OnChanges {
|
21
|
+
@Input() data: AlertDataI | undefined = undefined;
|
22
|
+
@Output() alertEvent = new EventEmitter<AlertEventI>();
|
23
|
+
|
24
|
+
/**----------------------------------------------------------------
|
25
|
+
* @name constructor
|
26
|
+
*/
|
27
|
+
constructor(private readonly alertController: AlertController) {}
|
28
|
+
|
29
|
+
/**----------------------------------------------------------------
|
30
|
+
* @name ngOnchange
|
31
|
+
* @description Update various values on component input changes
|
32
|
+
* @returns {void}
|
33
|
+
*/
|
34
|
+
ngOnChanges(changes: SimpleChanges): void {
|
35
|
+
const val = changes['data']?.currentValue as typeof this.data;
|
36
|
+
if (val) this.showAlert(val);
|
37
|
+
}
|
38
|
+
|
39
|
+
/**----------------------------------------------------------------
|
40
|
+
* @name showAlert
|
41
|
+
* @description Show
|
42
|
+
* @param {AlertDataI} data
|
43
|
+
* @returns {Promise<void>}
|
44
|
+
*/
|
45
|
+
async showAlert(data: AlertDataI): Promise<void> {
|
46
|
+
const alert = await this.alertController.create({
|
47
|
+
header: data.heading,
|
48
|
+
message: data.message,
|
49
|
+
cssClass: 'care-first-alert',
|
50
|
+
mode: 'md',
|
51
|
+
backdropDismiss: false,
|
52
|
+
buttons: [
|
53
|
+
{
|
54
|
+
text: data.buttonFalse || 'Cancel',
|
55
|
+
handler: () => {
|
56
|
+
this.alertEvent.emit({ identifier: data.alertIdentifier, status: false });
|
57
|
+
alert.dismiss();
|
58
|
+
},
|
59
|
+
cssClass: 'alert-button-cancel',
|
60
|
+
},
|
61
|
+
{
|
62
|
+
text: data.buttonTrue || 'OK',
|
63
|
+
handler: () => {
|
64
|
+
this.alertEvent.emit({ identifier: data.alertIdentifier, status: true });
|
65
|
+
alert.dismiss();
|
66
|
+
},
|
67
|
+
cssClass: 'alert-button-confirm',
|
68
|
+
},
|
69
|
+
],
|
70
|
+
});
|
71
|
+
alert.present();
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/*===============================================
|
2
|
+
===================== Tags ======================
|
3
|
+
===============================================*/
|
4
|
+
|
5
|
+
div[class^='cf-badge-'] {
|
6
|
+
//--- Default Colours
|
7
|
+
--cf-badge-background: var(--cf-app-color-primary);
|
8
|
+
--cf-badge-text-color: var(--cf-app-text-color-light);
|
9
|
+
--cf-badge-border-color: var(--cf-badge-background);
|
10
|
+
|
11
|
+
--cf-svg-overwrite-stroke-color: var(--cf-badge-text-color); //--- Comes from Icon Library
|
12
|
+
|
13
|
+
display: flex;
|
14
|
+
flex-direction: row;
|
15
|
+
gap: 8px;
|
16
|
+
justify-content: center;
|
17
|
+
align-items: center;
|
18
|
+
padding: 8px 16px;
|
19
|
+
border-radius: 6px;
|
20
|
+
width: fit-content;
|
21
|
+
|
22
|
+
background: var(--cf-badge-background);
|
23
|
+
border: 0.2rem solid var(--cf-badge-border-color);
|
24
|
+
> p {
|
25
|
+
width: fit-content;
|
26
|
+
font-size: 1.2rem;
|
27
|
+
font-weight: 500;
|
28
|
+
font-style: normal;
|
29
|
+
line-height: auto;
|
30
|
+
color: var(--cf-badge-text-color);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
/*===============================================
|
35
|
+
================== Variations ===================
|
36
|
+
===============================================*/
|
37
|
+
|
38
|
+
div.cf-badge-feedback-primary {
|
39
|
+
--cf-badge-background: var(--cf-app-color-primary);
|
40
|
+
--cf-badge-text-color: var(--cf-app-text-color-light);
|
41
|
+
--cf-badge-border-color: var(--cf-badge-background);
|
42
|
+
}
|
43
|
+
|
44
|
+
div.cf-badge-alert {
|
45
|
+
--cf-badge-background: var(--cf-app-system-color-error);
|
46
|
+
--cf-badge-text-color: var(--cf-app-text-color-light);
|
47
|
+
--cf-badge-border-color: var(--cf-app-system-color-error);
|
48
|
+
}
|
49
|
+
|
50
|
+
div.cf-badge-accent {
|
51
|
+
--cf-badge-background: var(--cf-app-color-accent);
|
52
|
+
--cf-badge-text-color: var(--cf-app-text-color-light);
|
53
|
+
--cf-badge-border-color: var(--cf-app-color-accent);
|
54
|
+
}
|
55
|
+
|
56
|
+
div.cf-badge-warning {
|
57
|
+
--cf-badge-background: var(--cf-app-system-color-warning);
|
58
|
+
--cf-badge-text-color: var(--cf-app-text-color-grey);
|
59
|
+
--cf-badge-border-color: var(--cf-app-system-color-warning);
|
60
|
+
}
|
61
|
+
|
62
|
+
div.cf-badge-disabled {
|
63
|
+
--cf-badge-background: var(--cf-app-system-color-disabled);
|
64
|
+
--cf-badge-text-color: var(--cf-app-text-color-grey);
|
65
|
+
--cf-badge-border-color: var(--cf-app-system-color-disabled);
|
66
|
+
}
|
67
|
+
|
68
|
+
div.cf-badge-feedback-success {
|
69
|
+
--cf-badge-background: var(--cf-app-system-color-light-success);
|
70
|
+
--cf-badge-text-color: var(--cf-app-system-color-success);
|
71
|
+
--cf-badge-border-color: var(--cf-app-system-color-success);
|
72
|
+
}
|
73
|
+
|
74
|
+
div.cf-badge-feedback-error {
|
75
|
+
--cf-badge-background: var(--cf-app-system-color-light-error);
|
76
|
+
--cf-badge-text-color: var(--cf-app-system-color-error);
|
77
|
+
--cf-badge-border-color: var(--cf-app-system-color-error);
|
78
|
+
}
|
79
|
+
|
80
|
+
div.cf-badge-feedback-warning {
|
81
|
+
--cf-badge-background: var(--cf-app-system-color-light-warning);
|
82
|
+
--cf-badge-text-color: var(--cf-app-system-color-warning);
|
83
|
+
--cf-badge-border-color: var(--cf-app-system-color-warning);
|
84
|
+
}
|
85
|
+
|
86
|
+
div.cf-badge-feedback-busy {
|
87
|
+
--cf-badge-background: var(--cf-app-system-color-light-warning);
|
88
|
+
--cf-badge-text-color: var(--cf-app-system-color-warning);
|
89
|
+
--cf-badge-border-color: var(--cf-app-system-color-warning);
|
90
|
+
|
91
|
+
ion-spinner {
|
92
|
+
color: var(--cf-app-system-color-warning);
|
93
|
+
height: 1.2rem;
|
94
|
+
width: 1.2rem;
|
95
|
+
}
|
96
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
2
|
+
|
3
|
+
import { BadgeComponent } from './badge.component';
|
4
|
+
|
5
|
+
describe('BadgeComponent', () => {
|
6
|
+
let component: BadgeComponent;
|
7
|
+
let fixture: ComponentFixture<BadgeComponent>;
|
8
|
+
|
9
|
+
beforeEach(async () => {
|
10
|
+
await TestBed.configureTestingModule({
|
11
|
+
imports: [BadgeComponent]
|
12
|
+
})
|
13
|
+
.compileComponents();
|
14
|
+
|
15
|
+
fixture = TestBed.createComponent(BadgeComponent);
|
16
|
+
component = fixture.componentInstance;
|
17
|
+
fixture.detectChanges();
|
18
|
+
});
|
19
|
+
|
20
|
+
it('should create', () => {
|
21
|
+
expect(component).toBeTruthy();
|
22
|
+
});
|
23
|
+
});
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/**
|
2
|
+
* CareFirst Chat Badge
|
3
|
+
*
|
4
|
+
* @file badge.component
|
5
|
+
* @description Contains all the logic for generating a CareFirst Chat Badge
|
6
|
+
* @author Jacques Coetzee
|
7
|
+
* @since 2024 - 02 - 22
|
8
|
+
* @usage <cf-badge type="BadgeTypeT" %icon%="IconsT"></cf-badge>
|
9
|
+
*/
|
10
|
+
|
11
|
+
import { Component, Input, type OnChanges, type SimpleChanges } from '@angular/core';
|
12
|
+
//--- Utils
|
13
|
+
import { validateStringValue } from '../../utils/attribute.util';
|
14
|
+
//--- Interfaces
|
15
|
+
import { iconsC, type IconsT } from '../../interfaces/icon.interface';
|
16
|
+
|
17
|
+
/**==============================================
|
18
|
+
* @interface BadgeTypeT
|
19
|
+
* @description Types of badges available
|
20
|
+
*/
|
21
|
+
const badgeTypeC = [
|
22
|
+
'primary',
|
23
|
+
'alert',
|
24
|
+
'accent',
|
25
|
+
'warning',
|
26
|
+
'disabled',
|
27
|
+
'feedback-success',
|
28
|
+
'feedback-error',
|
29
|
+
'feedback-warning',
|
30
|
+
'feedback-busy',
|
31
|
+
] as const;
|
32
|
+
type BadgeTypeT = (typeof badgeTypeC)[number];
|
33
|
+
|
34
|
+
/**==============================================
|
35
|
+
* @name BadgeComponent
|
36
|
+
* */
|
37
|
+
@Component({
|
38
|
+
selector: 'cf-badge',
|
39
|
+
templateUrl: './badge.component.html',
|
40
|
+
styleUrl: './badge.component.scss',
|
41
|
+
})
|
42
|
+
export class BadgeComponent implements OnChanges {
|
43
|
+
@Input() type: BadgeTypeT = 'primary';
|
44
|
+
@Input() icon?: IconsT | undefined;
|
45
|
+
|
46
|
+
//--- Local variables
|
47
|
+
inputType: typeof this.type = 'primary';
|
48
|
+
inputIcon: typeof this.icon | undefined = undefined;
|
49
|
+
|
50
|
+
/**----------------------------------------------------------------
|
51
|
+
* @name ngOnChanges
|
52
|
+
* @description Update various values on input changes
|
53
|
+
* @returns {void}
|
54
|
+
*/
|
55
|
+
ngOnChanges(changes: SimpleChanges): void {
|
56
|
+
//--- Type
|
57
|
+
this.inputType = validateStringValue<BadgeTypeT>(changes, 'type', badgeTypeC.slice(), this.inputType) || 'primary';
|
58
|
+
//--- Icon Start
|
59
|
+
this.inputIcon = validateStringValue<IconsT>(changes, 'icon', iconsC.slice(), this.inputIcon);
|
60
|
+
}
|
61
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<ion-button
|
2
|
+
[style]="'--custom-color: ' + inputCustomColor"
|
3
|
+
[ngClass]="{
|
4
|
+
'cf-button-primary': inputType === 'primary',
|
5
|
+
'cf-button-secondary': inputType === 'secondary',
|
6
|
+
'cf-button-tertiary': inputType === 'tertiary',
|
7
|
+
'text-large': inputFontSize === 'large',
|
8
|
+
'text-small': inputFontSize === 'small',
|
9
|
+
alert: inputAlert,
|
10
|
+
action: inputAction,
|
11
|
+
snug: inputSnug
|
12
|
+
}"
|
13
|
+
mode="md"
|
14
|
+
[disabled]="inputDisabled">
|
15
|
+
<cf-icon *ngIf="inputIconStart" [icon]="inputIconStart" style="--cf-svg-overwrite-stroke-color: var(--button-text-color)"></cf-icon>
|
16
|
+
<p *cfButtonLoader="inputLoading">
|
17
|
+
<ng-content></ng-content>
|
18
|
+
</p>
|
19
|
+
<cf-icon *ngIf="inputIconEnd" [icon]="inputIconEnd" style="--cf-svg-overwrite-stroke-color: var(--button-text-color)"></cf-icon>
|
20
|
+
</ion-button>
|
@@ -0,0 +1,153 @@
|
|
1
|
+
/*===============================================
|
2
|
+
==================== Buttons ====================
|
3
|
+
===============================================*/
|
4
|
+
|
5
|
+
ion-button[class^='cf-button-'] {
|
6
|
+
--custom-color: var(--cf-app-color-primary);
|
7
|
+
--core: var(--custom-color, var(--cf-app-color-primary));
|
8
|
+
width: 100%;
|
9
|
+
min-height: 5.6rem;
|
10
|
+
border-radius: 1rem 0.4rem 1rem 1rem;
|
11
|
+
text-transform: capitalize;
|
12
|
+
overflow: hidden;
|
13
|
+
margin: 0;
|
14
|
+
--padding-top: 1.6rem;
|
15
|
+
--padding-bottom: 1.6rem;
|
16
|
+
--padding-start: 2.4rem;
|
17
|
+
--padding-end: 2.4rem;
|
18
|
+
font-size: 1.2rem;
|
19
|
+
|
20
|
+
> p {
|
21
|
+
width: fit-content;
|
22
|
+
font-weight: 500;
|
23
|
+
font-style: normal;
|
24
|
+
line-height: auto;
|
25
|
+
}
|
26
|
+
|
27
|
+
> :not(:first-child) {
|
28
|
+
margin-left: 2rem;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
ion-button[class^='cf-button-']::part(native) {
|
32
|
+
border-radius: 1rem 0.4rem 1rem 1rem;
|
33
|
+
box-shadow: none;
|
34
|
+
}
|
35
|
+
|
36
|
+
//------------- Action button class -------------
|
37
|
+
//--- *Add to any 'cf-button-' class: %action% %snug%
|
38
|
+
ion-button[class^='cf-button-'].action {
|
39
|
+
border-radius: 0.6rem;
|
40
|
+
min-height: 3.6rem;
|
41
|
+
--padding-top: 0.6rem;
|
42
|
+
--padding-bottom: 0.6rem;
|
43
|
+
--padding-start: 2rem;
|
44
|
+
--padding-end: 2rem;
|
45
|
+
}
|
46
|
+
ion-button[class^='cf-button-'].action::part(native) {
|
47
|
+
border-radius: 0.6rem;
|
48
|
+
}
|
49
|
+
|
50
|
+
ion-button[class^='cf-button-'].snug {
|
51
|
+
width: fit-content;
|
52
|
+
min-height: fit-content;
|
53
|
+
}
|
54
|
+
|
55
|
+
//--------------------- Font --------------------
|
56
|
+
ion-button[class^='cf-button-'].text-large {
|
57
|
+
font-size: 1.6rem;
|
58
|
+
}
|
59
|
+
ion-button[class^='cf-button-'].text-small {
|
60
|
+
font-size: 1rem;
|
61
|
+
}
|
62
|
+
|
63
|
+
/*===============================================
|
64
|
+
==================== Primary ====================
|
65
|
+
===============================================*/
|
66
|
+
|
67
|
+
.cf-button-primary {
|
68
|
+
--background: var(--core);
|
69
|
+
--button-text-color: var(--cf-app-text-color-light);
|
70
|
+
p {
|
71
|
+
color: var(--button-text-color);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
.cf-button-primary[class*='disabled'] {
|
76
|
+
opacity: 100%;
|
77
|
+
--background: var(--cf-app-system-color-disabled);
|
78
|
+
--button-text-color: #9d9d9d;
|
79
|
+
p {
|
80
|
+
color: var(--button-text-color);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
.cf-button-primary.alert:not([class*='disabled']) {
|
85
|
+
--background: var(--cf-app-system-color-error);
|
86
|
+
--button-text-color: var(--cf-app-text-color-light);
|
87
|
+
p {
|
88
|
+
color: var(--button-text-color);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
/*===============================================
|
93
|
+
=================== Secondary ===================
|
94
|
+
===============================================*/
|
95
|
+
|
96
|
+
.cf-button-secondary {
|
97
|
+
--background: transparent;
|
98
|
+
--button-text-color: var(--core);
|
99
|
+
p {
|
100
|
+
color: var(--button-text-color);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
.cf-button-secondary::part(native) {
|
104
|
+
border: 0.2rem solid var(--core);
|
105
|
+
}
|
106
|
+
|
107
|
+
.cf-button-secondary[class*='disabled'] {
|
108
|
+
opacity: 100%;
|
109
|
+
--button-text-color: var(--cf-app-system-color-disabled);
|
110
|
+
p {
|
111
|
+
color: var(--button-text-color);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
.cf-button-secondary[class*='disabled']::part(native) {
|
115
|
+
border: 0.2rem solid var(--cf-app-system-color-disabled);
|
116
|
+
}
|
117
|
+
|
118
|
+
.cf-button-secondary.alert:not([class*='disabled']) {
|
119
|
+
--button-text-color: var(--cf-app-system-color-error);
|
120
|
+
p {
|
121
|
+
color: var(--button-text-color);
|
122
|
+
}
|
123
|
+
}
|
124
|
+
.cf-button-secondary.alert:not([class*='disabled'])::part(native) {
|
125
|
+
border: 0.2rem solid var(--cf-app-system-color-error);
|
126
|
+
}
|
127
|
+
|
128
|
+
/*===============================================
|
129
|
+
=================== Tertiary ====================
|
130
|
+
===============================================*/
|
131
|
+
|
132
|
+
.cf-button-tertiary {
|
133
|
+
--background: transparent;
|
134
|
+
--button-text-color: var(--core);
|
135
|
+
p {
|
136
|
+
color: var(--button-text-color);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
.cf-button-tertiary[class*='disabled'] {
|
141
|
+
opacity: 100%;
|
142
|
+
--button-text-color: var(--cf-app-system-color-disabled);
|
143
|
+
p {
|
144
|
+
color: var(--button-text-color);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
.cf-button-tertiary.alert:not([class*='disabled']) {
|
149
|
+
--button-text-color: var(--cf-app-system-color-error);
|
150
|
+
p {
|
151
|
+
color: var(--button-text-color);
|
152
|
+
}
|
153
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
2
|
+
|
3
|
+
import { ButtonComponent } from './button.component';
|
4
|
+
|
5
|
+
describe('ButtonComponent', () => {
|
6
|
+
let component: ButtonComponent;
|
7
|
+
let fixture: ComponentFixture<ButtonComponent>;
|
8
|
+
|
9
|
+
beforeEach(() => {
|
10
|
+
TestBed.configureTestingModule({
|
11
|
+
declarations: [ButtonComponent]
|
12
|
+
});
|
13
|
+
fixture = TestBed.createComponent(ButtonComponent);
|
14
|
+
component = fixture.componentInstance;
|
15
|
+
fixture.detectChanges();
|
16
|
+
});
|
17
|
+
|
18
|
+
it('should create', () => {
|
19
|
+
expect(component).toBeTruthy();
|
20
|
+
});
|
21
|
+
});
|