<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="183777" data-post-id="183777">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="stryrckt" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stryrckt/120/16834_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  stryrckt
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>My article on creating LiveView modals with Tailwind CSS and Alpine.js is up.</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://blog.pthompson.org/liveview-tailwind-css-alpine-js-modal">
  <header class="source">
      <img src="https://lightning.svbtle.com/cargo/favicon-3686f5990e669ad2a1684f0ac250c4d9ddc03e2ef6f3c980f17b7aae786833ef.ico" class="site-icon" alt="" width="64" height="64">

      <a href="https://blog.pthompson.org/liveview-tailwind-css-alpine-js-modal" target="_blank" rel="noopener nofollow ugc">Patrick Thompson on Svbtle</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/467;"><img src="https://svbtleusercontent.com/2msUNgjayaUgpZvJo9f9u0xspap.gif" class="thumbnail" alt="" width="690" height="467"></div>

<h3><a href="https://blog.pthompson.org/liveview-tailwind-css-alpine-js-modal" target="_blank" rel="noopener nofollow ugc">Creating LiveView Modals with Tailwind CSS and AlpineJS  • Patrick Thompson</a></h3>

  <p>Our last article explored how to use LiveView with AlpineJS. In this article, we will use LiveView along with AlpineJS and Tailwind CSS to create a production-ready modal component. That is, a modal that smoothly transitions into and out of view... |...</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="183777" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-and-enter-leave-transitions/31417/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-183777" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="183777"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #21"></div>
  </section>
</div>
    <div class="postbit" id="185716" data-post-id="185716">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tme_317" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tme_317
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Chris’ LV video from ElixirConf EU V 2020 is now up:  <a href="https://www.youtube.com/watch?v=VU1JMg9AbLQ" rel="noopener nofollow ugc">https://www.youtube.com/watch?v=VU1JMg9AbLQ</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="185716" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-and-enter-leave-transitions/31417/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-185716" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="185716"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="311571" data-post-id="311571">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="petrus-jvrensburg" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/petrus-jvrensburg/120/30959_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  petrus-jvrensburg
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>This is how I set up the mobile menu transitions for a tailwind ui template. It requires three changes:</p>
<ol>
<li>Add id’s to two of the elements</li>
<li>Change their classes slightly (<code>lg:hidden</code> → <code>hidden</code> and <code>flex</code> → <code>hidden</code>)</li>
<li>Add click handlers</li>
</ol>
<pre data-code-wrap="elixir"><code class="lang-elixir">--- a/lib/my_app_web/components/layouts/app.html.heex
+++ b/lib/my_app_web/components/layouts/app.html.heex
@@ -4,33 +4,25 @@
 
     Off-canvas menu for mobile, show/hide based on off-canvas menu state.
   --&gt;
-  &lt;div class="relative z-40 lg:hidden" role="dialog" aria-modal="true"&gt;
+  &lt;div id="mobile-menu-wrapper" class="relative z-40 hidden" role="dialog" aria-modal="true"&gt;
     &lt;!--
       Off-canvas menu backdrop, show/hide based on off-canvas menu state.
-
-      Entering: "transition-opacity ease-linear duration-300"
-        From: "opacity-0"
-        To: "opacity-100"
-      Leaving: "transition-opacity ease-linear duration-300"
-        From: "opacity-100"
-        To: "opacity-0"
     --&gt;
     &lt;div class="fixed inset-0 bg-black bg-opacity-25"&gt;&lt;/div&gt;
 
     &lt;div class="fixed inset-0 z-40 flex"&gt;
       &lt;!--
         Off-canvas menu, show/hide based on off-canvas menu state.
-
-        Entering: "transition ease-in-out duration-300 transform"
-          From: "-translate-x-full"
-          To: "translate-x-0"
-        Leaving: "transition ease-in-out duration-300 transform"
-          From: "translate-x-0"
-          To: "-translate-x-full"
       --&gt;
-      &lt;div class="relative flex w-full max-w-xs flex-col overflow-y-auto bg-white pb-12 shadow-xl"&gt;
+      &lt;div
+        id="mobile-menu"
+        phx-click-away={toggle_mobile_menu()}
+        class="relative hidden w-full max-w-xs flex-col overflow-y-auto bg-white pb-12 shadow-xl"
+      &gt;
         &lt;div class="flex px-4 pb-2 pt-5"&gt;
+          &lt;!-- Close button --&gt;
           &lt;button
+            phx-click={toggle_mobile_menu()}
             type="button"
             class="-m-2 inline-flex items-center justify-center rounded-md p-2 text-gray-400"
           &gt;
@@ -488,7 +480,11 @@
         &lt;div class="flex h-16 items-center justify-between"&gt;
           &lt;div class="flex flex-1 items-center lg:hidden"&gt;
             &lt;!-- Mobile menu toggle, controls the 'mobileMenuOpen' state. --&gt;
-            &lt;button type="button" class="-ml-2 rounded-md bg-white p-2 text-gray-400"&gt;
+            &lt;button
+              phx-click={toggle_mobile_menu()}
+              type="button"
+              class="-ml-2 rounded-md bg-white p-2 text-gray-400"
+            &gt;
               &lt;span class="sr-only"&gt;Open menu&lt;/span&gt;
               &lt;svg
                 class="h-6 w-6"
</code></pre>
<p>Then in <code>lib/my_app_web/components/layouts.ex</code> I define the toggle function:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def toggle_mobile_menu(js \\ %JS{}) do
    js
    |&gt; JS.toggle(
      to: "#mobile-menu-wrapper",
      in:
        {"transition-opacity ease-linear duration-300", "transform opacity-0",
         "transform opacity-100"},
      out:
        {"transition-opacity ease-linear duration-300", "transform opacity-100",
         "transform opacity-0"}
    )
    |&gt; JS.toggle(
      to: "#mobile-menu",
      in: {"transition ease-in-out duration-300 transform", "-translate-x-full", "translate-x-0"},
      out: {"transition ease-in-out duration-300 transform", "translate-x-0", "-translate-x-full"}
    )
  end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="311571" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-and-enter-leave-transitions/31417/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-311571" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="311571"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>