I’m starting to play around with updating my dashboard using Tailwind. Like others, the refresh is a concern. In this particular example, for my front load washing machine, this card is on a sub-page that wouldn’t be active all the time.
I’ve attached a couple of examples of the card in action. When the status is “off”, the additional detail is not shown. When the machine is on, the status is updated to whatever the current cycle is according to the machine: Standby, Load Sensing, Washing, Rinsing, Spinning.
Looking at the code below, what suggestions do people have for streamlining / making it better?
Code
<div class="grid grid-cols-1 gap-x-6 gap-y-8 xl:gap-x-8">
<div class="overflow-hidden rounded-xl border border-gray-200">
{%- if states('sensor.front_load_washer') == 'off' -%}
<div class="flex items-center gap-x-4 border-b border-gray-900/5 bg-gray-100 p-6">
{%- else -%}
<div class="flex items-center gap-x-4 border-b border-gray-900/5 bg-green-300 p-6">
{%- endif -%}
<svg class="h-12 w-12 flex-none rounded-lg bg-white object-cover ring-1 ring-gray-900/10 fill-green-800" data-name="Layer 1" id="Layer_1" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title/><path d="M6,3V29H26V3H6ZM25,4V8H7V4H25ZM7,28V9H25V28H7Z"/><circle cx="10" cy="6" r="1"/><circle cx="14" cy="6" r="1"/><circle cx="18" cy="6" r="1"/><circle cx="22" cy="6" r="1"/><path d="M16,11a7,7,0,1,0,7,7A7,7,0,0,0,16,11Zm0,13a6,6,0,1,1,6-6A6,6,0,0,1,16,24Z"/><path d="M16,14a4,4,0,1,0,4,4A4,4,0,0,0,16,14Zm0,7a3,3,0,1,1,3-3A3,3,0,0,1,16,21Z"/></svg>
<div class="text-sm font-medium leading-6 text-gray-900">Washing Machine <br> {%- if states('sensor.front_load_washer') == 'off' -%} {{ states('sensor.front_load_washer') | title }} {%- else -%} {{ states('sensor.front_load_washer_run_state') }} {%- endif -%}</div>
</div>
{%- if states('sensor.front_load_washer') != 'off' -%}
<dl class="-my-3 px-4 py-4 text-sm leading-6">
<div class="flex grid grid-cols-2 py-3">
<div class="relative flex items-center space-x-3 rounded-lg px-3 py-5 focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 hover:border-gray-400">
<div class="flex h-10 w-10 items-center justify-center rounded-lg bg-indigo-600">
<svg class="h-6 w-6 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M17.593 3.322c1.1.128 1.907 1.077 1.907 2.185V21L12 17.25 4.5 21V5.507c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0111.186 0z" />
</svg>
</div>
<div class="min-w-0 flex-1">
<a href="#" class="focus:outline-none">
<span class="absolute inset-0" aria-hidden="true"></span>
<p class="text-sm font-medium text-gray-200">Selection</p>
<p class="truncate text-sm text-gray-400">{{ states('sensor.front_load_washer_current_course') }}</p>
</a>
</div>
</div>
<div class="relative flex items-center space-x-3 rounded-lg px-3 py-5 focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 hover:border-gray-400">
<div class="flex h-10 w-10 items-center justify-center rounded-lg bg-green-600">
<svg class="h-6 w-6 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<div class="min-w-0 flex-1">
<a href="#" class="focus:outline-none">
<span class="absolute inset-0" aria-hidden="true"></span>
<p class="text-sm font-medium text-gray-200">Time left</p>
<p class="truncate text-sm text-gray-400">{{ states('sensor.front_load_washer_remaining_time') }}</p>
</a>
</div>
</div>
</div>
</dl>
{%- endif -%}
</div>
</div>