Skip to content
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

Refactor AverageRating component to use CSS modules for styling #3213

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/components/EventStats/Statistics/AverageRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Rating from '@mui/material/Rating';
import FavoriteIcon from '@mui/icons-material/Favorite';
import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder';
import Typography from '@mui/material/Typography';

import styles from '../../../style/app.module.css';
// Props for the AverageRating component
type ModalPropType = {
data: {
Expand Down Expand Up @@ -33,7 +33,7 @@ type FeedbackType = {
export const AverageRating = ({ data }: ModalPropType): JSX.Element => {
return (
<>
<Card style={{ width: '300px' }}>
<Card className={styles.cardContainer}>
<Card.Body>
<Card.Title>
<h4>Average Review Score</h4>
Expand All @@ -50,13 +50,9 @@ export const AverageRating = ({ data }: ModalPropType): JSX.Element => {
icon={<FavoriteIcon fontSize="inherit" />}
size="medium"
emptyIcon={<FavoriteBorderIcon fontSize="inherit" />}
sx={{
'& .MuiRating-iconFilled': {
color: '#ff6d75', // Color for filled stars
},
'& .MuiRating-iconHover': {
color: '#ff3d47', // Color for star on hover
},
classes={{
iconFilled: styles.ratingFilled,
iconHover: styles.ratingHover,
}}
/>
</Card.Body>
Expand Down
13 changes: 12 additions & 1 deletion src/style/app.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
--subtle-blue-grey-hover: #5f7e91;
--white: #fff;
--black: black;

--rating-star-filled: #ff6d75;
--rating-star-hover: #ff3d47;
/* Background and Border */
--table-bg: #eaebef;
--tablerow-bg: #eff1f7;
Expand Down Expand Up @@ -942,7 +943,17 @@ hr {
.card {
width: fit-content;
}
.cardContainer {
width: 300px;
}

.ratingFilled {
color: var(--rating-star-filled); /* Color for filled stars */
}

.ratingHover {
color: var(--rating-star-hover); /* Color for star on hover */
}
.cardHeader {
padding: 1.25rem 1rem 1rem 1rem;
border-bottom: 1px solid var(--bs-gray-200);
Expand Down
Loading