Skip to content

A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.

7.5 KB
Raw Blame
---
import { Image } from "astro:assets";
import wallpaper from "@/assets/wallpapers/desktop-10.jpg";
import claude from "@/assets/usage/claude.svg";
import Crab from "@/components/crab/Crab.astro";
import Section from "@/components/layout/Section.astro";
import SectionIntro from "@/components/showcase/SectionIntro.astro";
import { crabFacts, crabIntro, crabMoments } from "@/data/crab";
import { previewIcons } from "@/data/showcase";
import "@/styles/showcase.css";
---

<Section id="crab">
  <SectionIntro {...crabIntro} />

  <div class="moments" data-moments data-r>
    <figure class="moments-desk" aria-label="A desktop with Muelle, where the crab plays the moment you pick">
      <Image
        src={wallpaper}
        alt=""
        class="moments-wall"
        widths={[640, 1280]}
        sizes="(min-width: 1024px) 640px, 100vw"
      />
      <div class="moments-bar" aria-hidden="true">
        <b>Terminal</b>
        <span class="moments-power" data-power>
          <svg viewBox="0 0 16 16" class="moments-bolt" data-power-icon="charging">
            <path d="M9.2 1 3.5 9h3.7L6.4 15l6.1-8.3H8.8L9.2 1Z" fill="currentColor"></path>
          </svg>
          <svg viewBox="0 0 16 16" class="moments-leaf" data-power-icon="saver">
            <path
              d="M13.8 2.2C7 2 2.6 5.4 2.6 10.2c0 1.2.4 2.3 1 3.2l-1 1.1.8.7 1-1.1c.9.7 2 1.1 3.3 1.1 4.8 0 6.6-5 6.1-13Zm-6 10c1-2.9 2.6-5 4.6-6.6-2.4 1.1-4.4 3.3-5.6 6.1l1 .5Z"
              fill="currentColor"></path>
          </svg>
          <span data-power-label></span>
        </span>
      </div>
      <div class="moments-island" data-island aria-hidden="true">
        <Image src={claude} alt="" width={14} height={14} />
        <b class="tabular-nums"><span data-usage>63</span>%</b>
        <svg class="moments-ring" viewBox="0 0 16 16">
          <circle cx="8" cy="8" r="6" pathLength="100"></circle>
          <circle cx="8" cy="8" r="6" pathLength="100" stroke-dasharray="63 100" data-ring></circle>
        </svg>
      </div>
      <div class="moments-dock" data-moments-dock aria-hidden="true">
        {previewIcons.map((icon) => <Image src={icon} alt="" width={44} height={44} />)}
      </div>
      <Crab cell={3} class="crab-free" interactive label="The crab. Hover over it." data-moments-crab />
      <figcaption class="sr-only" aria-live="polite" data-moment-caption></figcaption>
    </figure>

    <div class="moments-side">
      <ol class="moments-list" role="list">
        {
          crabMoments.map((moment, index) => (
            <li>
              <button
                type="button"
                class="moments-item"
                data-moment={index}
                aria-pressed={index === 0 ? "true" : "false"}
              >
                <b>{moment.title}</b>
                <span>{moment.body}</span>
                <i class="moments-progress" aria-hidden="true" />
              </button>
            </li>
          ))
        }
      </ol>
      <ul class="moments-facts">
        {crabFacts.map((fact) => <li>{fact}</li>)}
      </ul>
    </div>
  </div>
</Section>

<script>
  import { initMoments } from "@/scripts/moments";
  import { initReveal } from "@/scripts/reveal";

  const section = document.querySelector<HTMLElement>("#crab");
  if (section) {
    initReveal(section);
    initMoments(section);
  }
</script>

<style>
  .moments {
    display: grid;
    gap: 36px;
    align-items: center;
    margin-top: 56px;
  }

  @media (min-width: 1024px) {
    .moments {
      grid-template-columns: 1.2fr 1fr;
      gap: 56px;
    }
  }

  .moments-desk {
    position: relative;
    margin: 0;
    aspect-ratio: 16 / 11;
    overflow: hidden;
    border-radius: 22px;
    corner-shape: squircle;
    box-shadow: 0 30px 70px rgb(0 0 0 / 0.22);
  }

  .moments-wall {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .moments-bar {
    position: absolute;
    inset: 0 0 auto;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 28px;
    padding: 0 14px;
    font-size: 12px;
    color: #fff;
    background: rgb(0 0 0 / 0.28);
    backdrop-filter: blur(14px) saturate(160%);
  }

  .moments-power {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    translate: 0 -4px;
    transition:
      opacity 0.25s ease,
      translate 0.25s ease;
  }

  .moments-power[data-state] {
    opacity: 1;
    translate: 0 0;
  }

  .moments-power svg {
    display: none;
    width: 13px;
    height: 13px;
  }

  .moments-power[data-state="charging"] [data-power-icon="charging"] {
    display: block;
    color: #ffd84a;
  }

  .moments-power[data-state="saver"] [data-power-icon="saver"] {
    display: block;
    color: #7ee2a8;
  }

  .moments-island {
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 12px;
    translate: -50% 0;
    border-radius: 0 0 14px 14px;
    background: #0b0c0f;
    color: #fff;
    font-size: 11px;
    box-shadow: 0 10px 28px rgb(0 0 0 / 0.35);
  }

  .moments-ring {
    width: 14px;
    height: 14px;
    rotate: -90deg;
  }

  .moments-ring circle {
    fill: none;
    stroke: rgb(255 255 255 / 0.18);
    stroke-width: 2.4;
  }

  .moments-ring circle + circle {
    stroke: #d97757;
    stroke-linecap: round;
    transition: stroke 0.3s ease;
  }

  .moments-island.is-hot .moments-ring circle + circle {
    stroke: #ff5a4e;
  }

  .moments-dock {
    position: absolute;
    left: 50%;
    bottom: 14px;
    z-index: 2;
    display: flex;
    width: max-content;
    gap: 6px;
    padding: 7px 10px;
    translate: -50% 0;
    border: 1px solid rgb(255 255 255 / 0.14);
    border-radius: 22px;
    corner-shape: squircle;
    background: rgb(255 255 255 / 0.16);
    backdrop-filter: blur(20px) saturate(170%);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
  }

  .moments-dock img {
    width: clamp(26px, 5vw, 44px);
    height: auto;
    filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.35));
  }

  .moments-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .moments-item {
    position: relative;
    display: grid;
    gap: 3px;
    width: 100%;
    overflow: hidden;
    padding: 14px 18px;
    border: 1px solid transparent;
    border-radius: 16px;
    corner-shape: squircle;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition:
      background 0.2s ease,
      border-color 0.2s ease;
  }

  .moments-item b {
    font-size: 1.05rem;
  }

  .moments-item span {
    color: var(--color-mute);
    line-height: 1.5;
  }

  .moments-item:hover {
    background: var(--color-card);
  }

  .moments-item[aria-pressed="true"] {
    border-color: var(--color-line);
    background: var(--color-card);
  }

  .moments-item:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
  }

  /* How far the current act has played. */
  .moments-progress {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transform-origin: 0 50%;
  }

  .moments-facts {
    display: grid;
    gap: 6px;
    margin: 20px 0 0;
    padding: 0 18px;
    list-style: none;
    font-size: 0.875rem;
    color: var(--color-mute);
  }

  .moments-facts li::before {
    content: "·";
    margin-right: 8px;
    color: var(--color-primary);
    font-weight: 800;
  }
</style>