All files / apps/timeOff/src/components/DateInfo index.tsx

100% Statements 8/8
100% Branches 2/2
100% Functions 2/2
100% Lines 7/7

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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132                            2x           14x 14x   14x 2x                                                           12x                                     14x                                                                                                                    
import { Text, TextStyle, View } from 'react-native';
 
import { CalendarIcon } from '@repo/ui/icons/Calendar';
import { makeStyles } from '@repo/ui/themes/makeStyles';
import { useTheme } from '@repo/ui/themes/ThemeContext';
import { textStyles } from '@repo/ui/themes/typography';
 
interface Props {
  summaryDateText: string;
  summaryValueText: string;
  summaryDateStyle?: TextStyle;
  summaryValueStyle?: TextStyle;
}
 
export const DateInfo = ({
  summaryDateText,
  summaryValueText,
  summaryDateStyle,
  summaryValueStyle,
}: Props) => {
  const styles = useStyles();
  const { theme } = useTheme();
 
  if (theme.isNewTheme) {
    return (
      <View style={styles.cardContainer}>
        {/* Calendar icon */}
        <CalendarIcon width={22} height={22} color={theme.colors.icon.brand} />
 
        {/* Date text */}
        <Text
          style={[styles.cardDate, summaryDateStyle]}
          numberOfLines={1}
          testID="date-infor-text"
        >
          {summaryDateText}
        </Text>
 
        {/* Vertical divider */}
        <View style={styles.dividerWrapper}>
          <View style={styles.divider} />
        </View>
 
        {/* Days off text */}
        <Text
          style={[styles.cardValue, summaryValueStyle]}
          testID="days-off-text"
        >
          {summaryValueText}
        </Text>
      </View>
    );
  }
 
  return (
    <View style={styles.summaryContainer}>
      <Text
        style={[styles.summaryDate, summaryDateStyle]}
        numberOfLines={1}
        testID="date-infor-text"
      >
        {summaryDateText}
      </Text>
      <Text
        style={[styles.summaryDaysOff, summaryValueStyle]}
        testID="days-off-text"
      >
        {summaryValueText}
      </Text>
    </View>
  );
};
 
const useStyles = makeStyles(theme => ({
  // ── v1 styles ──────────────────────────────────────────────
  summaryContainer: {
    gap: theme.metrics.spacing[0.5],
  },
  summaryDate: {
    ...textStyles.content.regular,
    color: theme.colors.text.tertiary,
    fontSize: theme.metrics.textSize[32],
    lineHeight: theme.metrics.textSize[36],
    fontWeight: theme.metrics.fontWeight.light,
  },
  summaryDaysOff: {
    ...textStyles.content.semiBold,
    lineHeight: theme.metrics.textSize[24],
    color: theme.colors.text.tertiary,
    fontSize: theme.metrics.textSize[20],
    fontWeight: theme.metrics.fontWeight.semiBold,
  },
 
  // ── v2 card styles ─────────────────────────────────────────
  cardContainer: {
    flexDirection: 'row',
    alignItems: 'center',
    gap: theme.metrics.spacing[3],
    borderWidth: 1,
    borderColor: theme.colors.border.primary,
    borderRadius: theme.metrics.borderRadius[4],
    paddingVertical: theme.metrics.spacing[3],
    paddingHorizontal: theme.metrics.spacing[4],
    backgroundColor: theme.colors.background.card,
    marginTop: -theme.metrics.spacing[3],
  },
  cardDate: {
    ...textStyles.content.semiBold,
    color: theme.colors.text.default,
    fontSize: theme.metrics.textSize[16],
    fontWeight: theme.metrics.fontWeight.semiBold,
    flex: 5,
  },
  dividerWrapper: {
    alignSelf: 'stretch',
    justifyContent: 'center',
    alignItems: 'center',
  },
  divider: {
    width: 1,
    height: 30,
    backgroundColor: theme.colors.text.muted,
  },
  cardValue: {
    ...textStyles.content.regular,
    color: theme.colors.text.default,
    fontSize: theme.metrics.textSize[16],
    flex: 4,
    textAlign: 'center',
  },
}));