Skip to content

Commit 6fa4509

Browse files
authored
Merge pull request #4073 from IgniteUI/iminchev/combo-samples
feat(combo): update samples content
2 parents 64007d1 + d2a2832 commit 6fa4509

12 files changed

Lines changed: 856 additions & 160 deletions
Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
1+
<div class="combo-features">
2+
<div class="combo-column">
3+
<igx-combo type="border" [data]="lData" displayKey="field" valueKey="field"
4+
searchPlaceholder="Search…" [allowCustomValues]="customValues"
5+
[disableFiltering]="disableFiltering" [showSearchCaseIcon]="showSearchCaseIcon"
6+
[groupKey]="grouping ? 'region' : ''" [disabled]="disabled" [(ngModel)]="selection">
7+
<label igxLabel>Location</label>
8+
</igx-combo>
19

2-
<igx-combo #combo class="combo" [data]="lData" [displayKey]="'field'" [valueKey]="'field'"
3-
placeholder="Location(s)" searchPlaceholder="Search..." [allowCustomValues]="customValues"
4-
(addition)="handleAddition($event)" [disableFiltering]="disableFiltering"
5-
[showSearchCaseIcon]="showSearchCaseIcon" [itemsMaxHeight]="255" [disabled]="disabled">
6-
</igx-combo>
10+
<div class="selection-panel">
11+
<span class="selection-title" id="features-selection-title">Selection</span>
12+
@if (selection.length) {
13+
<ul class="selection-list" aria-labelledby="features-selection-title">
14+
@for (item of selection; track item) {
15+
<li>{{ item }}</li>
16+
}
17+
</ul>
18+
} @else {
19+
<span class="selection-empty">No items selected</span>
20+
}
21+
</div>
22+
</div>
723

8-
<igx-switch [(ngModel)]="disableFiltering">Disable Filtering</igx-switch><br />
9-
<igx-switch [disabled]="disableFiltering" [(ngModel)]="showSearchCaseIcon">Show Case-sensitive Icon</igx-switch><br />
10-
<igx-switch [(ngModel)]="customValues">Allow Custom Values</igx-switch><br />
11-
<igx-switch (change)="enableGroups($event)">Enable Grouping</igx-switch><br />
12-
<igx-switch [(ngModel)]="disabled">Disable Combo</igx-switch>
24+
<div class="controls">
25+
<igx-switch [(ngModel)]="disableFiltering">Disable Filtering</igx-switch>
26+
<igx-switch [disabled]="disableFiltering" [(ngModel)]="showSearchCaseIcon">Show Case-sensitive Icon</igx-switch>
27+
<igx-switch [(ngModel)]="customValues">Allow Custom Values</igx-switch>
28+
<igx-switch [(ngModel)]="grouping">Enable Grouping</igx-switch>
29+
<igx-switch [(ngModel)]="disabled">Disable Combo</igx-switch>
30+
</div>
31+
</div>
Lines changed: 112 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,113 @@
1-
.combo, igx-switch {
2-
margin: 8px;
3-
width: 430px;
1+
/* Aktiv Grotesk, from the same Adobe Fonts kit the docs use. */
2+
@import url("https://use.typekit.net/bng2zgw.css");
3+
4+
/* The app clips the page at the frame, so a sample too tall for it scrolls here, from its top. */
5+
:host {
6+
display: flex;
7+
align-items: safe center;
8+
justify-content: center;
9+
height: 100%;
10+
overflow: auto;
11+
}
12+
13+
/* The combo sits in the middle, and the switches in the space on its right.
14+
When the frame is narrow, the combo moves left to make room for them. */
15+
.combo-features {
16+
display: grid;
17+
flex: 1;
18+
grid-template-columns: 1fr minmax(0, 22.5rem) 1fr;
19+
align-items: center;
20+
column-gap: 3rem;
21+
padding: 1rem;
22+
}
23+
24+
/* Keeps room below the combo for its open dropdown, so the two stay centered together. */
25+
.combo-column {
26+
grid-column: 2;
27+
min-height: 17.5rem;
28+
}
29+
30+
/* The app makes every component large; the combo keeps the medium size of the design.
31+
Its list carries the size into the overlay. */
32+
igx-combo {
33+
--ig-size: var(--ig-size-medium);
34+
}
35+
36+
/* The selected values of the combo, under it. */
37+
.selection-panel {
38+
display: flex;
39+
flex-direction: column;
40+
gap: 0.375rem;
41+
margin-top: 1.25rem;
42+
padding: 0.75rem 1rem;
43+
font-family: aktiv-grotesk, sans-serif;
44+
}
45+
46+
.selection-title {
47+
color: var(--ig-gray-900);
48+
font-size: var(--ig-subtitle-2-font-size);
49+
font-weight: var(--ig-subtitle-2-font-weight);
50+
line-height: var(--ig-subtitle-2-line-height);
51+
letter-spacing: var(--ig-subtitle-2-letter-spacing);
52+
}
53+
54+
.selection-list,
55+
.selection-empty {
56+
font-size: var(--ig-body-2-font-size);
57+
font-weight: var(--ig-body-2-font-weight);
58+
line-height: var(--ig-body-2-line-height);
59+
letter-spacing: var(--ig-body-2-letter-spacing);
60+
}
61+
62+
/* A long selection scrolls, so the column keeps its height and the combo stays in place. */
63+
.selection-list {
64+
display: flex;
65+
flex-direction: column;
66+
gap: 0.375rem;
67+
max-height: 8rem;
68+
margin: 0;
69+
padding: 0;
70+
overflow-y: auto;
71+
list-style: none;
72+
color: var(--ig-gray-700);
73+
}
74+
75+
.selection-empty {
76+
color: var(--ig-gray-500);
77+
}
78+
79+
/* Each label stays on one line. */
80+
.controls {
81+
display: flex;
82+
flex-direction: column;
83+
align-items: flex-start;
84+
gap: 1.625rem;
85+
width: max-content;
86+
}
87+
88+
/* The switch labels use the typeface of the selection. */
89+
.controls ::ng-deep .igx-switch__label {
90+
font-family: aktiv-grotesk, sans-serif;
91+
}
92+
93+
/* Too narrow for a side column: the switches move under the combo, packed to fit the frame. */
94+
@media (max-width: 44.5rem) {
95+
.combo-features {
96+
grid-template-columns: minmax(0, 22.5rem);
97+
justify-content: center;
98+
row-gap: 1.5rem;
99+
}
100+
101+
.combo-column {
102+
grid-column: 1;
103+
min-height: 0;
104+
}
105+
106+
.selection-list {
107+
max-height: 4rem;
108+
}
109+
110+
.controls {
111+
gap: 0.75rem;
112+
}
4113
}
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Component, OnInit, ViewChild } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
22
import { IgxComboComponent } from 'igniteui-angular/combo';
3+
import { IgxLabelDirective } from 'igniteui-angular/input-group';
34
import { IgxSwitchComponent } from 'igniteui-angular/switch';
45
import { localData } from './local-data';
56
import { FormsModule } from '@angular/forms';
@@ -8,25 +9,18 @@ import { FormsModule } from '@angular/forms';
89
selector: 'app-combo',
910
styleUrls: ['./combo-features.component.scss'],
1011
templateUrl: './combo-features.component.html',
11-
imports: [IgxComboComponent, IgxSwitchComponent, FormsModule]
12+
imports: [IgxComboComponent, IgxLabelDirective, IgxSwitchComponent, FormsModule]
1213
})
1314
export class ComboFeaturesComponent implements OnInit{
14-
@ViewChild('combo', { read: IgxComboComponent, static: true }) public combo: IgxComboComponent;
15-
// eslint-disable-next-line @typescript-eslint/naming-convention
16-
public GROUP_KEY = 'region';
1715
public lData: any[];
1816
public disableFiltering = false;
1917
public showSearchCaseIcon = false;
20-
public customValues = true;
18+
public customValues = false;
19+
public grouping = false;
2120
public disabled = false;
21+
public selection: string[] = [];
2222

2323
public ngOnInit() {
2424
this.lData = localData;
2525
}
26-
27-
public handleAddition(event) { }
28-
29-
public enableGroups(event) {
30-
this.combo.groupKey = event.checked ? this.GROUP_KEY : '';
31-
}
3226
}

