Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

9.6 KB
Raw Blame
---
/*
 * The home page's "What's new in 7" features as a bento grid. Each tile links to the guide that documents the feature
 * and shows a small animated motif of it (`whats-new/`). The section heading goes in the slot, so it shares the grid's
 * width and left edge. Motifs animate only while their tile is on screen, and hold one still frame under reduced
 * motion.
 */
import { withBase } from '../base-path';
import CanvasMotif from './whats-new/CanvasMotif.astro';
import ImageMapMotif from './whats-new/ImageMapMotif.astro';
import LoopMotif from './whats-new/LoopMotif.astro';
import ProjectsMotif from './whats-new/ProjectsMotif.astro';
import VideoMotif from './whats-new/VideoMotif.astro';
import WorkbenchMotif from './whats-new/WorkbenchMotif.astro';

const base = import.meta.env.BASE_URL;
const { t } = Astro.locals;

// In reading order, which the grid areas below follow at every width.
const tiles = [
  {
    id: 'workbench',
    title: t('whatsNew.workbench.title'),
    body: t('whatsNew.workbench.body'),
    link: '/users-guide/workbench/introduction/',
    Motif: WorkbenchMotif,
  },
  {
    id: 'projects',
    title: t('whatsNew.projects.title'),
    body: t('whatsNew.projects.body'),
    link: '/users-guide/projects/introduction/',
    Motif: ProjectsMotif,
  },
  {
    id: 'canvas',
    title: t('whatsNew.canvas.title'),
    body: t('whatsNew.canvas.body'),
    link: '/users-guide/canvas/canvas-guide/',
    Motif: CanvasMotif,
  },
  {
    id: 'video',
    title: t('whatsNew.video.title'),
    badge: t('whatsNew.experimentalBadge'),
    body: t('whatsNew.video.body'),
    link: '/users-guide/video-generation/introduction/',
    Motif: VideoMotif,
  },
  {
    id: 'map',
    title: t('whatsNew.imageMap.title'),
    body: t('whatsNew.imageMap.body'),
    link: '/users-guide/image-map/introduction/',
    Motif: ImageMapMotif,
  },
  {
    id: 'loops',
    title: t('whatsNew.loops.title'),
    body: t('whatsNew.loops.body'),
    link: '/users-guide/workflows/loop-nodes/',
    Motif: LoopMotif,
  },
];
---

<div class="bento" data-bento>
  <slot />
  <ul class="grid" role="list">
    {
      tiles.map(({ id, title, badge, body, link, Motif }) => (
        <li class:list={['tile', `tile--${id}`]} data-bento-tile>
          <a
            class="link"
            href={withBase(link, base)}
            aria-labelledby={`whats-new-${id}`}
            aria-describedby={`whats-new-${id}-body`}
          >
            <div class="text">
              <div class="heading">
                <h3 id={`whats-new-${id}`}>
                  {title}
                  {badge && <span class="badge">{badge}</span>}
                </h3>
                <svg
                  class="arrow"
                  width="16"
                  height="16"
                  viewBox="0 0 24 24"
                  fill="none"
                  stroke="currentColor"
                  stroke-width="2"
                  aria-hidden="true"
                >
                  <path d="M5 12h14M13 6l6 6-6 6" />
                </svg>
              </div>
              <p class="body" id={`whats-new-${id}-body`}>
                {body}
              </p>
            </div>
            <div class="visual" aria-hidden="true">
              <Motif />
            </div>
          </a>
        </li>
      ))
    }
  </ul>
</div>

<script>
  const bento = document.querySelector<HTMLElement>('[data-bento]');

  // Motifs run by default; this only pauses a tile's motif while it is off screen. A script that fails, loads late or
  // never hears from the observer therefore leaves them running, never frozen.
  if (bento) {
    const observer = new IntersectionObserver((entries) => {
      for (const { target, isIntersecting } of entries) target.toggleAttribute('data-paused', !isIntersecting);
    });
    for (const tile of bento.querySelectorAll('[data-bento-tile]')) observer.observe(tile);
  }
</script>

