Skip to content

Commit 7d2018a

Browse files
committed
initial attempt at a textarea for the schema
Not very Vue-ish...Hope to componentize and fix CSS class reference. :(
1 parent 8bfc41e commit 7d2018a

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

app.css

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,38 @@ html, body, #editor {
66
}
77
small { color:#999 }
88

9-
#input, #output {
9+
#left-side, #output {
1010
display: inline-block;
1111
width: 49%;
1212
height: 100%;
1313
vertical-align: top;
1414
-webkit-box-sizing: border-box;
1515
-moz-box-sizing: border-box;
1616
box-sizing: border-box;
17+
}
18+
#input {
1719
padding: 0 20px;
1820
}
1921

20-
#output {
22+
#schema, #output {
2123
border: none;
22-
border-left: 1px solid #ccc;
24+
background-color: #f6f6f6;
2325
resize: none;
2426
outline: none;
25-
background-color: #f6f6f6;
2627
font-size: 14px;
2728
font-family: 'Monaco', courier, monospace;
2829
padding: 20px;
2930
}
31+
#schema {
32+
border-top: 1px solid #ccc;
33+
margin-top: 3em;
34+
width: 100%;
35+
height: 100%;
36+
}
37+
38+
#output {
39+
border-left: 1px solid #ccc;
40+
}
3041

3142
code {
3243
color: #f66;

app.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ var app = new Vue({
2222
data: {
2323
schema: schema
2424
},
25+
created: function () {
26+
this.$el.getElementsByClassName('schema')[0].value
27+
= JSON.stringify(this.schema, null, "\t");
28+
},
29+
methods: {
30+
updateSchema: function(e) {
31+
console.log(e.target.value);
32+
e.targetVM.schema = JSON.parse(e.target.value);
33+
}
34+
},
2535
computed: {
2636
output: {
2737
$get: function() {
@@ -36,6 +46,9 @@ var app = new Vue({
3646
}
3747
},
3848
filters: {
49+
pretty: function(value) {
50+
return JSON.stringify(value, null, "\t");
51+
},
3952
input_type: function(value) {
4053
var types = {
4154
string: 'text',

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</head>
77
<body>
88
<div id="editor">
9+
<div id="left-side">
910
<div id="input">
1011
<h1>{{schema.title}}</h1>
1112
<div v-repeat="schema.properties">
@@ -14,7 +15,10 @@ <h1>{{schema.title}}</h1>
1415
<div v-if="description"><small>{{description}}</small></div>
1516
</div>
1617
</div>
17-
<textarea id="output" v-model="output"></textarea>
18+
<textarea id="schema" class="schema" v-on="change: updateSchema">
19+
</textarea>
20+
</div>
21+
<textarea id="output" v-model="output"></textarea>
1822
</div>
1923

2024
<script src="vue.min.js"></script>

0 commit comments

Comments
 (0)