File tree 2 files changed +17
-15
lines changed
renderers/Array2DRenderer
2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { Data } from '/core/datas' ;
2
2
import { Array2DRenderer } from '/core/renderers' ;
3
3
4
+ class Element {
5
+ constructor ( value ) {
6
+ this . value = value ;
7
+ this . patched = false ;
8
+ this . selected = false ;
9
+ }
10
+ }
11
+
4
12
class Array2DData extends Data {
5
13
getRendererClass ( ) {
6
14
return Array2DRenderer ;
7
15
}
8
16
9
17
set ( array2d = [ ] ) {
10
- this . data = [ ] ;
11
- for ( const array1d of array2d ) {
12
- const row = [ ] ;
13
- for ( const value of array1d ) {
14
- const col = {
15
- value,
16
- patched : false ,
17
- selected : false ,
18
- } ;
19
- row . push ( col ) ;
20
- }
21
- this . data . push ( row ) ;
22
- }
18
+ this . data = array2d . map ( array1d => [ ...array1d ] . map ( value => new Element ( value ) ) ) ;
23
19
super . set ( ) ;
24
20
}
25
21
26
22
patch ( x , y , v = this . data [ x ] [ y ] . value ) {
23
+ if ( ! this . data [ x ] [ y ] ) this . data [ x ] [ y ] = new Element ( ) ;
27
24
this . data [ x ] [ y ] . value = v ;
28
25
this . data [ x ] [ y ] . patched = true ;
29
26
}
Original file line number Diff line number Diff line change 7
7
8
8
.row {
9
9
display : flex ;
10
+ min-height : 28em ;
11
+ align-items : stretch ;
12
+
13
+ & :empty {
14
+ border-left : 1em solid $theme-light ;
15
+ }
10
16
11
17
.col {
12
18
display : flex ;
13
19
align-items : center ;
14
20
justify-content : center ;
15
21
min-width : 28em ;
16
- height : 28em ;
17
22
background-color : $theme-normal ;
18
23
border : 1em solid $theme-light ;
19
24
margin-right : -1em ;
33
38
}
34
39
}
35
40
}
36
- }
41
+ }
You can’t perform that action at this time.
0 commit comments