Skip to content

Commit d894e7d

Browse files
authored
Merge pull request #703 from dxc-technology/fix-select-aida
[Minor] Fix tokens and visual issues in select
2 parents 9ce18a0 + d26a668 commit d894e7d

File tree

13 files changed

+252
-110
lines changed

13 files changed

+252
-110
lines changed

projects/dxc-ngx-cdk-site/src/app/pages/theme-builder/previews/select-preview/select-preview.component.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
<dxc-select label="Label" helperText="HelperText" margin="xsmall" [options]="array1" (onChange)="onChange($event)"
66
(onBlur)="onBlur($event)" [optional]="true" placeholder="Another placeholder" size="large" tabIndex="3">
77
</dxc-select>
8-
<dxc-select label="Label" helperText="HelperText" margin="xsmall" [options]="array2" [optional]="true"
9-
(onChange)="onChange($event)" placeholder="Another placeholder"></dxc-select>
8+
<dxc-select
9+
label="Label"
10+
helperText="HelperText"
11+
margin="xsmall"
12+
[options]="array2"
13+
[optional]="true"
14+
(onChange)="onChange($event)"
15+
placeholder="This is a very very very long placeholder to test the ellipsis"
16+
></dxc-select>
1017
</tbuilder-component-mode>
1118

1219
<tbuilder-component-mode text="Searchable">

