Skip to content

Commit 118269a

Browse files
itssharmasandeepSandeep Kumar Sharma
andauthored
feat: Adding hover behaviour on select components (#732)
* fix : Adding hovet behaviour for select * fix: lint errors * fix: change hovere color for menu dropdown * fix: prettier errors * fix: multi select icon mode style and some code refactoring Co-authored-by: Sandeep Kumar Sharma <itssharmasandeep@Sandeeps-MacBook-Pro.local>
1 parent 2f3f763 commit 118269a

File tree

6 files changed

+51
-4
lines changed

6 files changed

+51
-4
lines changed

projects/components/src/menu-dropdown/menu-dropdown.component.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
.trigger-label:not(:last-child) {
2424
margin-right: 8px;
2525
}
26+
27+
&:hover {
28+
background-color: $gray-2;
29+
border-radius: 50%;
30+
}
31+
32+
&.labeled:hover {
33+
border-radius: 6px;
34+
}
2635
}
2736

2837
.dropdown-content {

projects/components/src/menu-dropdown/menu-dropdown.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { MenuItemComponent } from './menu-item/menu-item.component';
1111
<ht-event-blocker event="click" [enabled]="true">
1212
<ht-popover [closeOnClick]="true" [disabled]="this.disabled">
1313
<ht-popover-trigger>
14-
<div class="trigger-content" [ngClass]="{ disabled: this.disabled }">
14+
<div class="trigger-content" [ngClass]="{ disabled: this.disabled, labeled: !!this.label }">
1515
<ht-label *ngIf="this.label" class="trigger-label" [label]="this.label"> </ht-label>
1616
<ht-icon *ngIf="this.icon" class="trigger-icon" [icon]="this.icon" size="${IconSize.Small}"></ht-icon>
1717
</div>

projects/components/src/multi-select/multi-select.component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@
2929
cursor: pointer;
3030
height: 34px;
3131

32+
&.open {
33+
background-color: $gray-2;
34+
}
35+
3236
&.icon-mode {
3337
border: 1px solid transparent;
3438
border-radius: 64px;
3539
padding: 0 4px;
3640

41+
&.open {
42+
background: $blue-2;
43+
border-color: $blue-3;
44+
}
45+
3746
&:hover {
3847
color: $blue-5;
3948
background: $blue-1;
@@ -57,6 +66,10 @@
5766
margin-left: auto;
5867
}
5968
}
69+
70+
&:hover {
71+
background-color: $gray-1;
72+
}
6073
}
6174
}
6275

projects/components/src/multi-select/multi-select.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { MultiSelectJustify } from './multi-select-justify';
4444
<div
4545
class="trigger-content"
4646
[style.justify-content]="this.justify"
47-
[ngClass]="this.triggerLabelDisplayMode"
47+
[ngClass]="[this.triggerLabelDisplayMode, this.popoverOpen ? 'open' : '']"
4848
#triggerContainer
4949
>
5050
<ht-icon *ngIf="this.icon" [icon]="this.icon" [size]="this.iconSize"> </ht-icon>

projects/components/src/select/select.component.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
height: 100%;
3232
}
3333

34+
&.open {
35+
background-color: $gray-2;
36+
border-radius: 6px;
37+
}
38+
3439
&.border {
3540
&.group-right {
3641
border-radius: 0 2px 2px 0;
@@ -93,6 +98,11 @@
9398
margin-left: auto;
9499
color: $gray-7;
95100
}
101+
102+
&:hover {
103+
background-color: $gray-1;
104+
border-radius: 6px;
105+
}
96106
}
97107

98108
.icon-only {
@@ -111,6 +121,16 @@
111121
}
112122
}
113123

124+
&.open {
125+
background-color: white;
126+
127+
.icon {
128+
background: $blue-2;
129+
border: 1px solid $blue-3;
130+
border-radius: 50%;
131+
}
132+
}
133+
114134
&.selected {
115135
color: $blue-5;
116136
}

projects/components/src/select/select.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,17 @@ import { SelectSize } from './select-size';
3535
this.groupPosition,
3636
selected ? selected.style.toString() : '',
3737
this.showBorder ? 'border' : '',
38-
this.disabled ? 'disabled' : ''
38+
this.disabled ? 'disabled' : '',
39+
this.popoverOpen ? 'open' : ''
3940
]"
4041
*htLetAsync="this.selected$ as selected"
4142
>
4243
<ht-popover
4344
[disabled]="this.disabled"
4445
[closeOnClick]="true"
4546
class="select-container"
47+
(popoverOpen)="this.popoverOpen = true"
48+
(popoverClose)="this.popoverOpen = false"
4649
[ngSwitch]="this.triggerDisplayMode"
4750
>
4851
<ht-popover-trigger>
@@ -61,7 +64,7 @@ import { SelectSize } from './select-size';
6164
<div
6265
*ngSwitchCase="'${SelectTriggerDisplayMode.Icon}'"
6366
class="trigger-content icon-only"
64-
[ngClass]="this.selected !== undefined ? 'selected' : ''"
67+
[ngClass]="{ selected: this.selected !== undefined, open: this.popoverOpen }"
6568
>
6669
<ht-icon
6770
class="icon"
@@ -168,6 +171,8 @@ export class SelectComponent<V> implements AfterContentInit, OnChanges {
168171

169172
public topControlItems$?: Observable<SelectControlOptionComponent<V>[]>;
170173

174+
public popoverOpen: boolean = false;
175+
171176
public get justifyClass(): string {
172177
if (this.justify !== undefined) {
173178
return this.justify;

0 commit comments

Comments
 (0)