Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go
6.1 KB
Raw Blame
/*
 * Attachment image figure.
 *
 * Shared by the editor NodeView and standalone attachment surfaces such as
 * chat messages, comment attachment lists, and markdown image renderers.
 * The Attachment component imports this file directly so its visual contract
 * does not depend on ContentEditor or ReadonlyContent being mounted first.
 */

.image-figure {
  position: relative;
  display: inline-block;
  margin: 0.75rem 0;
}

.image-figure[data-clickable="true"] {
  cursor: zoom-in;
}

.image-figure.image-selected .image-content {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.image-content {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* An image in a list of standalone attachments (the "card" layout): full
   size, so it reads without opening, but capped in height — a phone
   screenshot keeps its shape instead of running the length of the page.
   The list spaces its images itself. */
.image-figure.image-standalone {
  margin: 0;
}

.image-figure.image-standalone .image-content {
  width: auto;
  max-width: 100%;
  max-height: 36rem;
  box-shadow: 0 0 0 1px var(--border);
}

/* Reserved box. An unloaded <img> lays out at 0×0 inside the shrink-to-fit
   figure even with width/height attributes, so the figure carries the size:
   an image with a known pixel size (--image-width, --image-aspect) gets the
   box it will render at; one without gets a fixed-ratio placeholder until it
   loads. Without a box, every unloaded image sits in the viewport at once and
   lazy loading can't defer any of them. */
.image-figure[data-sized] {
  width: min(var(--image-width), 100%);
}

.image-figure.image-standalone[data-sized] {
  width: min(var(--image-width), 100%, 36rem * var(--image-aspect));
}

.image-figure[data-sized] .image-content {
  width: 100%;
  aspect-ratio: var(--image-aspect);
}

.image-figure[data-pending] {
  display: block;
}

.image-figure.image-standalone[data-pending] {
  width: 20rem;
  max-width: 100%;
}

.image-figure[data-pending] .image-content {
  width: 100%;
  aspect-ratio: 16 / 10;
}

.image-content:not([data-loaded]) {
  background-color: var(--muted);
}

.image-uploading {
  opacity: 0.5;
  animation: rte-upload-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes rte-upload-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.3; }
}

/* The pulse stops; the dimmed image still reads as uploading. */
@media (prefers-reduced-motion: reduce) {
  .image-uploading {
    animation: none;
  }
}

.image-toolbar {
  /* Keep the resting controls near their image so tabbing to them scrolls it into view. */
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  display: flex;
  width: max-content;
  gap: 1px;
  padding: 0.25rem;
  background: color-mix(in srgb, black 75%, transparent);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
}

.image-toolbar[data-placement] {
  position: fixed;
  inset-inline-end: auto;
  top: var(--image-toolbar-y, 0);
  left: var(--image-toolbar-x, 0);
}

.image-toolbar:is([data-placement="top"], [data-placement="bottom"]) {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.15s;
}

/* Keep the gap between the image and its toolbar hoverable. */
.image-toolbar::after {
  position: absolute;
  inset-inline: 0;
  height: 4px;
  content: "";
}

.image-toolbar[data-placement="top"]::after {
  top: 100%;
}

.image-toolbar[data-placement="bottom"]::after {
  bottom: 100%;
}

.image-toolbar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: calc(var(--radius) - 2px);
  color: white;
  transition: background 0.15s;
}

.image-toolbar button:hover {
  background: color-mix(in srgb, white 15%, transparent);
}

/*
 * Issue-timeline comment images. `data-comment-images` sits on the timeline
 * and the bottom composer, carrying the personal "Images in comments"
 * preference ("thumbnails" | "full"). "full" keeps the rules above.
 *
 * Thumbnails: attached images sit in a wrapping row at one height and their
 * own aspect (never cropped); a lone one, and any image in the body, gets a
 * larger box. Sized figures are capped by width, because capping the height
 * of an `aspect-ratio` image would stretch it. Click opens the full size.
 */
[data-comment-images="thumbnails"] [data-comment-image-list] {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.375rem;
}

[data-comment-images="thumbnails"] [data-comment-image-list] .image-standalone .image-content {
  max-height: 12.5rem;
}

[data-comment-images="thumbnails"] [data-comment-image-list] .image-standalone[data-sized] {
  width: min(var(--image-width), 100%, 12.5rem * var(--image-aspect));
}

[data-comment-images="thumbnails"] [data-comment-image-list] > .image-node:only-child .image-content {
  max-width: min(100%, 35rem);
  max-height: 25rem;
}

[data-comment-images="thumbnails"] [data-comment-image-list] > .image-node:only-child .image-standalone[data-sized] {
  width: min(var(--image-width), 100%, 35rem, 25rem * var(--image-aspect));
}

[data-comment-images="thumbnails"] .image-figure[data-sized]:not(.image-standalone) {
  width: min(var(--image-width), 100%, 35rem, 25rem * var(--image-aspect));
}

[data-comment-images="thumbnails"] .image-figure[data-pending]:not(.image-standalone) {
  max-width: 35rem;
}

[data-comment-images="thumbnails"] .image-figure:not([data-sized], [data-pending], .image-standalone) .image-content {
  width: auto;
  max-width: min(100%, 35rem);
  max-height: 25rem;
}

/* Comment composers, whatever the preference: an image keeps its place in
   the text as a small thumbnail, so what is being written stays in view. */
[data-comment-images] .ProseMirror .image-node {
  text-align: start;
}

[data-comment-images] .ProseMirror .image-figure[data-sized] {
  width: min(var(--image-width), 100%, 7.5rem * var(--image-aspect));
}

[data-comment-images] .ProseMirror .image-figure[data-pending] {
  width: 12rem;
}

[data-comment-images] .ProseMirror .image-figure:not([data-sized], [data-pending]) .image-content {
  width: auto;
  max-width: 100%;
  max-height: 7.5rem;
}