Skip to content

Commit 08a3a30

Browse files
committed
Put placeholder for empty row in array2d
1 parent 33cdd1c commit 08a3a30

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/frontend/core/datas/Array2DData.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
import { Data } from '/core/datas';
22
import { Array2DRenderer } from '/core/renderers';
33

4+
class Element {
5+
constructor(value) {
6+
this.value = value;
7+
this.patched = false;
8+
this.selected = false;
9+
}
10+
}
11+
412
class Array2DData extends Data {
513
getRendererClass() {
614
return Array2DRenderer;
715
}
816

917
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)));
2319
super.set();
2420
}
2521

2622
patch(x, y, v = this.data[x][y].value) {
23+
if (!this.data[x][y]) this.data[x][y] = new Element();
2724
this.data[x][y].value = v;
2825
this.data[x][y].patched = true;
2926
}

src/frontend/core/renderers/Array2DRenderer/stylesheet.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77

88
.row {
99
display: flex;
10+
min-height: 28em;
11+
align-items: stretch;
12+
13+
&:empty {
14+
border-left: 1em solid $theme-light;
15+
}
1016

1117
.col {
1218
display: flex;
1319
align-items: center;
1420
justify-content: center;
1521
min-width: 28em;
16-
height: 28em;
1722
background-color: $theme-normal;
1823
border: 1em solid $theme-light;
1924
margin-right: -1em;
@@ -33,4 +38,4 @@
3338
}
3439
}
3540
}
36-
}
41+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy