Commit 54b517a4 authored by Romain DELEAU's avatar Romain DELEAU

Dynamic width for task

parent c114060a
...@@ -11,6 +11,8 @@ import { GameContextComponent } from './pieces/game-context/game-context.compone ...@@ -11,6 +11,8 @@ import { GameContextComponent } from './pieces/game-context/game-context.compone
import { TaskComponent } from './pieces/task/task.component'; import { TaskComponent } from './pieces/task/task.component';
import { AnnexeTaskComponent } from './pieces/annexe-task/annexe-task.component'; import { AnnexeTaskComponent } from './pieces/annexe-task/annexe-task.component';
import { FormsModule } from '@angular/forms';
@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
...@@ -24,7 +26,8 @@ import { AnnexeTaskComponent } from './pieces/annexe-task/annexe-task.component' ...@@ -24,7 +26,8 @@ import { AnnexeTaskComponent } from './pieces/annexe-task/annexe-task.component'
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
AppRoutingModule AppRoutingModule,
FormsModule,
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]
......
<div class="piece"> <div class="piece" [ngStyle]="{'width': pieceWidth}">
<div class="piece-attach piece-attach-left"></div> <div class="piece-attach piece-attach-left"></div>
<div class="piece-attach piece-attach-right"></div> <div class="piece-attach piece-attach-right"></div>
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<option value="1">1</option> <option value="1">1</option>
</select> </select>
<div class="piece-form-bottom-duration"> <div class="piece-form-bottom-duration">
<input name="value" type="text" value="1"/> <input name="value" type="text" [(ngModel)]="duration" (input)="durationChange()"/>
<select name="unite"> <select name="unite" [(ngModel)]="durationUnit" (change)="durationChange()">
<option selected value="UT">UT</option> <option selected value="UT">UT</option>
<option value="min">min</option> <option value="min">min</option>
<option value="tours">tours</option> <option value="tours">tours</option>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
height: 400px; height: 400px;
position: relative; position: relative;
background-color: var(--piece-background-color); background-color: var(--piece-background-color);
transition: all 0.5s ease;
&-attach { &-attach {
z-index: 1; z-index: 1;
...@@ -89,17 +90,17 @@ ...@@ -89,17 +90,17 @@
&-bottom { &-bottom {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
margin-bottom: 25px; margin-bottom: 10px;
justify-content: space-between; justify-content: space-between;
&-duration { &-duration {
input { input {
border-top-right-radius: 0px; border-top-right-radius: 0px;
border-bottom-right-radius: 0px; border-bottom-right-radius: 0px;
width: 50px; width: 20px;
z-index: 2; z-index: 2;
} }
select { select {
width: 50px; width: 60px;
border-top-left-radius: 0px; border-top-left-radius: 0px;
border-bottom-left-radius: 0px; border-bottom-left-radius: 0px;
z-index: 1; z-index: 1;
......
...@@ -12,4 +12,25 @@ export class TaskComponent implements OnInit { ...@@ -12,4 +12,25 @@ export class TaskComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
} }
durationUnit: String = 'UT';
duration: number = 1;
pieceWidth = '400px';
durationChange():void {
if(this.durationUnit === 'UT') {
if(this.duration == 1) {
this.pieceWidth = '400px';
} else if(this.duration == 2) {
this.pieceWidth = '800px';
} else if(this.duration >= 3) {
this.pieceWidth = '1200px';
}
} else {
this.pieceWidth = '400px';
}
console.log('largeur : '+this.pieceWidth);
console.log('durationUnit : '+this.durationUnit);
console.log('duration : '+this.duration);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment