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.

3.0 KB
Raw Blame
'use client';

import { Flexbox } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';

import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
import type { RouteSkeletonProps } from '@/spa/router/routeMeta';
import { useInterfaceDensity } from '@/styles/density';

import SkeletonBar from './Bar';

const styles = stylex.create({
  listRows: {
    display: 'flex',
    flexDirection: 'column',
    borderBlockWidth: '1px',
    borderBlockStyle: 'solid',
    borderBlockColor: cssVar.colorBorderSecondary,
  },
});

/**
 * The three row shapes a goal list settles into. Exported so a list that is
 * re-reading one of its tabs can hold the same shape instead of collapsing to
 * blank while the server answers. Compact rows (6px padding, 14px title over a
 * 12px requirement) settle at ~57px, so the skeleton pads 11px around its 35px
 * bar stack.
 */
export const GoalListRowsSkeleton = () => {
  const compact = useInterfaceDensity() === 'compact';

  return (
    <Flexbox aria-busy className={stylex.props(styles.listRows).className}>
      {Array.from({ length: 3 }).map((_, index) => (
        <Flexbox horizontal align={'center'} gap={12} key={index} paddingBlock={compact ? 11 : 14}>
          <SkeletonBar height={20} radius={'50%'} width={20} />
          <Flexbox flex={1} gap={7}>
            <SkeletonBar height={16} width={`${36 + index * 8}%`} />
            <SkeletonBar height={12} width={`${54 + index * 6}%`} />
          </Flexbox>
          <SkeletonBar height={24} width={72} />
        </Flexbox>
      ))}
    </Flexbox>
  );
};

const GoalSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (
  <Flexbox aria-busy flex={1} height={'100%'}>
    {chrome !== 'body' && <NavHeader />}
    <WideScreenContainer
      fullWidth
      flex={1}
      gap={20}
      paddingBlock={16}
      paddingInline={16}
      wrapperStyle={{ flex: 1, overflowY: 'auto' }}
    >
      <Flexbox horizontal align={'center'} justify={'space-between'} paddingBlock={'6px 18px'}>
        <Flexbox gap={6}>
          <SkeletonBar height={20} width={160} />
          <SkeletonBar height={14} width={280} />
        </Flexbox>
        <Flexbox horizontal gap={20}>
          {Array.from({ length: 3 }).map((_, index) => (
            <Flexbox gap={5} key={index} width={88}>
              <SkeletonBar height={20} width={32} />
              <SkeletonBar height={12} width={56} />
            </Flexbox>
          ))}
        </Flexbox>
      </Flexbox>
      <Flexbox gap={10}>
        <Flexbox horizontal align={'center'} justify={'space-between'}>
          <SkeletonBar height={18} width={112} />
          <Flexbox horizontal gap={8}>
            <SkeletonBar height={28} width={112} />
            <SkeletonBar height={28} width={64} />
          </Flexbox>
        </Flexbox>
        <GoalListRowsSkeleton />
      </Flexbox>
    </WideScreenContainer>
  </Flexbox>
);

export default GoalSkeleton;