-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select): add key event functionality
- Loading branch information
patrickjahr
committed
Apr 18, 2024
1 parent
db594bc
commit c326877
Showing
24 changed files
with
337 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { animate, AnimationMetadata, style } from '@angular/animations'; | ||
|
||
export const fadeFactory = ( | ||
from: number, | ||
to: number, | ||
duration = '200ms' | ||
): AnimationMetadata[] => { | ||
return [ | ||
style({ opacity: from }), | ||
animate(`${duration} ease`, style({ opacity: to })), | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { animate, AnimationMetadata, style } from '@angular/animations'; | ||
|
||
export const zoomFactory = ( | ||
from: number, | ||
to: number, | ||
duration = '500ms' | ||
): AnimationMetadata[] => { | ||
return [ | ||
style({ opacity: from, scale: from }), | ||
animate( | ||
`${duration} cubic-bezier(0.05, 0.7, 0.1, 1)`, | ||
style({ opacity: to, scale: to }) | ||
), | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 27 additions & 19 deletions
46
...app/src/app/pages/select-sample/select-options-sample/select-options-sample.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
margin-top: 0.5rem; | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
max-height: 200px; | ||
margin-top: 0.5rem; | ||
overflow-x: auto; | ||
} | ||
|
||
sk-select-option { | ||
background-color: #fff; | ||
color: #000; | ||
padding: 0.5rem 1rem; | ||
cursor: pointer; | ||
transition: color 0.3s ease-in-out, font-weight 0.3s ease-in-out, | ||
font-size 0.3s ease-in-out; | ||
display: flex; | ||
gap: 0.5rem; | ||
background-color: #fff; | ||
color: #000; | ||
padding: 0.5rem 1rem; | ||
cursor: pointer; | ||
transition: color 0.3s ease-in-out, font-weight 0.3s ease-in-out; | ||
} | ||
|
||
sk-select-option:first-child { | ||
border-top-left-radius: 0.25rem; | ||
border-top-right-radius: 0.25rem; | ||
border-top-left-radius: 0.25rem; | ||
border-top-right-radius: 0.25rem; | ||
} | ||
|
||
sk-select-option:last-child { | ||
border-bottom-left-radius: 0.25rem; | ||
border-bottom-right-radius: 0.25rem; | ||
border-bottom-left-radius: 0.25rem; | ||
border-bottom-right-radius: 0.25rem; | ||
} | ||
|
||
@media (hover) { | ||
sk-select-option:hover { | ||
color: deeppink; | ||
font-weight: bold; | ||
font-size: 1.5em; | ||
} | ||
sk-select-option:hover { | ||
color: var(--sk-primary-color); | ||
font-weight: bold; | ||
} | ||
} | ||
|
||
sk-select-option:focus { | ||
border: none; | ||
color: var(--sk-primary-color); | ||
font-weight: bold; | ||
} |
11 changes: 6 additions & 5 deletions
11
...pp/src/app/pages/select-sample/select-options-sample/select-options-sample.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<sk-select-option [value]="{ data: 1 }">Test 1</sk-select-option> | ||
<sk-select-option [value]="{ data: 2 }">Test 2</sk-select-option> | ||
<sk-select-option [value]="{ data: 3 }">Test 3</sk-select-option> | ||
<sk-select-option [value]="{ data: 4 }">Test 4</sk-select-option> | ||
<sk-select-option [value]="{ data: 5 }">Test 5</sk-select-option> | ||
@for (option of options(); track option.value) { | ||
<sk-select-option [value]="option.value"> | ||
<fa-icon [icon]="option.icon"></fa-icon> | ||
<span>{{ option.label }}</span> | ||
</sk-select-option> | ||
} |
6 changes: 5 additions & 1 deletion
6
...src/app/pages/select-sample/select-options-sample/select-options-sample.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 21 additions & 41 deletions
62
apps/demo-app/src/app/pages/select-sample/select-sample.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,31 @@ | ||
sk-select { | ||
display: block; | ||
margin-top: 1rem; | ||
display: block; | ||
margin-top: 1rem; | ||
} | ||
|
||
.sk-label { | ||
padding: 0.5rem 1rem; | ||
border-radius: 8px; | ||
background: rgba(255, 255, 255, 0.1); | ||
color: #fefefe; | ||
box-shadow: rgba(255, 255, 255, 0.05) 0px 6px 24px 0px, rgba(255, 255, 255, 0.08) 0px 0px 0px 1px; | ||
} | ||
display: flex; | ||
align-items: center; | ||
gap: 0.25rem; | ||
padding: 0.5rem 1rem; | ||
border-radius: 8px; | ||
background: rgb(255 255 255 / 10%); | ||
color: #fefefe; | ||
box-shadow: rgb(255 255 255 / 5%) 0 6px 24px 0, | ||
rgb(255 255 255 / 8%) 0 0 0 1px; | ||
|
||
.sk-options { | ||
.sk-label-item { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 0.25rem; | ||
width: 100%; | ||
margin-top: 0.5rem; | ||
} | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
max-width: 90%; | ||
|
||
sk-select-option { | ||
background-color: #fff; | ||
color: #000; | ||
padding: 0.5rem 1rem; | ||
cursor: pointer; | ||
transition: color 0.3s ease-in-out, font-weight 0.3s ease-in-out, | ||
font-size 0.3s ease-in-out; | ||
} | ||
|
||
sk-select-option:first-child { | ||
border-top-left-radius: 0.25rem; | ||
border-top-right-radius: 0.25rem; | ||
} | ||
|
||
sk-select-option:last-child { | ||
border-bottom-left-radius: 0.25rem; | ||
border-bottom-right-radius: 0.25rem; | ||
} | ||
|
||
@media (hover) { | ||
sk-select-option:hover { | ||
color: deeppink; | ||
font-weight: bold; | ||
font-size: 1.5em; | ||
fa-icon { | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
} | ||
} | ||
} | ||
|
||
sk-select-option:not(:last-child) { | ||
border-bottom: 1px solid #000; | ||
} |
24 changes: 13 additions & 11 deletions
24
apps/demo-app/src/app/pages/select-sample/select-sample.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
Multiple: <input type="checkbox" (change)="switchMultiple($event)" /> | ||
|
||
<sk-select | ||
[(ngModel)]="value" | ||
[skMultiple]="multiple()" | ||
[ngModel]="value" | ||
(ngModelChange)="valueChanged($event)" | ||
[multiple]="multiple()" | ||
[animationDelay]="250" | ||
[closeOnSelect]="true" | ||
(open)="showAnimation.set($event)" | ||
> | ||
<div class="sk-label" skSelectPlaceholder>Please select an option</div> | ||
<div class="sk-label" skSelectLabel> | ||
@if (Array.isArray(value)) { | ||
@for (item of value; track item) { | ||
{{ item.data }} | ||
<div class="sk-label-item"> | ||
@for (item of selectedValues(); track item.value) { @if | ||
(selectedValues().length <= 1) { | ||
<fa-icon [icon]="item.icon"></fa-icon> | ||
} | ||
} @else { | ||
{{ value?.data }} | ||
} | ||
{{ item.label }} | ||
} | ||
</div> | ||
</div> | ||
|
||
<app-select-options-sample | ||
[show]="showAnimation()" | ||
></app-select-options-sample> | ||
<app-select-options-sample [options]="options" [show]="showAnimation()"> | ||
</app-select-options-sample> | ||
</sk-select> |
Oops, something went wrong.