All files / apps/timeOff/src/screens/ChooseApproversAndObservers Skeleton.tsx

100% Statements 12/12
100% Branches 4/4
100% Functions 5/5
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116          1x             1x             1x 1x   1x               4x                           4x                             1x 1x 1x     2x                                                                                                      
import { ScrollView, Text, View } from 'react-native';
 
import { makeStyles } from '@repo/ui/themes/makeStyles';
import { textStyles } from '@repo/ui/themes/typography';
 
const APPROVER_SKELETON_ITEMS = [
  { id: 'approver-1', showLabel: true },
  { id: 'approver-2', showLabel: true },
  { id: 'approver-3', showLabel: true },
  { id: 'approver-add', showLabel: false },
];
 
const OBSERVER_SKELETON_ITEMS = [
  { id: 'observer-1', showLabel: true },
  { id: 'observer-2', showLabel: true },
  { id: 'observer-3', showLabel: true },
  { id: 'observer-add', showLabel: false },
];
 
export const ApproversAndObserversSkeleton = () => {
  const styles = useStyles();
 
  return (
    <View style={styles.container}>
      <ScrollView style={styles.scrollView} scrollEnabled={false}>
        <View style={styles.content}>
          <View style={styles.personGroup}>
            <Text style={styles.label}>APPROVERS</Text>
            <View style={styles.avatarRow}>
              {APPROVER_SKELETON_ITEMS.map(({ id, showLabel }) => (
                <View key={id} style={styles.avatarItem}>
                  <View style={[styles.block, styles.avatar]} />
                  {showLabel ? (
                    <View style={[styles.block, styles.avatarLabel]} />
                  ) : null}
                </View>
              ))}
            </View>
          </View>
 
          <View style={styles.personGroup}>
            <Text style={styles.label}>OBSERVERS</Text>
            <View style={styles.avatarRow}>
              {OBSERVER_SKELETON_ITEMS.map(({ id, showLabel }) => (
                <View key={id} style={styles.avatarItem}>
                  <View style={[styles.block, styles.avatar]} />
                  {showLabel ? (
                    <View style={[styles.block, styles.avatarLabel]} />
                  ) : null}
                </View>
              ))}
            </View>
          </View>
        </View>
      </ScrollView>
    </View>
  );
};
 
export const ApproversAndObserversSearchSkeleton = () => {
  const styles = useStyles();
  return <View style={[styles.block, styles.searchLoader]} />;
};
 
const useStyles = makeStyles(theme => ({
  container: {
    flex: 1,
    backgroundColor: theme.colors.background.pageMuted,
  },
  scrollView: {
    flexGrow: 1,
  },
  content: {
    flex: 1,
    paddingTop: theme.metrics.spacing[2],
    gap: theme.metrics.spacing[4],
    backgroundColor: theme.colors.background.pageMuted,
  },
  personGroup: {
    gap: theme.metrics.spacing[4],
  },
  label: {
    fontWeight: theme.metrics.fontWeight.semiBold,
    textTransform: 'uppercase',
    ...textStyles.content.semiBold,
  },
  block: {
    backgroundColor: theme.colors.skeleton.default,
  },
  avatarRow: {
    flexDirection: 'row',
    flexWrap: 'wrap',
  },
  avatarItem: {
    width: '25%',
    alignItems: 'center',
    marginBottom: theme.metrics.spacing[5],
  },
  avatar: {
    width: theme.metrics.spacing[15],
    height: theme.metrics.spacing[15],
    borderRadius: theme.metrics.borderRadius.circle,
  },
  avatarLabel: {
    marginTop: theme.metrics.spacing[2],
    width: theme.metrics.spacing[12],
    height: theme.metrics.spacing[3],
    borderRadius: theme.metrics.borderRadius[1],
  },
  searchLoader: {
    width: theme.metrics.spacing[40],
    height: theme.metrics.spacing[12],
    borderRadius: theme.metrics.borderRadius[4],
  },
}));