projects/dxc-ngx-cdk-site/src/app/pages/theme-builder/previews/select-preview/select-preview.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ import { OptionGroup } from "@dxc-technology/halstack-angular/lib/dxc-select/int
88
})
99
export class SelectPreviewComponent implements OnInit {
1010
selectedValues: string = "";
11-
1211
array1: Option[] = [
1312
{
1413
label: "label1",
1514
value: "1",
1615
icon: '<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="18px" viewBox="0 0 24 24" width="18px" fill="#000000"><g><path d="M0,0h24v24H0V0z" fill="none"/></g><g><g><path d="M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z"/></g></g></svg>',
1716
},
18-
{ label: "label2", value: "2" },
17+
{
18+
label: "This is a very very very long label to test the ellipsis",
19+
value: "2",
20+
},
1921
{ label: "label6", value: "6" },
2022
{ label: "label9", value: "9" },
2123
{ label: "aida", value: "10" },
@@ -31,7 +33,10 @@ export class SelectPreviewComponent implements OnInit {
3133
{
3234
label: "Group label 1",
3335
options: [
34-
{ label: "label3", value: "3" },
36+
{
37+
label: "This is a very very very long label to test the ellipsis",
38+
value: "3",
39+
},
3540
{ label: "label4", value: "4" },
3641
{
3742
label: "label5",

projects/dxc-ngx-cdk-site/src/app/pages/theme-builder/themes/AdvancedTheme.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,8 @@
934934
"underlineFocusColor": "#000000",
935935
"underlineThickness": "1px",
936936
"arrowColor": "#000000",
937-
"systemMessageFontColor": "#666666"
937+
"systemMessageFontColor": "#666666",
938+
"focusListOptionBorderColor": "#0095ff"
938939
},
939940
"sidenav": {
940941
"backgroundColor": "#F8F8F8",

projects/dxc-ngx-cdk-site/src/app/pages/theme-builder/themes/schemas/Advanced.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,8 @@
938938
"valueFontColorOnDark": "color",
939939
"arrowColor": "color",
940940
"arrowColorOnDark": "color",
941-
"systemMessageFontColor": "color"
941+
"systemMessageFontColor": "color",
942+
"focusListOptionBorderColor": "color"
942943
},
943944
"sidenav": {
944945
"backgroundColor": "color",

projects/dxc-ngx-cdk/src/lib/dxc-select/dxc-select-option-selected/dxc-select-option-selected.component.html

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
<div class="labelsContainer" #labelsContainer>
22
<ng-container *ngIf="!(multiple && searchable)">
33
<span
4-
*ngFor="let option of selectedOptions; last as last"
54
class="selectedOption"
5+
[ngClass]="{
6+
isOptionalLabel: isOptionalLabel()
7+
}"
68
>
7-
<!-- <span
8-
*ngIf="option?.icon"
9-
class="iconLabel"
10-
[innerHTML]="option.icon | safeHtml"
11-
></span> -->
12-
<span
13-
class="selectedLabel"
14-
[ngClass]="{
15-
isOptionalLabel: !multiple && this.selectedOptions[0]?.value === ''
16-
}"
17-
>
18-
{{ option.label }} <span *ngIf="!last" class="comma">,</span>
19-
</span>
9+
{{ selectedOptions }}
2010
</span>
2111
</ng-container>
2212

projects/dxc-ngx-cdk/src/lib/dxc-select/dxc-select-option-selected/dxc-select-option-selected.component.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export class DxcSelectOptionSelectedComponent implements OnInit {
2323
@Input() placeholder: string;
2424

2525
subscriptor: any;
26-
selectedOptions: Array<Option> = [];
26+
selectedOptions: string = "";
27+
array: Array<Option> = [];
2728

2829
defaultInputs = new BehaviorSubject<any>({
2930
multiple: false,
@@ -33,13 +34,22 @@ export class DxcSelectOptionSelectedComponent implements OnInit {
3334
constructor(public service: SelectService) {
3435
this.subscriptor = this.service.selectedValues.subscribe((newOptions) => {
3536
if (newOptions) {
37+
this.selectedOptions = "";
3638
if (Array.isArray(newOptions)) {
37-
this.selectedOptions = newOptions;
39+
this.array = newOptions;
40+
newOptions.forEach((option, index) => {
41+
if (index === 0) {
42+
this.selectedOptions = option.label;
43+
} else {
44+
this.selectedOptions = this.selectedOptions + ", " + option.label;
45+
}
46+
});
3847
} else {
39-
this.selectedOptions[0] = newOptions;
48+
this.array[0] = newOptions;
49+
this.selectedOptions = newOptions.label;
4050
}
4151
} else {
42-
this.selectedOptions = [];
52+
this.selectedOptions = "";
4353
}
4454
});
4555
}
@@ -75,47 +85,39 @@ export class DxcSelectOptionSelectedComponent implements OnInit {
7585
}
7686
}
7787

88+
isOptionalLabel() {
89+
return !this.multiple && this.array[0]?.value === "";
90+
}
91+
7892
getDynamicStyle(inputs) {
7993
return css`
8094
display: flex;
8195
max-width: 100%;
96+
width: 100%;
8297
div.labelsContainer {
8398
width: 100%;
84-
overflow: hidden;
85-
white-space: nowrap;
86-
text-overflow: ellipsis;
87-
display: inline-block;
8899
.selectedOption {
89-
text-align: left;
90-
display: inline-flex;
91-
align-items: center;
100+
overflow: hidden;
101+
white-space: nowrap;
102+
text-overflow: ellipsis;
103+
display: block;
104+
width: 100%;
92105
font-family: var(--select-fontFamily);
93106
font-size: var(--select-valueFontSize);
94107
font-style: var(--select-valueFontStyle);
95108
font-weight: var(--select-valueFontWeight);
96109
color: ${inputs.disabled
97110
? "var(--select-disabledColor)"
98111
: "var(--select-valueFontColor)"};
99-
.iconLabel {
100-
width: 24px;
101-
height: 24px;
102-
display: inline-flex;
103-
align-items: center;
104-
}
105-
.comma {
106-
margin-right: 4px;
107-
}
108-
.iconLabel {
109-
margin-right: 0.25rem;
110-
}
111-
.isOptionalLabel {
112+
&.isOptionalLabel {
112113
color: ${inputs.disabled
113114
? "var(--select-disabledColor)"
114115
: "#000000b3"};
115116
}
116117
}
117118
.notSelectedLabel {
118119
text-align: left;
120+
white-space: nowrap;
119121
font-family: var(--select-fontFamily);
120122
font-size: var(--select-placeholderFontSize);
121123
font-style: var(--select-placeholderFontStyle);

projects/dxc-ngx-cdk/src/lib/dxc-select/dxc-select-option/dxc-select-option.component.html

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@
1111
class="iconLabel"
1212
[innerHTML]="option.icon | safeHtml"
1313
></div>
14-
<span class="label" [attr.aria-selected]="this.selected" role="option">{{
15-
option.label
16-
}}</span>
14+
<span class="label"
15+
><span [attr.aria-selected]="this.selected" role="option">{{
16+
option.label
17+
}}</span></span
18+
>
1719
<span
1820
class="checkIcon"
1921
*ngIf="
2022
!multiple && this.service.getSelectedValues()?.value === option.value
2123
"
2224
>
23-
<svg
24-
xmlns="http://www.w3.org/2000/svg"
25-
viewBox="0 0 24 24"
26-
fill="#000000"
27-
>
25+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000000">
2826
<path d="M0 0h24v24H0z" fill="none" />
2927
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" />
3028
</svg>
@@ -39,20 +37,18 @@
3937
(mousedown)="handleOptionMouseDown($event)"
4038
tabindex="-1"
4139
>
42-
<span class="label" [attr.aria-selected]="this.selected" role="option">{{
43-
option.label
44-
}}</span>
40+
<span class="label"
41+
><span [attr.aria-selected]="this.selected" role="option">{{
42+
option.label
43+
}}</span></span
44+
>
4545
<span
4646
class="checkIcon"
4747
*ngIf="
4848
!multiple && this.service.getSelectedValues()?.value === option.value
4949
"
5050
>
51-
<svg
52-
xmlns="http://www.w3.org/2000/svg"
53-
viewBox="0 0 24 24"
54-
fill="#000000"
55-
>
51+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000000">
5652
<path d="M0 0h24v24H0z" fill="none" />
5753
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" />
5854
</svg>
@@ -76,8 +72,10 @@
7672
</dxc-checkbox>
7773
<div *ngIf="option.icon !== undefined && option.icon !== null">
7874
<span class="iconLabel" [innerHTML]="option.icon | safeHtml"></span>
79-
<span class="label" [attr.aria-selected]="this.selected" role="option">{{
80-
option.label
81-
}}</span>
75+
<span class="label"
76+
><span [attr.aria-selected]="this.selected" role="option">{{
77+
option.label
78+
}}</span></span
79+
>
8280
</div>
8381
</span>

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

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,29 @@ export class DxcSelectOptionComponent implements OnInit {
106106
height: 32px;
107107
:hover {
108108
cursor: pointer;
109-
background-color: var(--select-unselectedHoverListOptionBackgroundColor);
109+
background-color: var(
110+
--select-unselectedHoverListOptionBackgroundColor
111+
);
110112
}
111113
:active {
112-
background-color: var(--select-unselectedActiveListOptionBackgroundColor);
114+
background-color: var(
115+
--select-unselectedActiveListOptionBackgroundColor
116+
);
113117
}
114118
${inputs.checked && inputs.multiple ? this.setSelectedStyles() : ""}
115119
&.selected {
116120
${this.setSelectedStyles()}
117121
&.focused {
118-
background-color: var(--select-selectedHoverListOptionBackgroundColor);
122+
background-color: var(
123+
--select-selectedHoverListOptionBackgroundColor
124+
);
119125
}
120126
.optionLabel {
121127
border-bottom: 1px solid transparent;
122128
}
123129
}
124130
&.focused {
125-
box-shadow: inset 0 0 0 2px #0095ff;
131+
box-shadow: inset 0 0 0 2px var(--select-focusListOptionBorderColor);
126132
.optionLabel {
127133
border-bottom: 1px solid transparent;
128134
}
@@ -134,33 +140,40 @@ export class DxcSelectOptionComponent implements OnInit {
134140
margin: 2px 8px;
135141
height: 100%;
136142
box-sizing: border-box;
137-
border-bottom: 1px solid var(--select-ListOptionDividerColor);
143+
border-bottom: 1px solid var(--select-listOptionDividerColor);
144+
overflow: hidden;
138145
.iconLabel {
139146
display: flex;
140147
align-items: center;
141148
margin-left: ${!inputs.multiple ? "8px" : ""};
142149
svg {
143-
fill: var(--select-ListOptionIconColor);
150+
fill: var(--select-listOptionIconColor);
144151
}
145152
}
146153
.label {
147154
width: 100%;
148-
height: 100%;
149-
display: flex;
150-
align-items: center;
155+
overflow: hidden;
156+
white-space: nowrap;
157+
text-overflow: ellipsis;
158+
display: inline-block;
159+
align-self: center;
151160
margin-left: 0.5rem;
152161
margin-right: 0.5rem;
153-
font-family: var(--select-fontFamily);
154-
font-size: var(--select-ListOptionFontSize);
155-
font-style: var(--select-ListOptionFontStyle);
156-
font-weight: var(--select-ListOptionFontWeight);
157-
color: var(--select-ListOptionFontColor);
162+
span {
163+
width: 100%;
164+
height: 100%;
165+
font-family: var(--select-fontFamily);
166+
font-size: var(--select-listOptionFontSize);
167+
font-style: var(--select-listOptionFontStyle);
168+
font-weight: var(--select-listOptionFontWeight);
169+
color: var(--select-listOptionFontColor);
170+
}
158171
}
159172
.checkIcon {
160173
display: flex;
161-
margin-right: 8px;
174+
margin-right: 0.5rem;
162175
align-items: center;
163-
svg{
176+
svg {
164177
fill: var(--select-selectedListOptionIconColor);
165178
width: 16px;
166179
height: 16px;
@@ -171,8 +184,24 @@ export class DxcSelectOptionComponent implements OnInit {
171184
width: 100%;
172185
height: 100%;
173186
display: flex;
187+
align-items: center;
174188
div {
175189
display: flex;
190+
overflow: hidden;
191+
}
192+
dxc-checkbox {
193+
.mat-checkbox-label {
194+
span:last-child {
195+
display: inline-grid;
196+
.checkboxLabel {
197+
overflow: hidden;
198+
white-space: nowrap;
199+
text-overflow: ellipsis;
200+
display: block;
201+
width: 100%;
202+
}
203+
}
204+
}
176205
}
177206
}
178207
`;

0 commit comments

Comments
 (0)