-
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.
Merge pull request #23 from qupaya/feature/select-component
Feature/select component
- Loading branch information
Showing
34 changed files
with
1,079 additions
and
8 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
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
9 changes: 9 additions & 0 deletions
9
apps/demo-app/src/app/pages/select-sample/select-default/select-default.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<sk-select [(ngModel)]="selectedValue"> | ||
<span skSelectPlaceholder>Select option</span> | ||
<span skSelectLabel>{{ selectedValue?.label }}</span> | ||
@for (option of options; track option.value) { | ||
<sk-select-option [value]="option"> | ||
{{ option.label }} | ||
</sk-select-option> | ||
} | ||
</sk-select> |
39 changes: 39 additions & 0 deletions
39
apps/demo-app/src/app/pages/select-sample/select-default/select-default.component.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Component } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { SelectDemoOption } from '../select-sample.component'; | ||
import { | ||
faBell, | ||
faCog, | ||
faEnvelope, | ||
faGlobe, | ||
faHeart, | ||
faHome, | ||
faKey, | ||
faLock, | ||
faStar, | ||
faUser, | ||
} from '@fortawesome/free-solid-svg-icons'; | ||
import { SelectComponent, SelectOptionComponent } from '@qupaya/sketch'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-select-default', | ||
standalone: true, | ||
imports: [CommonModule, SelectComponent, SelectOptionComponent, FormsModule], | ||
templateUrl: './select-default.component.html', | ||
}) | ||
export class SelectDefaultComponent { | ||
readonly options: SelectDemoOption[] = [ | ||
{ label: 'Option 1', icon: faHome, value: 1 }, | ||
{ label: 'Option 2', icon: faUser, value: 2 }, | ||
{ label: 'Option 3', icon: faCog, value: 3 }, | ||
{ label: 'Option 4', icon: faHeart, value: 4 }, | ||
{ label: 'Option 5', icon: faStar, value: 5 }, | ||
{ label: 'Option 6', icon: faBell, value: 6 }, | ||
{ label: 'Option 7', icon: faEnvelope, value: 7 }, | ||
{ label: 'Option 8', icon: faGlobe, value: 8 }, | ||
{ label: 'Option 9', icon: faLock, value: 9 }, | ||
{ label: 'Option 10', icon: faKey, value: 10 }, | ||
]; | ||
selectedValue?: SelectDemoOption; | ||
} |
1 change: 1 addition & 0 deletions
1
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<router-outlet></router-outlet> |
22 changes: 22 additions & 0 deletions
22
apps/demo-app/src/app/pages/select-sample/select-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { SelectSampleComponent } from './select-sample.component'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
describe('SelectSampleComponent', () => { | ||
let component: SelectSampleComponent; | ||
let fixture: ComponentFixture<SelectSampleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SelectSampleComponent, NoopAnimationsModule], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SelectSampleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
apps/demo-app/src/app/pages/select-sample/select-sample.component.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Component } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { IconProp } from '@fortawesome/fontawesome-svg-core'; | ||
import { RouterOutlet } from '@angular/router'; | ||
|
||
export interface SelectDemoOption { | ||
label: string; | ||
icon: IconProp; | ||
value: number; | ||
} | ||
|
||
@Component({ | ||
selector: 'app-select-sample', | ||
standalone: true, | ||
imports: [CommonModule, RouterOutlet], | ||
templateUrl: './select-sample.component.html', | ||
}) | ||
export class SelectSampleComponent {} |
41 changes: 41 additions & 0 deletions
41
...select-sample/select-with-style/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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
max-height: 200px; | ||
margin-top: 0.5rem; | ||
overflow-x: auto; | ||
} | ||
|
||
sk-select-option { | ||
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; | ||
} | ||
|
||
sk-select-option:last-child { | ||
border-bottom-left-radius: 0.25rem; | ||
border-bottom-right-radius: 0.25rem; | ||
} | ||
|
||
@media (hover) { | ||
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; | ||
} |
6 changes: 6 additions & 0 deletions
6
...elect-sample/select-with-style/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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@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> | ||
} |
25 changes: 25 additions & 0 deletions
25
...ct-sample/select-with-style/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { SelectOptionsSampleComponent } from './select-options-sample.component'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
describe('SelectOptionsSampleComponent', () => { | ||
let component: SelectOptionsSampleComponent; | ||
let fixture: ComponentFixture<SelectOptionsSampleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SelectOptionsSampleComponent, NoopAnimationsModule], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SelectOptionsSampleComponent); | ||
component = fixture.componentInstance; | ||
const componentRef = fixture.componentRef; | ||
componentRef.setInput('show', true); | ||
componentRef.setInput('options', []); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
.../select-sample/select-with-style/select-options-sample/select-options-sample.component.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Component, effect, HostBinding, input } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { query, transition, trigger } from '@angular/animations'; | ||
import { SelectOptionComponent } from '@qupaya/sketch'; | ||
import { slideFadeAnimationFactory } from '../../../../animations/slide.animation'; | ||
import { fadeFactory } from '../../../../animations/fade.animations'; | ||
import { FaIconComponent } from '@fortawesome/angular-fontawesome'; | ||
import { SelectDemoOption } from '../../select-sample.component'; | ||
|
||
@Component({ | ||
selector: 'app-select-options-sample', | ||
standalone: true, | ||
imports: [CommonModule, SelectOptionComponent, FaIconComponent], | ||
templateUrl: './select-options-sample.component.html', | ||
styleUrl: './select-options-sample.component.css', | ||
animations: [ | ||
trigger('animation', [ | ||
transition( | ||
'* => visible', | ||
query('sk-select-option', slideFadeAnimationFactory(), { | ||
optional: true, | ||
}) | ||
), | ||
transition( | ||
'* => hidden', | ||
query('sk-select-option', fadeFactory(1, 0, '350ms'), { | ||
optional: true, | ||
}) | ||
), | ||
transition( | ||
'visible => void', | ||
query('sk-select-option', fadeFactory(1, 0, '350ms'), { | ||
optional: true, | ||
}) | ||
), | ||
]), | ||
], | ||
}) | ||
export class SelectOptionsSampleComponent { | ||
options = input.required<SelectDemoOption[]>(); | ||
@HostBinding('@animation') animateOptions = 'hidden'; | ||
|
||
show = input.required<boolean>(); | ||
|
||
protected readonly toggleShow = effect(() => { | ||
this.animateOptions = this.show() ? 'visible' : 'hidden'; | ||
}); | ||
} |
Oops, something went wrong.