<style>
  /*
   * Wider than the splash column, like the hero screenshot: up to 80rem, centred, inside the page gutters. The grid
   * follows the bento's own width: one column, then two, then four.
   */
  .bento {
    --bento-width: min(100vw - 2 * var(--sl-content-pad-x), 80rem);
    --tile-pad: 1.25rem;
    container: bento / inline-size;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: var(--bento-width);
    margin-inline: calc((100% - var(--bento-width)) / 2);
  }

  .grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'workbench' 'projects' 'canvas' 'video' 'map' 'loops';
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  @container bento (min-width: 36rem) {
    .grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      grid-template-rows: minmax(28rem, auto) repeat(2, minmax(19rem, auto)) repeat(2, minmax(18rem, auto));
      grid-template-areas:
        'workbench workbench'
        'projects canvas'
        'video canvas'
        'map map'
        'loops loops';
    }
  }

  @container bento (min-width: 68rem) {
    .grid {
      grid-template-columns: repeat(4, minmax(0, 1fr));
      grid-template-rows: repeat(2, minmax(20rem, auto)) minmax(19rem, auto);
      grid-template-areas:
        'workbench workbench projects canvas'
        'workbench workbench video canvas'
        'map map loops loops';
    }
  }

  .tile {
    display: flex;
    min-width: 0;
  }

  .tile--workbench {
    grid-area: workbench;
  }

  .tile--projects {
    grid-area: projects;
  }

  .tile--canvas {
    grid-area: canvas;
  }

  .tile--video {
    grid-area: video;
  }

  .tile--map {
    grid-area: map;
  }

  .tile--loops {
    grid-area: loops;
  }

  /* Hovers like the site's link cards: a stronger border over the control fill. */
  .link {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
    border: 1px solid var(--docs-border);
    border-radius: var(--docs-radius-container);
    background-color: var(--docs-surface);
    color: var(--docs-text-strong);
    text-decoration: none;
    transition:
      border-color 150ms ease,
      background-color 150ms ease;

    &:is(:hover, :focus-visible) {
      border-color: var(--docs-border-strong);
      background-color: var(--docs-control);
      color: var(--docs-text-strong);
    }

    &:focus-visible {
      outline: 2px solid var(--docs-accent);
      outline-offset: 2px;
    }
  }

  .text {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.375rem var(--tile-pad) 0;
  }

  .heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
  }

  h3 {
    margin: 0;
    color: var(--docs-text-strong);
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.35;
    text-wrap: balance;
  }

  .tile--workbench h3 {
    font-size: clamp(1.1875rem, 1rem + 0.6vw, 1.375rem);
  }

  .badge {
    display: inline-block;
    margin-inline-start: 0.5rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--docs-radius);
    background-color: var(--sl-color-orange-low);
    color: var(--sl-color-orange-high);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.4;
    vertical-align: 0.15em;
  }

  .arrow {
    flex-shrink: 0;
    margin-top: 0.25rem;
    color: var(--sl-color-gray-4);
    transition:
      color 150ms ease-out,
      translate 200ms ease-out;
  }

  .link:is(:hover, :focus-visible) .arrow {
    color: var(--docs-accent);
    translate: 2px 0;
  }

  .body {
    max-width: 34rem;
    margin: 0;
    color: var(--docs-text-muted);
    font-size: 0.875rem;
    line-height: 1.55;
    text-wrap: pretty;
  }

  /*
   * The motif sits on the tile's own surface, in line with the copy. The visual is a size container, so a motif's
   * stage fits its content box either way; a stage wider than that box (wide motifs on a phone) bleeds into the
   * padding and is clipped at the tile's edge. One column gives each tile a fixed height; in the grid the visual
   * fills whatever its row leaves.
   */
  .visual {
    position: relative;
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    height: var(--visual-height, 12rem);
    overflow: hidden;
    container-type: size;
    padding: 0 var(--tile-pad) var(--tile-pad);
  }

  .tile--workbench {
    --visual-height: min(24rem, 72cqw);
  }

  .tile--canvas {
    --visual-height: 22rem;
  }

  /* Wide motifs would shrink to illegible on a phone; there they fill the height and crop at the sides instead. */
  .tile--map,
  .tile--loops {
    --visual-height: 12rem;

    :global(.wn-stage) {
      --stage-width: calc(100cqh * var(--stage-w) / var(--stage-h));
    }
  }

  @container bento (min-width: 36rem) {
    .visual {
      flex: 1 1 0;
      height: auto;
      min-height: 9rem;
    }

    .tile--map,
    .tile--loops {
      :global(.wn-stage) {
        --stage-width: initial;
      }
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    /* Tiles rise into place as they scroll in, where scroll-driven animations exist. */
    @supports ((animation-timeline: view()) and (animation-range: entry)) {
      /* Longhands only: the minifier would fold `animation-timeline` into the shorthand, which only resets it. */
      .tile {
        animation-name: bento-enter;
        animation-fill-mode: both;
        animation-timing-function: linear;
        animation-timeline: view();
        animation-range: entry 5% entry 65%;
      }
    }
  }

  @keyframes bento-enter {
    from {
      opacity: 0;
      translate: 0 1.5rem;
    }
  }

  /* Off screen, a tile's motif pauses where it is. */
  .tile[data-paused] .visual :global(*) {
    animation-play-state: paused;
  }
</style>