‎src/app/lists/combo/combo-features/local-data.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ const division = {
1212
'South Atlantic 01': ['Delaware', 'Florida', 'Georgia', 'Maryland'],
1313
'South Atlantic 02': ['North Carolina', 'South Carolina', 'Virginia',
1414
'District of Columbia', 'West Virginia'],
15-
'South Atlantic 03': ['District of Columbia', 'West Virginia'],
1615
'East South Central 01': ['Alabama', 'Kentucky'],
1716
'East South Central 02': ['Mississippi', 'Tennessee'],
18-
'West South Central': ['Arkansas', 'Louisiana', 'Oklahome', 'Texas'],
17+
'West South Central': ['Arkansas', 'Louisiana', 'Oklahoma', 'Texas'],
1918
'Mountain': ['Arizona', 'Colorado', 'Idaho', 'Montana', 'Nevada', 'New Mexico', 'Utah', 'Wyoming'],
2019
'Pacific 01': ['Alaska', 'California'],
2120
'Pacific 02': ['Hawaii', 'Oregon', 'Washington']
@@ -27,7 +26,8 @@ for (const key of keys) {
2726
division[key].map((e) => {
2827
localData.push({
2928
field: e,
30-
region: key.substring(0, key.length - 3)
29+
// The number only splits a region into shorter lists: "Pacific 01" is "Pacific".
30+
region: key.replace(/ \d+$/, '')
3131
});
3232
});
3333
}
Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1-
<igx-combo
2-
placeholder="Choose option(s)"
3-
[data]="items"
4-
valueKey="name"
5-
displayKey="name"
6-
[overlaySettings]="overlaySettings">
7-
</igx-combo>
1+
<div class="combo-column">
2+
<igx-combo
3+
#combo
4+
type="border"
5+
[data]="people"
6+
valueKey="name"
7+
displayKey="name"
8+
groupKey="department"
9+
searchPlaceholder="Search people…"
10+
[(ngModel)]="selectedPeople"
11+
[overlaySettings]="overlaySettings">
12+
<label igxLabel>Team members</label>
13+
</igx-combo>
14+
15+
<div class="selection-panel">
16+
<span class="selection-title" id="overlay-selection-title">Selection</span>
17+
@if (selectedPeople.length) {
18+
<ul class="selection-list" aria-labelledby="overlay-selection-title">
19+
@for (person of selectedPeople; track person) {
20+
<li>{{ person }}</li>
21+
}
22+
</ul>
23+
} @else {
24+
<span class="selection-empty">No items selected</span>
25+
}
26+
</div>
27+
</div>
Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,64 @@
1-
.igx-combo {
2-
width: 430px;
3-
margin: 8px;
1+
/* Aktiv Grotesk, from the same Adobe Fonts kit the docs use. */
2+
@import url("https://use.typekit.net/bng2zgw.css");
3+
4+
:host {
5+
display: flex;
6+
align-items: center;
7+
justify-content: center;
8+
height: 100%;
9+
}
10+
11+
/* Keeps room below the combo for its open list, so the two stay centered together. */
12+
.combo-column {
13+
width: 22.5rem;
14+
min-height: 18.5rem;
15+
}
16+
17+
/* The app makes every component large; the combo keeps the medium size of the design.
18+
Its list carries the size into the overlay. */
19+
igx-combo {
20+
--ig-size: var(--ig-size-medium);
21+
}
22+
23+
/* The selected values of the combo, under it. */
24+
.selection-panel {
25+
display: flex;
26+
flex-direction: column;
27+
gap: 0.375rem;
28+
margin-top: 1.25rem;
29+
padding: 0.75rem 1rem;
30+
font-family: aktiv-grotesk, sans-serif;
31+
}
32+
33+
.selection-title {
34+
color: var(--ig-gray-900);
35+
font-size: var(--ig-subtitle-2-font-size);
36+
font-weight: var(--ig-subtitle-2-font-weight);
37+
line-height: var(--ig-subtitle-2-line-height);
38+
letter-spacing: var(--ig-subtitle-2-letter-spacing);
39+
}
40+
41+
.selection-list,
42+
.selection-empty {
43+
font-size: var(--ig-body-2-font-size);
44+
font-weight: var(--ig-body-2-font-weight);
45+
line-height: var(--ig-body-2-line-height);
46+
letter-spacing: var(--ig-body-2-letter-spacing);
47+
}
48+
49+
/* A long selection scrolls, so the column keeps its height and the combo stays in place. */
50+
.selection-list {
51+
display: flex;
52+
flex-direction: column;
53+
gap: 0.375rem;
54+
max-height: 8rem;
55+
margin: 0;
56+
padding: 0;
57+
overflow-y: auto;
58+
list-style: none;
59+
color: var(--ig-gray-700);
60+
}
61+
62+
.selection-empty {
63+
color: var(--ig-gray-500);
464
}
Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,47 @@
1-
import { Component } from '@angular/core';
2-
import { GlobalPositionStrategy, OverlaySettings } from 'igniteui-angular/core';
1+
import { AfterViewInit, Component, ViewChild } from '@angular/core';
2+
import { FormsModule } from '@angular/forms';
3+
import { OverlaySettings } from 'igniteui-angular/core';
34
import { IgxComboComponent } from 'igniteui-angular/combo';
4-
import { scaleInCenter, scaleOutCenter } from 'igniteui-angular/animations';
5+
import { IgxLabelDirective } from 'igniteui-angular/input-group';
56

67
@Component({
78
selector: 'app-combo-overlay',
89
templateUrl: 'combo-overlay.component.html',
910
styleUrls: ['combo-overlay.component.scss'],
10-
imports: [IgxComboComponent]
11+
imports: [IgxComboComponent, IgxLabelDirective, FormsModule]
1112
})
12-
export class ComboOverlayComponent {
13-
public items = [{ name: 'Option 1' }, { name: 'Option 2' }, { name: 'Option 3' },
14-
{ name: 'Option 4' }, { name: 'Option 5' }, { name: 'Option 6' },
15-
{ name: 'Option 7' }, { name: 'Option 8' }, { name: 'Option 9' }];
13+
export class ComboOverlayComponent implements AfterViewInit {
14+
@ViewChild('combo', { static: true })
15+
public combo: IgxComboComponent;
1616

17+
public people = [
18+
{ name: 'Ana Petrova', department: 'Engineering' },
19+
{ name: 'Marc Lee', department: 'Engineering' },
20+
{ name: 'Priya Nair', department: 'Engineering' },
21+
{ name: 'Tom Becker', department: 'Engineering' },
22+
{ name: 'Yuki Sato', department: 'Engineering' },
23+
{ name: 'Daniel Kim', department: 'Finance' },
24+
{ name: 'Elena Popescu', department: 'Finance' },
25+
{ name: 'Grace Okafor', department: 'Finance' },
26+
{ name: 'Hugo Martin', department: 'Marketing' },
27+
{ name: 'Isabel Costa', department: 'Marketing' },
28+
{ name: 'Lena Fischer', department: 'Marketing' },
29+
{ name: 'Jonas Berg', department: 'Sales' },
30+
{ name: 'Omar Haddad', department: 'Sales' },
31+
{ name: 'Sofia Rossi', department: 'Sales' }
32+
];
33+
34+
public selectedPeople = ['Ana Petrova', 'Marc Lee'];
35+
36+
/* Merged over the combo's own settings, so the list still opens below the combo.
37+
A modal overlay dims the page behind the list, and a click outside closes it. */
1738
public overlaySettings: OverlaySettings = {
18-
positionStrategy: new GlobalPositionStrategy({ openAnimation: scaleInCenter, closeAnimation: scaleOutCenter }),
1939
modal: true,
2040
closeOnOutsideClick: true
2141
};
42+
43+
// Opens the list on load, so the sample shows the overlay right away.
44+
public ngAfterViewInit() {
45+
this.combo.open();
46+
}
2247
}

0 commit comments

Comments
 (0)