|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <title>PDF preview</title> |
| 7 | + <link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet"> |
| 8 | + <link href="https://cdn.jsdelivr.net/npm/ace-builds@1.21.0/css/ace.min.css" rel="stylesheet"> |
| 9 | + <script src="https://cdn.jsdelivr.net/npm/ace-builds@1.21.0/src-min-noconflict/ace.min.js"></script> |
| 10 | + <script src="https://code.jquery.com/jquery-3.7.0.min.js" crossorigin="anonymous"></script> |
| 11 | + <style> |
| 12 | + html, body { |
| 13 | + background-color: #fff; |
| 14 | + color: #636b6f; |
| 15 | + font-family: 'Nunito', sans-serif; |
| 16 | + font-weight: 200; |
| 17 | + margin: 0; |
| 18 | + } |
| 19 | + main { |
| 20 | + position: fixed; |
| 21 | + width: 100%; |
| 22 | + height: 100%; |
| 23 | + } |
| 24 | + .rows { |
| 25 | + display: flex; |
| 26 | + flex-direction: column; |
| 27 | + width: 100%; |
| 28 | + height: 100%; |
| 29 | + } |
| 30 | + .cols { |
| 31 | + display: flex; |
| 32 | + flex-direction: row; |
| 33 | + width: 100%; |
| 34 | + height: 100%; |
| 35 | + } |
| 36 | +
|
| 37 | + section.preview.tabs { |
| 38 | + width: 100%; |
| 39 | + height: 100%; |
| 40 | + } |
| 41 | + section.preview.tabs .tab { |
| 42 | + width: 100%; |
| 43 | + height: 100%; |
| 44 | + display: none; |
| 45 | + } |
| 46 | + section.preview.tabs .tab.active { |
| 47 | + display: block; |
| 48 | + } |
| 49 | + #editor { |
| 50 | + width: 100%; |
| 51 | + height: 100%; |
| 52 | + border: 0; |
| 53 | + } |
| 54 | + iframe { |
| 55 | + width: 100%; |
| 56 | + height: 100%; |
| 57 | + border: 0; |
| 58 | + } |
| 59 | + section.warnings { |
| 60 | + min-height: 20vh; |
| 61 | + max-height: 25vh; |
| 62 | + border-top: 5px solid #464646; |
| 63 | + background: black;; |
| 64 | + padding: 0; |
| 65 | + overflow: auto; |
| 66 | + } |
| 67 | + section.warnings ul { |
| 68 | + font-family: monospace; |
| 69 | + font-size: 11px; |
| 70 | + list-style: none; |
| 71 | + color: #77888e; |
| 72 | + padding: 0; |
| 73 | + margin: 0; |
| 74 | + } |
| 75 | + section.warnings ul li { |
| 76 | + border-bottom: 1px solid #373f42; |
| 77 | + background: #282828;; |
| 78 | + padding: 5px 10px; |
| 79 | + } |
| 80 | + section.toolbar { |
| 81 | + height: 60px; |
| 82 | + border-bottom: 2px solid #464646; |
| 83 | + background: #282828; |
| 84 | + align-content: center; |
| 85 | + align-items: center; |
| 86 | + padding: 10px; |
| 87 | + } |
| 88 | + section.toolbar .logo { |
| 89 | + height: 30px; |
| 90 | + } |
| 91 | +
|
| 92 | + nav.tabs { |
| 93 | + margin-left: 20px; |
| 94 | + display: flex; |
| 95 | + column-gap: 0px; |
| 96 | + align-content: center; |
| 97 | + align-items: center; |
| 98 | + height: auto; |
| 99 | + border-radius: 4px; |
| 100 | + overflow: hidden; |
| 101 | + } |
| 102 | + nav.tabs > a { |
| 103 | + display: block; |
| 104 | + padding: 5px 15px; |
| 105 | + background: #1e1e1e; |
| 106 | + color: #c4c4c4; |
| 107 | + cursor: pointer; |
| 108 | + height: 20px; |
| 109 | + font-size: 10pt; |
| 110 | + font-weight: bold; |
| 111 | + line-height: 16pt; |
| 112 | + border-right: 1px solid #282828; |
| 113 | + } |
| 114 | + nav.tabs > a:last-child { |
| 115 | + border:none; |
| 116 | + } |
| 117 | + nav.tabs > a.active { |
| 118 | + color:red; |
| 119 | + } |
| 120 | +
|
| 121 | + </style> |
| 122 | + </head> |
| 123 | + <body> |
| 124 | + <main class="rows"> |
| 125 | + <section class="toolbar cols"> |
| 126 | + <a href="https://docs.typeset.sh/setup/css-and-paged-media" class="logo" target="_blank"> |
| 127 | + <img src="https://stat.typeset.sh/images/logo-square.png" alt="typeset.sh" class="logo"> |
| 128 | + </a> |
| 129 | + <nav class="tabs"> |
| 130 | + <a class="tab pdf" onclick="tab('pdf')">PDF</a> |
| 131 | + <a class="tab html" onclick="tab('html')">HTML</a> |
| 132 | + <a class="tab code" onclick="tab('code')">CODE</a> |
| 133 | + <a class="tab help" onclick="tab('help')">?</a> |
| 134 | + </nav> |
| 135 | + </section> |
| 136 | + <section class="preview tabs"> |
| 137 | + <div class="pdf tab"> |
| 138 | + <iframe id="pdf"></iframe> |
| 139 | + </div> |
| 140 | + <div class="html tab"> |
| 141 | + <iframe id="html"></iframe> |
| 142 | + </div> |
| 143 | + <div class="code tab"> |
| 144 | + <div id="editor">{{ $html_code }}</div> |
| 145 | + </div> |
| 146 | + <div class="help tab"> |
| 147 | + <iframe src="https://docs.typeset.sh/setup/css-and-paged-media"></iframe> |
| 148 | + </div> |
| 149 | + </section> |
| 150 | + <section class="warnings"> |
| 151 | + <ul> |
| 152 | + @foreach( $log as $message) |
| 153 | + <li>{{ $message }}</li> |
| 154 | + @endforeach |
| 155 | + </ul> |
| 156 | + </section> |
| 157 | + </main> |
| 158 | + <script type="text/javascript"> |
| 159 | + var editor = ace.edit("editor"); |
| 160 | + editor.setTheme("ace/theme/monokai"); |
| 161 | + editor.session.setMode("ace/mode/html"); |
| 162 | +
|
| 163 | + tab('pdf'); |
| 164 | +
|
| 165 | + function tab(tab) { |
| 166 | + $('.tabs > .tab').removeClass('active').filter('.'+tab).addClass('active') |
| 167 | + } |
| 168 | +
|
| 169 | + function displayContent(id, type, content) { |
| 170 | + document.getElementById(id).src = "data:"+type+";base64," + content; |
| 171 | + } |
| 172 | +
|
| 173 | + window.addEventListener('load', function() { |
| 174 | + displayContent('pdf', 'application/pdf', '{!! base64_encode($pdf) !!}'); |
| 175 | + displayContent('html', 'text/html', '{!! base64_encode($html) !!}'); |
| 176 | +
|
| 177 | + console.log(document.getElementById('html')); |
| 178 | + }); |
| 179 | + </script> |
| 180 | + </body> |
| 181 | +</html> |
0 commit comments