File size: 2,429 Bytes
ce8c232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import React from "react";
import styled from "styled-components";
import { CircleCheckBig } from "lucide-react";
import { media } from "../Utils/helper.js"; // 👈 adjust path as needed

const Card = styled.div`
  display: flex;
  flex-direction: ${(props) => props.direction || "row"};
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background: white;
  position: relative;
  border-inline: 4px solid #2563eb;

  @media ${media.laptop} {
    padding: 16px;
  }

  @media ${media.tablet} {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  @media ${media.mobile} {
    padding: 12px;
    gap: 10px;
  }
`;

const Label = styled.span`
  color: #4b5563;
  font-size: 1.4rem;
  font-weight: ${(props) => props.fontWeight || 500};
  flex: 1 1 auto;              /* allow it to shrink and grow */
  min-width: 0;                /* necessary for flex children to wrap */
  word-wrap: break-word;      /* legacy but still widely used */
  overflow-wrap: break-word;  /* modern equivalent */
  word-break: break-word;     /* ensures breaking long words */

  @media ${media.tablet} {
    font-size: 1.2rem;
  }

  @media ${media.mobile} {
    font-size: 1rem;
  }
`;

const ScoreWrapper = styled.div`
  display: flex;
  align-items: center;
  gap: 8px;
`;

const Score = styled.span`
  font-weight: bold;
  font-size: ${(props) => props.fontSize || 1.5}rem;
  color: #000;
    
  @media ${media.tablet} {
    font-size: 1.3rem;
    flex: 1 1 auto;              
    min-width: 0;                
    word-break: break-word;
  }

  @media ${media.mobile} {
    font-size: 1.1rem;
    flex: 1 1 auto;              
    min-width: 0;                
    word-break: break-word;
  }
`;

const Icon = styled(CircleCheckBig)`
  width: 20px;
  height: 20px;
  color: #37c200;
  cursor: pointer;

  @media ${media.mobile} {
    width: 18px;
    height: 18px;
  }
`;

const ScoreCard = ({ label, score, width, direction, fontSize, fontWeight }) => {
  if (typeof score === "number") score = Math.round(score * 100) / 100;
  return (
    <Card width={width} direction={direction}>
      <Label fontWeight={fontWeight}>{label}</Label>
      <ScoreWrapper>
        <Score fontSize={fontSize}>{score}</Score>
        <Icon />
      </ScoreWrapper>
    </Card>
  );
};

export default ScoreCard;