|
27 | 27 | </div>
|
28 | 28 | </div>
|
29 | 29 |
|
30 |
| -<% f = form_for(@changeset, "#") %> |
31 |
| -<div class="flex" x-data="{previewMode: false, previewDevice: 'desktop', editorExpanded: false}"> |
32 |
| - <%= textarea(f, :mjml_body, |
33 |
| - rows: 20, |
34 |
| - class: "hidden", |
35 |
| - phx_debounce: "1000" |
36 |
| - ) %> |
37 |
| - <div |
38 |
| - id="mjml-editor-container" |
39 |
| - class="editor flex-grow flex-shrink-0 transition-all" |
40 |
| - :class="editorExpanded ? 'w-2/3' : 'w-2/5'" |
41 |
| - phx-update="ignore" |
42 |
| - x-on:x-toggle-expand-editor.document="editorExpanded = !editorExpanded" |
43 |
| - > |
| 30 | +<div |
| 31 | + id="mjml-editor-wrapper" |
| 32 | + phx-update="ignore" |
| 33 | + class="flex bg-blue-200" |
| 34 | + x-data="{editorExpanded: false}" |
| 35 | + x-on:x-toggle-expand-editor.document="editorExpanded = !editorExpanded" |
| 36 | +> |
| 37 | + <%!-- |
| 38 | + NOTE: using width: 0 for the editor is a weird hack here because otherwise the editor kept |
| 39 | + causing the entire page to overflow. |
| 40 | + The width of the editor is controlled via the (inverse) width of the iframe instead. |
| 41 | + --%> |
| 42 | + <div class="flex-grow transition-all" style="width: 0"> |
| 43 | + <div id="mjml-editor"></div> |
44 | 44 | </div>
|
45 |
| - <div |
46 |
| - id="preview-container-mjml" |
47 |
| - class="flex-grow flex-shrink w-1/3 flex flex-col" |
48 |
| - phx-update="ignore" |
49 |
| - x-on:x-toggle-preview.document="previewMode = !previewMode" |
50 |
| - x-on:x-toggle-desktop-preview.document="previewDevice = 'desktop'" |
51 |
| - x-on:x-toggle-mobile-preview.document="previewDevice = 'mobile'" |
52 |
| - :class="previewMode ? 'fixed z-40 w-full min-h-full inset-0 bg-gray-900 items-center' : 'w-3/5 flex-grow'" |
| 45 | + <iframe |
| 46 | + id="html-inline-preview" |
| 47 | + src="about:blank" |
| 48 | + class="transition-all w-1/2" |
| 49 | + x-bind:class="editorExpanded ? 'w-0' : 'w-3/5'" |
53 | 50 | >
|
54 |
| - <div x-show="previewMode" style="display: none"> |
55 |
| - <div class="relative shadow z-10 flex overflow-x-auto my-4"> |
56 |
| - <div class="flex-grow"></div> |
57 |
| - <button |
58 |
| - title={gettext("Desktop preview")} |
59 |
| - class="flex w-10 h-10 p-2 items-center justify-center bg-gray-800 hover:bg-gray-600 text-white" |
60 |
| - :class="previewDevice == 'desktop' && 'bg-gray-700'" |
61 |
| - @click.prevent="$dispatch('x-toggle-desktop-preview')" |
62 |
| - > |
63 |
| - <%= render_icon(:desktop_computer) %> |
64 |
| - </button> |
65 |
| - <button |
66 |
| - title={gettext("Mobile preview")} |
67 |
| - class="flex w-10 h-10 p-2 items-center justify-center bg-gray-800 hover:bg-gray-600 text-white" |
68 |
| - :class="previewDevice == 'mobile' && 'bg-gray-700'" |
69 |
| - @click.prevent="$dispatch('x-toggle-mobile-preview')" |
70 |
| - > |
71 |
| - <%= render_icon(:device_mobile) %> |
72 |
| - </button> |
73 |
| - <div class="w-4"></div> |
74 |
| - <button |
75 |
| - x-show="previewMode" |
76 |
| - @click.prevent="previewMode = !previewMode" |
77 |
| - class="h-10 p-2 items-center justify-center bg-gray-800 hover:bg-gray-600 text-white" |
78 |
| - > |
79 |
| - <%= gettext("Close preview") %> |
80 |
| - </button> |
81 |
| - </div> |
82 |
| - </div> |
83 |
| - <iframe |
84 |
| - id="html-preview" |
85 |
| - src="about:blank" |
86 |
| - data-source="html-preview-data" |
87 |
| - class="bg-gray-100 flex-grow transition-all" |
88 |
| - :class="previewMode ? 'w-20 flex-grow-0 h-full' : ''" |
89 |
| - :style="previewMode ? previewDevice == 'desktop' ? 'width: 100%' : 'width: 360px' : ''" |
90 |
| - > |
91 |
| - </iframe> |
92 |
| - </div> |
93 |
| - <div id="html-preview-data" phx-hook="HtmlPreview" class="hidden" data-iframe="html-preview"> |
94 |
| - <%= @preview %> |
95 |
| - </div> |
| 51 | + </iframe> |
| 52 | +</div> |
| 53 | + |
| 54 | +<% f = form_for(@changeset, "#") %> |
| 55 | +<%= textarea(f, :mjml_body, |
| 56 | + rows: 20, |
| 57 | + class: "hidden", |
| 58 | + phx_debounce: "1000" |
| 59 | +) %> |
| 60 | +<div |
| 61 | + id="html-preview-data" |
| 62 | + phx-hook="HtmlPreview" |
| 63 | + class="hidden" |
| 64 | + data-iframe="#html-inline-preview, #html-preview" |
| 65 | +> |
| 66 | + <%= @preview %> |
96 | 67 | </div>
|
0 commit comments