Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.1 KB
Raw Blame
import ChannelIcon from '@icon/system/regular/hash-straight.svg';
import { cn } from '@ui';
import { createMemo, createSignal, type JSX, Show } from 'solid-js';

/** Presentation shared by the header, editor, and channel rows. */
export function ChannelPicture(props: {
  url?: string;
  revision?: number;
  class?: string;
  fallback?: JSX.Element;
}) {
  // A refetch permits another attempt at the same URL without reloading healthy images.
  const request = createMemo(() => ({
    url: props.url,
    revision: props.revision,
  }));
  const [failedRequest, setFailedRequest] =
    createSignal<ReturnType<typeof request>>();
  return (
    <span class={cn('inline-flex shrink-0', props.class ?? 'size-6')}>
      <Show
        when={request().url && request() !== failedRequest()}
        fallback={props.fallback ?? <ChannelIcon class="size-full" />}
      >
        <img
          src={request().url}
          alt=""
          class="size-full rounded-lg object-cover"
          onError={() => setFailedRequest(request())}
        />
      </Show>
    </span>
  );
}