Skip to content

Commit 9536030

Browse files
Merge pull request #373 from dxc-technology/jcheng-selectInvalid
[Patch] Fix #372 #366 select invalid & date border
2 parents 87694da + e0d8aa2 commit 9536030

File tree

2 files changed

+63
-65
lines changed

2 files changed

+63
-65
lines changed

projects/dxc-ngx-cdk/src/lib/dxc-select/select.ts

Lines changed: 62 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ export abstract class _MatSelectBase<C>
269269
HasTabIndex,
270270
MatFormFieldControl<any>,
271271
CanUpdateErrorState,
272-
CanDisableRipple {
272+
CanDisableRipple
273+
{
273274
/** All of the defined select options. */
274275
abstract options: QueryList<_MatOptionBase>;
275276

@@ -1088,9 +1089,10 @@ export abstract class _MatSelectBase<C>
10881089
option._element.nativeElement.childNodes[1]["firstElementChild"]
10891090
.tagName === "DXC-OPTION-ICON"
10901091
) {
1091-
const trigger = this._elementRef.nativeElement.getElementsByClassName(
1092-
"mat-select-trigger"
1093-
)[0];
1092+
const trigger =
1093+
this._elementRef.nativeElement.getElementsByClassName(
1094+
"mat-select-trigger"
1095+
)[0];
10941096
if (trigger.firstChild.tagName === "DXC-OPTION-ICON") {
10951097
trigger.firstChild.remove();
10961098
}
@@ -1303,64 +1305,10 @@ export abstract class _MatSelectBase<C>
13031305
height: 66.5px;
13041306
position: relative;
13051307
1306-
&.mat-select-disabled {
1307-
cursor: not-allowed;
1308-
.mat-select-trigger {
1309-
cursor: not-allowed;
1310-
border-bottom: 1px solid var(--select-disabledColor) !important;
1311-
outline: none !important;
1312-
}
1313-
.assistiveText {
1314-
color: var(--select-disabledColor) !important;
1315-
}
1316-
.selectLabel {
1317-
color: var(--select-disabledColor) !important;
1318-
}
1319-
.mat-select-arrow {
1320-
color: var(--select-disabledColor) !important;
1321-
}
1322-
}
1323-
&.mat-select-invalid {
1324-
.assistiveText {
1325-
color: var(--select-error) !important;
1326-
}
1327-
.mat-select-trigger {
1328-
border-bottom: 1px solid var(--select-error) !important;
1329-
}
1330-
.selectLabel {
1331-
color: var(--select-error) !important;
1332-
}
1333-
}
1334-
.mat-select-value {
1335-
height: 32px;
1336-
color: var(--select-color);
1337-
}
1338-
.mat-select-arrow {
1339-
color: var(--select-color);
1340-
}
1341-
div.underline.opened {
1342-
border-bottom: 2px solid var(--select-color);
1343-
}
1344-
1345-
.mat-select-trigger {
1346-
border-top-width: 0.84375em;
1347-
border-top-style: solid;
1348-
border-top-color: transparent;
1349-
border-bottom: 1px solid var(--select-color);
1350-
:focus{
1351-
outline: -webkit-focus-ring-color auto 1px;
1352-
outline-color: var(--select-focusColor);
1353-
}
1354-
}
1355-
&.mat-select-disabled .mat-select-value {
1356-
color: var(--select-disabledColor);
1357-
}
13581308
.assistiveText {
13591309
font-size: 12px;
13601310
font-family: var(--fontFamily);
1361-
}
1362-
.assistiveText:not(.mat-select-disabled) {
1363-
color: var(--select-color);
1311+
color: ${this.invalid ? "var(--select-error)" : "var(--select-color)"};
13641312
}
13651313
13661314
.selectLabel {
@@ -1373,14 +1321,16 @@ export abstract class _MatSelectBase<C>
13731321
top: ${this.panelOpen || this.floatingLabel ? "10px" : "19px"};
13741322
font-size: ${this.panelOpen || this.floatingLabel ? "12px" : "16px"};
13751323
transform: ${this.floatingStyles()};
1376-
color: var(--select-color);
1324+
color: ${this.invalid && (this.panelOpen || this.floatingLabel)
1325+
? "var(--select-error)"
1326+
: "var(--select-color)"};
13771327
transition: transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1),
13781328
color 400ms cubic-bezier(0.25, 0.8, 0.25, 1),
13791329
left 400ms cubic-bezier(0.25, 0.8, 0.25, 1),
13801330
top 400ms cubic-bezier(0.25, 0.8, 0.25, 1),
13811331
width 400ms cubic-bezier(0.25, 0.8, 0.25, 1),
13821332
font-size 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
1383-
1333+
13841334
.select-required {
13851335
color: var(--select-required);
13861336
}
@@ -1398,6 +1348,51 @@ export abstract class _MatSelectBase<C>
13981348
width: 24px;
13991349
}
14001350
}
1351+
1352+
.mat-select-value {
1353+
height: 32px;
1354+
}
1355+
1356+
.mat-select-trigger {
1357+
border-top-width: 0.84375em;
1358+
border-top-style: solid;
1359+
border-top-color: transparent;
1360+
border-bottom: 1px solid var(--select-color);
1361+
:focus {
1362+
outline: -webkit-focus-ring-color auto 1px;
1363+
outline-color: var(--select-focusColor);
1364+
}
1365+
}
1366+
1367+
${this.disabled
1368+
? `cursor: not-allowed;
1369+
.mat-select-trigger {
1370+
cursor: not-allowed;
1371+
border-bottom: 1px solid var(--select-disabledColor) !important;
1372+
outline: none !important;
1373+
}
1374+
.assistiveText {
1375+
color: var(--select-disabledColor) !important;
1376+
}
1377+
.selectLabel {
1378+
color: var(--select-disabledColor) !important;
1379+
}
1380+
.mat-select-arrow {
1381+
color: var(--select-disabledColor) !important;
1382+
}
1383+
.mat-select-value {
1384+
color: var(--select-disabledColor);
1385+
}`
1386+
: `.mat-select-value {
1387+
color: var(--select-color);
1388+
}
1389+
.mat-select-arrow {
1390+
color: var(--select-color);
1391+
}
1392+
div.underline.opened {
1393+
border-bottom: 2px solid var(--select-color);
1394+
}
1395+
`}
14011396
`;
14021397
}
14031398

@@ -1457,7 +1452,8 @@ export abstract class _MatSelectBase<C>
14571452
})
14581453
export class DxcSelectComponent
14591454
extends _MatSelectBase<MatSelectChange>
1460-
implements OnInit {
1455+
implements OnInit
1456+
{
14611457
/** The scroll position of the overlay panel, calculated to center the selected option. */
14621458
private _scrollTop = 0;
14631459

@@ -1529,7 +1525,8 @@ export class DxcSelectComponent
15291525
.pipe(takeUntil(this._destroy))
15301526
.subscribe(() => {
15311527
if (this.panelOpen) {
1532-
this._triggerRect = this.trigger.nativeElement.getBoundingClientRect();
1528+
this._triggerRect =
1529+
this.trigger.nativeElement.getBoundingClientRect();
15331530
this._changeDetectorRef.markForCheck();
15341531
}
15351532
});
@@ -1599,7 +1596,8 @@ export class DxcSelectComponent
15991596
* content width in order to constrain the panel within the viewport.
16001597
*/
16011598
private _calculateOverlayOffsetX(): void {
1602-
const overlayRect = this.overlayDir.overlayRef.overlayElement.getBoundingClientRect();
1599+
const overlayRect =
1600+
this.overlayDir.overlayRef.overlayElement.getBoundingClientRect();
16031601
const viewportSize = this._viewportRuler.getViewportSize();
16041602
const isRtl = this._isRtl();
16051603
const paddingWidth = this.multiple

projects/dxc-ngx-cdk/src/lib/theme/componentTokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const componentTokens = {
167167
"--inputText-selectedOptionBackgroundColor": globalTokens.lightGrey,
168168
"--inputText-placeholderColor": globalTokens.lightGrey,
169169
"--inputText-error": globalTokens.darkRed,
170-
"--inputText-focusColor": globalTokens.black,
170+
"--inputText-focusColor": globalTokens.blue,
171171
"--inputText-fontColor": globalTokens.black,
172172
"--inputText-scrollBarThumbColor": globalTokens.darkGrey,
173173
"--inputText-scrollBarTrackColor": globalTokens.lightGrey,

0 commit comments

Comments
 (0)