Files
Checkmate/src/Components/StarPrompt/index.jsx
T

119 lines
2.9 KiB
React
Raw Normal View History

2025-03-03 11:27:43 -05:00
import React, { useState, useEffect } from 'react';
2025-03-03 15:58:03 -05:00
import { Box, Typography, IconButton } from '@mui/material';
2025-03-03 11:27:43 -05:00
import CloseIcon from '@mui/icons-material/Close';
2025-03-03 15:58:03 -05:00
import { useTheme } from '@emotion/react';
import './index.css';
2025-03-03 11:27:43 -05:00
2025-03-03 15:58:03 -05:00
const StarPrompt = () => {
2025-03-03 11:27:43 -05:00
const [isVisible, setIsVisible] = useState(false);
2025-03-03 15:58:03 -05:00
const STORAGE_KEY = 'starPromptClosed';
const theme = useTheme();
2025-03-03 11:27:43 -05:00
useEffect(() => {
2025-03-03 15:58:03 -05:00
const hasClosedPrompt = localStorage.getItem(STORAGE_KEY);
2025-03-03 11:27:43 -05:00
if (!hasClosedPrompt) {
setIsVisible(true);
}
2025-03-03 15:58:03 -05:00
}, []);
2025-03-03 11:27:43 -05:00
const handleClose = () => {
2025-03-03 15:58:03 -05:00
localStorage.setItem(STORAGE_KEY, 'true');
2025-03-03 11:27:43 -05:00
setIsVisible(false);
};
const handleStarClick = () => {
2025-03-03 15:58:03 -05:00
window.open('https://github.com/bluewave-labs/checkmate', '_blank');
2025-03-03 11:27:43 -05:00
};
if (!isVisible) return null;
return (
2025-03-03 15:58:03 -05:00
<Box
className="star-prompt"
2025-03-03 11:27:43 -05:00
sx={{
2025-03-03 15:58:03 -05:00
borderBottom: '1px solid',
borderColor: 'divider',
width: '100%',
2025-03-03 11:27:43 -05:00
backgroundColor: 'background.paper',
}}
>
2025-03-03 15:58:03 -05:00
<Box
sx={{
display: 'flex',
flexDirection: 'column',
px: theme.spacing(8),
py: 2
}}
>
<Box sx={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'flex-start',
mb: '10px'
}}>
<Typography
sx={{
fontFamily: 'Inter',
fontWeight: 500,
lineHeight: '14.52px',
letterSpacing: '0%',
color: '#344054',
pt: '19px'
}}
>
Star Checkmate
2025-03-03 11:27:43 -05:00
</Typography>
<IconButton
size="small"
onClick={handleClose}
sx={{
2025-03-03 15:58:03 -05:00
color: theme.palette.primary.contrastTextTertiary,
pt: 0,
pr: 0,
pb: 0,
pl: 0,
2025-03-03 11:27:43 -05:00
mr: -1,
'&:hover': {
2025-03-03 15:58:03 -05:00
backgroundColor: 'transparent',
color: theme.palette.primary.contrastTextSecondary
2025-03-03 11:27:43 -05:00
}
}}
>
2025-03-03 15:58:03 -05:00
<CloseIcon sx={{ fontSize: '18px' }} />
2025-03-03 11:27:43 -05:00
</IconButton>
</Box>
2025-03-03 15:58:03 -05:00
<Typography
sx={{
fontFamily: 'Inter',
fontWeight: 400,
lineHeight: '14.53px',
letterSpacing: '0%',
color: '#344054',
opacity: 0.8,
mb: '15px'
}}
>
See the latest releases and help grow the community on GitHub
2025-03-03 11:27:43 -05:00
</Typography>
<Box
2025-03-03 15:58:03 -05:00
component="img"
src="https://img.shields.io/github/stars/bluewave-labs/checkmate?label=checkmate&style=social"
alt="GitHub stars"
2025-03-03 11:27:43 -05:00
onClick={handleStarClick}
sx={{
cursor: 'pointer',
2025-03-03 15:58:03 -05:00
width: 'fit-content',
pb: '18px',
'&:hover': {
opacity: 0.8
}
2025-03-03 11:27:43 -05:00
}}
2025-03-03 15:58:03 -05:00
/>
2025-03-03 11:27:43 -05:00
</Box>
2025-03-03 15:58:03 -05:00
</Box>
2025-03-03 11:27:43 -05:00
);
};
export default StarPrompt;