Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playwright/cps-accessibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const components: ComponentEntry[] = [
{ route: '/file-upload', name: 'File upload', selector: 'cps-file-upload' },
// { route: '/icon', name: 'Icon', selector: 'cps-icon' },
{ route: '/info-circle', name: 'Info circle', selector: 'cps-info-circle' },
// { route: '/input', name: 'Input', selector: 'cps-input' },
{ route: '/input', name: 'Input', selector: '.example-content cps-input' },
// { route: '/loader', name: 'Loader', selector: 'cps-loader' },
{
route: '/menu',
Expand Down
8 changes: 8 additions & 0 deletions projects/composition/src/app/api-data/cps-datepicker.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
"default": "",
"description": "Label of the datepicker element."
},
{
"name": "ariaLabel",
"optional": false,
"readonly": false,
"type": "string",
"default": "",
"description": "Aria label for the datepicker component, used for accessibility, it takes precedence over label."
},
{
"name": "disabled",
"optional": false,
Expand Down
18 changes: 17 additions & 1 deletion projects/composition/src/app/api-data/cps-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
"default": "",
"description": "Label of the input element."
},
{
"name": "ariaLabel",
"optional": false,
"readonly": false,
"type": "string",
"default": "",
"description": "Aria label for the input component, used for accessibility, it takes precedence over label."
},
{
"name": "hint",
"optional": false,
Expand Down Expand Up @@ -98,9 +106,17 @@
"optional": false,
"readonly": false,
"type": "iconSizeType",
"default": "18px",
"default": "1.125rem",
"description": "Size of icon before input value."
},
{
"name": "prefixIconAriaLabel",
"optional": false,
"readonly": false,
"type": "string",
"default": "",
"description": "Aria label for the clickable prefix icon, required when prefixIconClickable is true."
},
{
"name": "prefixText",
"optional": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h3 class="list-title">Styles</h3>
<div class="list">
<h3 class="list-title">Components</h3>
<cps-input
ariaLabel="Search a component"
prefixIcon="search"
placeholder="Search a component"
appearance="underlined"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="search-input">
<cps-input
ariaLabel="Search a color"
placeholder="Search a color"
(valueChanged)="onSearchChanged($event)"
prefixIcon="search"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- Example of component's usage -->
<div class="search-input">
<cps-input
ariaLabel="Search an icon"
placeholder="Search an icon"
(valueChanged)="onSearchChanged($event)"
hint="Click on any icon to copy its name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@
placeholder="Enter amount"></cps-input>
<div class="sync-val-example">
<cps-input
width="400"
width="25rem"
label="Input with two-way binding, type something in"
[(ngModel)]="syncVal"
hint="This input has a fixed width of 400px"
hint="This input has a fixed width of 25rem"
[ngModelOptions]="{ standalone: true }">
></cps-input
>
<span class="sync-val">{{ syncVal }}</span>
</div>
<cps-input
label="Underlined input"
label="Underlined input with clickable prefix icon"
[prefixIconClickable]="true"
prefixIconAriaLabel="Search"
(prefixIconClicked)="onClickPrefixIcon()"
prefixIcon="search"
appearance="underlined"
placeholder="Search something"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.inputs-group {
gap: 24px;
gap: 1.5rem;
display: flex;
flex-direction: column;
}
Expand All @@ -8,6 +8,6 @@
display: flex;
align-items: center;
.sync-val {
margin-left: 24px;
margin-left: 1.5rem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ValidationErrors,
Validators
} from '@angular/forms';
import { CpsInputComponent } from 'cps-ui-kit';
import { CpsInputComponent, CpsNotificationService } from 'cps-ui-kit';

Check warning on line 11 in projects/composition/src/app/pages/input-page/input-page.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

import ComponentData from '../../api-data/cps-input.json';
import { ComponentDocsViewerComponent } from '../../components/component-docs-viewer/component-docs-viewer.component';
Expand All @@ -25,13 +25,16 @@
styleUrls: ['./input-page.component.scss'],
host: { class: 'composition-page' }
})
export class InputPageComponent implements OnInit {
form!: UntypedFormGroup;
syncVal = '';
componentData = ComponentData;

// eslint-disable-next-line no-useless-constructor
constructor(private _formBuilder: UntypedFormBuilder) {}
constructor(

Check warning on line 34 in projects/composition/src/app/pages/input-page/input-page.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
private _notifService: CpsNotificationService,

Check warning on line 35 in projects/composition/src/app/pages/input-page/input-page.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
private _formBuilder: UntypedFormBuilder

Check warning on line 36 in projects/composition/src/app/pages/input-page/input-page.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
) {}

ngOnInit() {
this.form = this._formBuilder.group({
Expand All @@ -55,4 +58,10 @@
}
return null;
}

onClickPrefixIcon() {

Check warning on line 62 in projects/composition/src/app/pages/input-page/input-page.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
this._notifService.info(`Prefix icon clicked`, undefined, {
timeout: 2000
});

Check warning on line 65 in projects/composition/src/app/pages/input-page/input-page.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}

Check warning on line 67 in projects/composition/src/app/pages/input-page/input-page.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@
role="combobox"
aria-autocomplete="list"
aria-haspopup="listbox"
[attr.aria-busy]="loading || validating ? true : null"
[attr.aria-invalid]="error || externalError ? 'true' : null"
[attr.aria-controls]="optionsListId"
[attr.aria-activedescendant]="activeDescendantId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
[disabled]="disabled"
[value]="stringDate"
[label]="label"
[ariaLabel]="ariaLabel"
prefixIcon="datepicker"
prefixIconAriaLabel="Open calendar"
[placeholder]="placeholder"
(prefixIconClicked)="onClickCalendarIcon()"
[prefixIconClickable]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ $disabled-day-color: var(--cps-color-text-lightest);
width: 100%;
&.focused {
::ng-deep {
input {
border: 1px solid $color-calm !important;
.cps-input-wrap {
border-color: $color-calm !important;
}
.cps-input-prefix-icon {
color: $color-calm !important;
Expand Down Expand Up @@ -82,8 +82,14 @@ $disabled-day-color: var(--cps-color-text-lightest);
.p-datepicker .p-datepicker-header .p-datepicker-title {
line-height: 2rem;
}
.p-datepicker .p-datepicker-header .p-datepicker-title .p-datepicker-select-year,
.p-datepicker .p-datepicker-header .p-datepicker-title .p-datepicker-select-month {
.p-datepicker
.p-datepicker-header
.p-datepicker-title
.p-datepicker-select-year,
.p-datepicker
.p-datepicker-header
.p-datepicker-title
.p-datepicker-select-month {
color: $text-color;
transition:
background-color 0.2s,
Expand All @@ -102,7 +108,10 @@ $disabled-day-color: var(--cps-color-text-lightest);
.p-datepicker-select-month:enabled:hover {
color: $color-calm;
}
.p-datepicker .p-datepicker-header .p-datepicker-title .p-datepicker-select-month {
.p-datepicker
.p-datepicker-header
.p-datepicker-title
.p-datepicker-select-month {
margin-right: 0.5rem;
}
.p-datepicker table {
Expand Down Expand Up @@ -206,7 +215,9 @@ $disabled-day-color: var(--cps-color-text-lightest);
transition: box-shadow 0.2s;
border-radius: 6px;
}
.p-datepicker .p-datepicker-month-view .p-datepicker-month.p-datepicker-day-selected {
.p-datepicker
.p-datepicker-month-view
.p-datepicker-month.p-datepicker-day-selected {
color: $color-calm;
background: $color-selected-background;
font-weight: bold;
Expand All @@ -219,7 +230,9 @@ $disabled-day-color: var(--cps-color-text-lightest);
transition: box-shadow 0.2s;
border-radius: 6px;
}
.p-datepicker .p-datepicker-year-view .p-datepicker-year.p-datepicker-day-selected {
.p-datepicker
.p-datepicker-year-view
.p-datepicker-year.p-datepicker-day-selected {
color: $color-calm;
background: $color-selected-background;
font-weight: bold;
Expand Down Expand Up @@ -254,7 +267,9 @@ $disabled-day-color: var(--cps-color-text-lightest);
}
.p-datepicker:not(.p-disabled)
.p-datepicker-month-view
.p-datepicker-month:not(.p-disabled):not(.p-datepicker-day-selected):hover {
.p-datepicker-month:not(.p-disabled):not(
.p-datepicker-day-selected
):hover {
background: $color-highlight;
}
.p-datepicker:not(.p-disabled)
Expand All @@ -266,7 +281,9 @@ $disabled-day-color: var(--cps-color-text-lightest);
}
.p-datepicker:not(.p-disabled)
.p-yearpicker
.p-datepicker-year:not(.p-disabled):not(.p-datepicker-day-selected):hover {
.p-datepicker-year:not(.p-disabled):not(
.p-datepicker-day-selected
):hover {
background: $color-highlight;
}
.p-datepicker:not(.p-disabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Component,
EventEmitter,
Input,
OnChanges,
OnDestroy,
OnInit,
Optional,
Expand Down Expand Up @@ -43,15 +44,21 @@
templateUrl: './cps-datepicker.component.html',
styleUrls: ['./cps-datepicker.component.scss']
})
export class CpsDatepickerComponent
implements ControlValueAccessor, OnInit, OnDestroy
implements ControlValueAccessor, OnInit, OnChanges, OnDestroy
{
/**
* Label of the datepicker element.
* @group Props
*/
@Input() label = '';

/**
* Aria label for the datepicker component, used for accessibility, it takes precedence over label.
* @group Props
*/
@Input() ariaLabel = '';

Check warning on line 60 in projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

/**
* Determines whether datepicker is disabled.
* @group Props
Expand Down Expand Up @@ -208,6 +215,14 @@
);
}

ngOnChanges() {

Check warning on line 218 in projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
if (!this.label?.trim() && !this.ariaLabel?.trim()) {

Check warning on line 219 in projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 219 in projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
console.error(
'CpsDatepickerComponent: unlabeled datepicker component must have an ariaLabel for accessibility.'
);

Check warning on line 222 in projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 223 in projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 223 in projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}

ngOnDestroy() {
this._statusChangesSubscription?.unsubscribe();
}
Expand Down
Loading
Loading