<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sean Thorne</title>
    <description>The latest articles on DEV Community by Sean Thorne (@bakersbakebread).</description>
    <link>https://dev.to/bakersbakebread</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F207587%2Fdbe6e937-d695-4e24-931b-2e79d611e0f6.gif</url>
      <title>DEV Community: Sean Thorne</title>
      <link>https://dev.to/bakersbakebread</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bakersbakebread"/>
    <language>en</language>
    <item>
      <title>Umbraco Bellissima &amp; Tailwind</title>
      <dc:creator>Sean Thorne</dc:creator>
      <pubDate>Sat, 30 Mar 2024 11:57:05 +0000</pubDate>
      <link>https://dev.to/bakersbakebread/umbraco-bellissima-tailwind-3i6c</link>
      <guid>https://dev.to/bakersbakebread/umbraco-bellissima-tailwind-3i6c</guid>
      <description>&lt;p&gt;With the release of v14 beta comes an updated backoffice. At a recent hackathon, I was motivated to take on a challenging project: developing a 'command menu' for the backoffice. &lt;/p&gt;

&lt;p&gt;The feature aimed to add complexity and utility, albeit not strictly necessary. The premise was simple: allow editors to quickly access a command menu through a shortcut, facilitating faster navigation within the backoffice.&lt;/p&gt;

&lt;p&gt;It's rather simple and somewhat buggy. My intention was to never have a polished off ready to release package, but more so, a proof of concept of touching all areas of the new backoffice as a "real-world" exercise on how to do things. You can see all the code for it here: &lt;a href="https://github.com/Bakersbakebread/umbra-command-menu"&gt;https://github.com/Bakersbakebread/umbra-command-menu&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The structure of the code was utilising Kevin's incredible series: &lt;a href="https://dev.to/kevinjump/series/26221"&gt;https://dev.to/kevinjump/series/26221&lt;/a&gt;. On the hackathon day, we talked about this template and once I had it - I was up and running in no time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tailwind, but, why?
&lt;/h2&gt;

&lt;p&gt;I wanted to have something done and ready to use, I wanted to spend time in the new backoffice code figuring out Lit and how to register manifests and which files belong where - not writing actual 'feature' code.&lt;/p&gt;

&lt;p&gt;I knew Tailwind had a large ecosystem, with ready-to-use 'components'. So instead of building the command menu myself with regular 'ol HTML &amp;amp; CSS, I took to Google and searched for one instead.&lt;/p&gt;

&lt;p&gt;If you haven't used &lt;a href="https://tailwindcss.com/"&gt;Tailwind CSS&lt;/a&gt; yet, it's a utility-first CSS framework that lets you write classes in your HTML and combine them together to build out a design.&lt;/p&gt;

&lt;p&gt;We can see this in action if we just add a bg-blue-500 class to to change the background of our command menu. &lt;a href="https://github.com/Bakersbakebread/umbra-command-menu/blob/b7e2669046ee78f95df116af9f6af4eb762f03d5/CommandMenu.Client/assets/src/command-menu/index.ts#L87"&gt;See the before line of code here&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"items-center justify-center p-2 md:p-12 lg:px-20 lg:py-36"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-blue-500 [...other classes]"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            ... removed for brevity
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9d1cvl0swhc3h0tg509g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9d1cvl0swhc3h0tg509g.png" alt="Screenshot of the blue command menu" width="712" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  But How?
&lt;/h2&gt;

&lt;p&gt;Well first of all, let's make sure we've Tailwind installed in our project by following &lt;a href="https://tailwindcss.com/docs/installation/using-postcss"&gt;https://tailwindcss.com/docs/installation/using-postcss&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;We'll notice on Step 4 however, we need to import the tailwind directives into our CSS - but - how do we make them available to Lit throughout our files?&lt;/p&gt;

&lt;p&gt;In a directory of your choosing (I used &lt;code&gt;/shared&lt;/code&gt;) add a file called &lt;code&gt;tailwind.global.css&lt;/code&gt; and paste the step 4 code inside of it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/Bakersbakebread/umbra-command-menu/blob/main/CommandMenu.Client/assets/src/shared/tailwind.global.css"&gt;This is where I put mine&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then let's create our Tailwind Mixin, create a new file called &lt;code&gt;tailwindfactory.config.js&lt;/code&gt; and paste the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;LitElement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unsafeCSS&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@umbraco-cms/backoffice/external/lit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./tailwind.global.css?inline&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tailwindElement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;unsafeCSS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TailwindElementMixin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;LitElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;tailwindElement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;unsafeCSS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;)];&lt;/span&gt;

    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TailwindElementMixin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/Bakersbakebread/umbra-command-menu/blob/main/CommandMenu.Client/assets/src/shared/tailwindfactory.element.ts"&gt;This is where I put mine&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now anywhere you want to use Tailwind, you need to pass it into a constructor like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;UmbElementMixin&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@umbraco-cms/backoffice/element-api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;TailwindElementMixin&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../shared/tailwindfactory.element&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;customElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;commandmenu-commandmenu&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CommandMenu&lt;/span&gt;  &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;UmbElementMixin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;TailwindElementMixin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;property&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CommandMenu&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ... removed for brevity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/Bakersbakebread/umbra-command-menu/blob/main/CommandMenu.Client/assets/src/command-menu/index.ts"&gt;This is how I did it in mine&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's it 🎉 &lt;/p&gt;

&lt;p&gt;You've got all the usual goodness of &lt;a href="https://github.com/Bakersbakebread/umbra-command-menu/blob/main/CommandMenu.Client/assets/tailwind.config.js"&gt;tailwind config&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>umbraco</category>
      <category>cms</category>
      <category>opensource</category>
      <category>tailwindcss</category>
    </item>
  </channel>
</rss>
