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.4 KB
Raw Blame
import { UserIcon } from '@core/component/UserIcon';
import { Key } from '@solid-primitives/keyed';
import { AvatarGroup } from '@ui';
import { Show } from 'solid-js';
import type { Property } from '../types';
import { getEntityValues, isEntityProperty } from '../utils';

type Props = {
  property: Property;
  maxUsers?: number;
  /** Extra classes applied to each avatar (e.g. responsive sizing). */
  avatarClass?: string;
};

/**
 * Avatar stack for ENTITY+USER properties. Renders nothing for other types.
 */
export function PropertyUserStack(props: Props) {
  const isUser = () =>
    isEntityProperty(props.property) &&
    props.property.specificEntityType === 'USER';

  const max = () => props.maxUsers ?? 3;

  const entities = () => getEntityValues(props.property);
  const display = () => entities().slice(0, max());
  const remaining = () => Math.max(0, entities().length - max());

  return (
    <Show when={isUser()}>
      <AvatarGroup size="sm" class="-space-x-2">
        <Key each={display()} by="entity_id">
          {(entity) => (
            <UserIcon
              id={entity().entity_id}
              size="sm"
              suppressClick
              showTooltip={false}
              class={props.avatarClass}
            />
          )}
        </Key>
        <Show when={remaining() > 0}>
          <AvatarGroup.Count size="sm">+{remaining()}</AvatarGroup.Count>
        </Show>
      </AvatarGroup>
    </Show>
  );
}