-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/1484 modal to encourage starring the repo #1517
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ import ChangeLog from "../../assets/icons/changeLog.svg?react"; | |
import Docs from "../../assets/icons/docs.svg?react"; | ||
import Folder from "../../assets/icons/folder.svg?react"; | ||
import ChatBubbleOutlineRoundedIcon from "@mui/icons-material/ChatBubbleOutlineRounded"; | ||
import CloseIcon from "@mui/icons-material/Close"; // Importing CloseIcon from MUI | ||
|
||
import "./index.css"; | ||
|
||
|
@@ -119,6 +120,7 @@ function Sidebar() { | |
const [anchorEl, setAnchorEl] = useState(null); | ||
const [popup, setPopup] = useState(); | ||
const { user } = useSelector((state) => state.auth); | ||
const [showStarRepo, setShowStarRepo] = useState(true); | ||
|
||
const accountMenuItem = menu.find((item) => item.name === "Account"); | ||
if (user.role?.includes("demo") && accountMenuItem) { | ||
|
@@ -156,6 +158,18 @@ function Sidebar() { | |
} | ||
}, [location]); | ||
|
||
useEffect(() => { | ||
const hasClosed = localStorage.getItem("starRepoClosed"); | ||
if (hasClosed) { | ||
setShowStarRepo(false); | ||
} | ||
}, []); | ||
|
||
const handleCloseStarRepo = () => { | ||
setShowStarRepo(false); | ||
localStorage.setItem("starRepoClosed", "true"); | ||
}; | ||
|
||
/* TODO refactor this, there are a some ternaries and comments in the return */ | ||
|
||
return ( | ||
|
@@ -508,6 +522,69 @@ function Sidebar() { | |
</List> | ||
<Divider sx={{ mt: "auto" }} /> | ||
|
||
{showStarRepo && ( | ||
<Box | ||
sx={{ | ||
backgroundColor: theme.palette.background.paper, | ||
padding: theme.spacing(4), | ||
borderRadius: theme.shape.borderRadius, | ||
position: "relative", | ||
height: theme.spacing(50), // Converted 100px to theme spacing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spacing seems an semantically incorrect value to use for height. It would also probably be ideal to use a relative height here as well. |
||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
margin: theme.spacing(3), | ||
}} | ||
> | ||
<Typography | ||
sx={{ | ||
fontWeight: theme.typography.fontWeightBold, // Use theme for font weight | ||
marginTop: theme.spacing(1), | ||
color: theme.palette.text.primary, | ||
fontSize: theme.typography.pxToRem(16) // Use theme for font size | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there some reason not to use the defined font sizes?
Why are we overriding the theme typography levels? This appears to be an anti-pattern to me, to first have sizes set in the theme and then override them? |
||
}} | ||
variant="body2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are declaring a variant to use then we should not override that variant's styles |
||
> | ||
Star Checkmate | ||
</Typography> | ||
<Typography | ||
sx={{ | ||
fontSize: theme.typography.pxToRem(13), // Use theme for font size | ||
marginTop: theme.spacing(2), | ||
color: theme.palette.text.primary | ||
}} | ||
variant="body2" | ||
> | ||
See the latest releases and help grow the community on GitHub | ||
</Typography> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
justifyContent: "start", | ||
alignItems: "center", | ||
marginTop: theme.spacing(2.5), // Converted 10px to theme spacing | ||
marginBottom: theme.spacing(2.5) // Converted 10px to theme spacing | ||
}} | ||
> | ||
<a href="https://github.com/bluewave-labs/checkmate" target="_blank" rel="noopener noreferrer"> | ||
<img src="https://img.shields.io/github/stars/bluewave-labs/checkmate?label=checkmate&style=social" alt="Checkmate Logo" /> | ||
</a> | ||
</Box> | ||
<Box sx={{ borderTop: '1px solid', borderColor: theme.palette.divider, my: 2 }} /> | ||
<IconButton | ||
sx={{ | ||
position: "absolute", | ||
top: 0, | ||
right: 0, | ||
mt: "-10px", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why -10px? Where did this value come from? |
||
}} | ||
onClick={handleCloseStarRepo} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</Box> | ||
)} | ||
|
||
<Stack | ||
direction="row" | ||
height="50px" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an insufficient solution for whether or not a user has closed the star repo modal. If the user uses a different device/browser or clears their browser data the repo will show again.
A complete solution would require a server side implementation, ie storing a flag in the User model in the database, and persisting that state in the Redux store on the front end with the rest of the user data.
update
For the purposes of this PR we can accept this solution, please add a TODO comment noting that the solution is incomplete and will eventually need to be addressed. Thank you!