Skip to content

Commit 29d14ba

Browse files
committed
complete examples!
1 parent 52454a0 commit 29d14ba

39 files changed

+787
-1
lines changed

src/.vitepress/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ const sidebar = {
425425
},
426426
{
427427
text: 'Temperature Converter',
428-
link: '/examples/#temprature-converter'
428+
link: '/examples/#temperature-converter'
429429
},
430430
{
431431
text: 'Flight Booker',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Cell from './Cell.vue'
2+
import { cells } from './store.js'
3+
4+
export default {
5+
components: {
6+
Cell
7+
},
8+
setup() {
9+
const cols = cells.map((_, i) => String.fromCharCode(65 + i))
10+
return {
11+
cols,
12+
cells
13+
}
14+
}
15+
}

src/examples/src/cells/App/options.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Cell from './Cell.vue'
2+
import { cells } from './store.js'
3+
4+
export default {
5+
components: {
6+
Cell
7+
},
8+
data() {
9+
return {
10+
cols: cells.map((_, i) => String.fromCharCode(65 + i)),
11+
cells
12+
}
13+
}
14+
}

src/examples/src/cells/App/style.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
body {
2+
margin: 0;
3+
}
4+
5+
table {
6+
border-collapse: collapse;
7+
table-layout: fixed;
8+
width: 100%;
9+
}
10+
11+
th {
12+
background-color: lightgray;
13+
}
14+
15+
tr:first-of-type th {
16+
width: 100px;
17+
}
18+
19+
tr:first-of-type th:first-of-type {
20+
width: 25px;
21+
}
22+
23+
td {
24+
border: 1px solid lightgray;
25+
height: 1.5em;
26+
overflow: scroll;
27+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<table>
2+
<thead>
3+
<tr>
4+
<th></th>
5+
<th v-for="c in cols">{{ c }}</th>
6+
</tr>
7+
</thead>
8+
<tbody>
9+
<tr v-for="i in cells[0].length">
10+
<th>{{ i - 1 }}</th>
11+
<td v-for="c, j in cols">
12+
<Cell :r="i - 1" :c="j"></Cell>
13+
</td>
14+
</tr>
15+
</tbody>
16+
</table>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ref } from 'vue'
2+
import { cells, evalCell } from './store.js'
3+
4+
export default {
5+
props: {
6+
c: Number,
7+
r: Number
8+
},
9+
setup(props) {
10+
const editing = ref(false)
11+
12+
function update(e) {
13+
editing.value = false
14+
cells[props.c][props.r] = e.target.value.trim()
15+
}
16+
17+
return {
18+
cells,
19+
editing,
20+
evalCell,
21+
update
22+
}
23+
}
24+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { cells, evalCell } from './store.js'
2+
3+
export default {
4+
props: {
5+
c: Number,
6+
r: Number
7+
},
8+
data() {
9+
return {
10+
editing: false,
11+
cells
12+
}
13+
},
14+
methods: {
15+
evalCell,
16+
update(e) {
17+
this.editing = false
18+
cells[this.c][this.r] = e.target.value.trim()
19+
}
20+
}
21+
}

src/examples/src/cells/Cell/style.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.cell {
2+
padding: 0 6px;
3+
height: 1em;
4+
}
5+
6+
.cell input {
7+
width: 80px;
8+
height: 1em;
9+
font-size: 15px;
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="cell" @click="editing = true">
2+
<input
3+
v-if="editing"
4+
:value="cells[c][r]"
5+
@change="update"
6+
@blur="update"
7+
@vnode-mounted="({ el }) => el.focus()"
8+
/>
9+
<span v-else>{{ evalCell(cells[c][r]) }}</span>
10+
</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://eugenkiss.github.io/7guis/tasks/#cells

0 commit comments

Comments
 (0)