Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sokoban App - Create Level</title>
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css"> -->
</head>
<body>
<div id="create"></div>
<script type="module" src="/src/create.js"></script>
</body>
</html>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.25"
"vue": "^3.2.25",
"vue-json-pretty": "^2.0.6"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.0.0",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions src/Create.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<main class="container">
<h1>Sokoban</h1>
<h2>Create Level</h2>
<!-- <Field ref="field" :data="data" /> -->
<div class="flex">
<Keys :keys="schemeKeys" />
<Textarea v-model="scheme" />
</div>
<PrettyJson :scheme="scheme" />

</main>
</template>

<script>
import Field from './components/Field.vue'
import Keys from './components/Keys.vue'
import PrettyJson from './components/PrettyJson.vue'
import Textarea from './components/Form/Textarea.vue'
import schemeKeys from './scheme-keys.json'

export default {
components: {
Field,
Keys,
PrettyJson,
Textarea,
},
data() {
return {
scheme: '',
schemeKeys: schemeKeys,
}
}
}
</script>

<style type="text/css">
#create {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
.container {
margin: 0 auto;
}
.flex {
display: flex;
margin: 0 auto;
max-width: 500px;
justify-content: space-around;
align-items: center;
}
</style>
36 changes: 36 additions & 0 deletions src/components/Form/Textarea.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<textarea class="textarea" v-model="scheme" :placeholder="placeholder"></textarea>
</template>

<script>
export default {
data() {
return {
scheme: '',
placeholder:
`Draw your sokoban

-++++-
++ *++
+ 0 #+
+ P++
+++++-`
}
}
}
</script>

<style type="text/css">
.textarea {
text-align: center;
letter-spacing: .5rem;
font-size: 1rem;
padding: 6px;
margin: 1rem 0;
min-height: 10rem;
border-radius: .5rem;
}
.textarea:focus {
border: 2px solid black;
}
</style>
27 changes: 27 additions & 0 deletions src/components/Keys.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<table class="table" cellpadding="5" >
<caption class="caption">Scheme keys</caption>
<tbody>
<tr v-for="(description, key) in keys">
<th>{{ key.replace(' ', '”&nbsp;”') }}</th>
<th>{{ '&nbsp;-&nbsp;' }}</th>
<td style="text-align: left">{{ description }}</td>
</tr>
</tbody>
</table>
</template>

<script>
export default {
props: {
keys: Object
}
}
</script>

<style type="text/css">
.caption {
padding: 6px;
font-weight: bold;
}
</style>
36 changes: 36 additions & 0 deletions src/components/PrettyJson.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div class="json-pretty">
<vue-json-pretty :path="'res'" :data="data"> </vue-json-pretty>
</div>
</template>

<script>
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';

export default {
components: {
VueJsonPretty,
},
props: {
scheme: String
},
computed: {
data() {
return {
cells: Array.from(this.scheme.split('\n'), el => el.split(''))
}
}
},
methods: {

}
};
</script>

<style type="text/css">
.json-pretty {
max-width: 500px;
margin: 0 auto;
}
</style>
4 changes: 4 additions & 0 deletions src/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createApp } from 'vue'
import Create from './Create.vue'

const create = createApp(Create).mount('#create')
9 changes: 9 additions & 0 deletions src/scheme-keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"-": "Empty space",
"+": "Border",
"0": "Box",
" ": "Empty cell",
"*": "Target",
"#": "Box on target",
"P": "Player"
}
2 changes: 1 addition & 1 deletion src/scheme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-+++++--
++ +++
+ ***# +
+ +M0+ +
+ +P0+ +
+ 0 +
+++ +0++
--+ +-
Expand Down