Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.5 KB
Raw Blame
import { createStaticStyles, cx } from '@lobehub/ui';
import type { ReactNode } from 'react';

import { densityVars } from '@/styles/densityVars';

const styles = createStaticStyles(({ css }) => ({
  // Cards carry their own frame, so the grid sits bare in its host. Columns
  // step by the host's own width β€” one on a phone, then two, three and four β€”
  // keeping every card at least ~270px wide. In the 1024px settings column the
  // grid tops out at three; the four-column step serves wider hosts.
  grid: css`
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: ${densityVars.sectionGap};
    min-width: 0;

    @container device-grid (min-width: 560px) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    @container device-grid (min-width: 880px) {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    @container device-grid (min-width: 1200px) {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  `,
  // Query container for the grid's column steps (a grid can't query itself).
  host: css`
    container: device-grid / inline-size;
    min-width: 0;
  `,
}));

interface DeviceGridProps {
  children: ReactNode;
  className?: string;
}

/**
 * The device card grid β€” shared by the loaded list and its skeleton, so the
 * loading β†’ loaded swap keeps every card in place.
 */
const DeviceGrid = ({ children, className }: DeviceGridProps) => (
  <div className={styles.host}>
    <div className={cx(styles.grid, className)}>{children}</div>
  </div>
);

export default DeviceGrid;