-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(slider): Add slider component (#182)
Co-authored-by: Marko OLEKSIYENKO <[email protected]>
- Loading branch information
1 parent
08ee7af
commit 07d66a9
Showing
38 changed files
with
2,969 additions
and
17 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,51 @@ | ||
import {AgnosUIAngularModule} from '@agnos-ui/angular'; | ||
import type {OnInit} from '@angular/core'; | ||
import {Component} from '@angular/core'; | ||
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule, ReactiveFormsModule, FormsModule], | ||
template: ` | ||
<h2>Slider with form control</h2> | ||
<au-component auSlider [auMin]="0" [auMax]="100" [auStepSize]="1" [formControl]="sliderControl"></au-component> Form control values: | ||
{{ sliderControl.value }} | ||
<hr /> | ||
<h2>Slider with value</h2> | ||
<au-component auSlider [auMin]="0" [auMax]="100" [auStepSize]="1" [(auValues)]="sliderValues"></au-component> Values: | ||
{{ sliderValues }} | ||
<hr /> | ||
<h2>Disabled slider</h2> | ||
<au-component auSlider [auMin]="0" [auMax]="100" [auStepSize]="1" [formControl]="disabledControl" [auReadonly]="readonlyToggle"></au-component> | ||
<div class="form-check form-switch"> | ||
<input class="form-check-input" type="checkbox" role="switch" id="disabled" [(ngModel)]="disabledToggle" (change)="handleDisabled()" /> | ||
<label class="form-check-label" for="disabled">Disabled</label> | ||
</div> | ||
<div class="form-check form-switch"> | ||
<input class="form-check-input" type="checkbox" role="switch" id="readonly" [(ngModel)]="readonlyToggle" /> | ||
<label class="form-check-label" for="readonly">Readonly</label> | ||
</div> | ||
`, | ||
}) | ||
export default class DefaultSliderComponent implements OnInit { | ||
sliderControl = new FormControl([70]); | ||
disabledControl = new FormControl(60); | ||
sliderValues = [20]; | ||
disabledToggle = true; | ||
readonlyToggle = true; | ||
|
||
ngOnInit() { | ||
this.disabledControl.disable(); | ||
} | ||
|
||
handleDisabled() { | ||
if (this.disabledToggle) { | ||
this.disabledControl.disable(); | ||
} else { | ||
this.disabledControl.enable(); | ||
} | ||
} | ||
} |
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,23 @@ | ||
import type {SliderComponent} from '@agnos-ui/angular'; | ||
import {AgnosUIAngularModule} from '@agnos-ui/angular'; | ||
import {getSliderDefaultConfig} from '@agnos-ui/core'; | ||
import {Component, ViewChild} from '@angular/core'; | ||
import {getUndefinedValues, hashChangeHook, provideHashConfig} from '../../utils'; | ||
|
||
const undefinedConfig = getUndefinedValues(getSliderDefaultConfig()); | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule], | ||
providers: provideHashConfig('slider'), | ||
template: `<au-component auSlider #widget></au-component>`, | ||
}) | ||
export default class PlaygroundComponent { | ||
@ViewChild('widget') widget: SliderComponent; | ||
|
||
constructor() { | ||
hashChangeHook((props) => { | ||
this.widget?._widget.patch({...undefinedConfig, ...props}); | ||
}); | ||
} | ||
} |
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 {AgnosUIAngularModule} from '@agnos-ui/angular'; | ||
import {Component} from '@angular/core'; | ||
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule, ReactiveFormsModule, FormsModule], | ||
template: ` | ||
<h2>Slider with form control</h2> | ||
<au-component auSlider [auMin]="0" [auMax]="100" [auStepSize]="1" [formControl]="sliderControl"></au-component> | ||
Form control values: {{ sliderControl.value }} | ||
<hr /> | ||
<h2>Slider with value</h2> | ||
<au-component auSlider [auMin]="0" [auMax]="100" [auStepSize]="1" [(auValues)]="sliderValues"></au-component> | ||
Values: {{ sliderValues }} | ||
`, | ||
}) | ||
export default class RangeSliderComponent { | ||
sliderControl = new FormControl([10, 40, 50, 60, 90]); | ||
sliderValues = [10, 40]; | ||
} |
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 {AgnosUIAngularModule} from '@agnos-ui/angular'; | ||
import {Component} from '@angular/core'; | ||
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule, ReactiveFormsModule, FormsModule], | ||
template: ` | ||
<h2>Vertical slider</h2> | ||
<div class="d-flex" style="height: 350px"> | ||
<div class="col-6" style="height: 300px"> | ||
<au-component auSlider [auMin]="0" [auMax]="100" [auStepSize]="1" [auVertical]="true" [formControl]="sliderControl"></au-component> | ||
Form control values: {{ sliderControl.value }} | ||
</div> | ||
<div class="col-6" style="height: 300px"> | ||
<au-component auSlider [auMin]="0" [auMax]="100" [auStepSize]="1" [auVertical]="true" [formControl]="sliderControlRange"></au-component> | ||
From control values: {{ sliderControlRange.value }} | ||
</div> | ||
</div> | ||
`, | ||
}) | ||
export default class VerticalSliderComponent { | ||
sliderControl = new FormControl([10, 40]); | ||
sliderControlRange = new FormControl([40]); | ||
} |
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
Oops, something went wrong.