All files / src/components BadgesModal.tsx

0% Statements 0/9
0% Branches 0/1
0% Functions 0/2
0% Lines 0/8

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                                                                                                                 
import React from 'react';
import { AchievementData } from '../types';
 
interface BadgesModalProps {
    show: boolean;
    achievements: AchievementData[];
    onClose: () => void;
}
 
const BadgesModal: React.FC<BadgesModalProps> = ({ show, achievements, onClose }) => {
    Iif (!show) return null;
 
    const modalStyle: React.CSSProperties = {
        position: 'fixed',
        top: '50%',
        left: '50%',
        transform: 'translate(-50%, -50%)',
        backgroundColor: '#fff',
        padding: '20px',
        borderRadius: '8px',
        boxShadow: '0 0 10px rgba(0,0,0,0.1)',
        zIndex: 1000,
        maxWidth: '80%',
        maxHeight: '80%',
        overflow: 'auto',
    };
 
    const overlayStyle: React.CSSProperties = {
        position: 'fixed',
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        backgroundColor: 'rgba(0,0,0,0.5)',
        zIndex: 999,
    };
 
    return (
        <>
            <div style={overlayStyle} onClick={onClose} />
            <div style={modalStyle} role="dialog" aria-modal="true" aria-labelledby="badges-title">
                <h2 id="badges-title">Your Achievements</h2>
                <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'center' }}>
                    {achievements.map(achievement => (
                        <div key={achievement.id} style={{ margin: '10px', textAlign: 'center' }}>
                            <img src={achievement.icon} alt={achievement.title} style={{ width: '50px', height: '50px' }} />
                            <h4>{achievement.title}</h4>
                        </div>
                    ))}
                </div>
                <button onClick={onClose} style={{ marginTop: '20px' }}>Close</button>
            </div>
        </>
    );
};
 
export default React.memo(BadgesModal);