Editor.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <section class="container">
  2. <div class="editor">
  3. <textarea bind:value=text type=text></textarea>
  4. </div>
  5. <div id="jsonformatter">Unter <code>»s«</code> erreichbare Daten:</div>
  6. <div class="right-half">
  7. {#if schueler}
  8. {#each schueler as s (s.ID)}
  9. <svelte:component this={Component} s={s}/>
  10. {/each}
  11. {/if}
  12. </div>
  13. </section>
  14. <script>
  15. import svelte from 'svelte'
  16. import JSONFormatter from 'json-formatter-js'
  17. export default {
  18. oncreate () {
  19. const {schueler} = this.get()
  20. const formatter = new JSONFormatter(schueler[0])
  21. document.querySelector('#jsonformatter').appendChild(formatter.render())
  22. },
  23. data () {return {
  24. text: 'Hallo {s.Vorname}'
  25. }},
  26. computed: {
  27. Component: ({text}) => svelte.create(text)
  28. },
  29. }
  30. </script>
  31. <style>
  32. @import 'daten/main.css';
  33. /* Pattern styles */
  34. .container {
  35. display: grid;
  36. grid-template-columns: 1fr 2fr;
  37. grid-template-rows: 2fr 1fr;
  38. grid-gap: 10px;
  39. height: 90vh;
  40. margin-top: 10px;
  41. }
  42. .editor {
  43. grid-column: 1;
  44. grid-row: 1;
  45. /* position: sticky; */
  46. height: 90%;
  47. margin-left: 10px;
  48. }
  49. .right-half {
  50. grid-column: 2;
  51. grid-row-start: 1;
  52. grid-row-end: 3;
  53. }
  54. #jsonformatter {
  55. grid-column: 1;
  56. grid-row-start: 2;
  57. grid-row-end: 3;
  58. font-size: 10pt;
  59. margin-left: 10px;
  60. overflow: auto;
  61. }
  62. textarea {
  63. width: 100%;
  64. height: 100%;
  65. padding: 20px;
  66. border-color: #ccc;
  67. resize: none;
  68. font-size: 1.6em;
  69. }
  70. textarea:focus {
  71. outline: none;
  72. border-color: #3498db;
  73. }
  74. </style>