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

Add an icon next to moderator names #42

Merged
merged 1 commit into from
Nov 28, 2024
Merged
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
33 changes: 16 additions & 17 deletions src/components/User.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { useHistory } from "react-router-dom";
import { useTheme, makeStyles } from "@material-ui/core/styles";
import Security from "@material-ui/icons/Security";
import WhatshotIcon from "@material-ui/icons/Whatshot";

import useFirebaseRef from "../hooks/useFirebaseRef";
import useStats from "../hooks/useStats";
import { colors } from "../util";

const useStyles = makeStyles((theme) => ({
patronIcon: {
cursor: "pointer",
"&:hover": {
filter: `drop-shadow(0.1rem 0rem 0.2rem)`,
},
},
rating: {
display: "inline-block",
width: "3em",
Expand All @@ -35,7 +29,6 @@ function User({
...other
}) {
const theme = useTheme();
const history = useHistory();
const classes = useStyles();

const [user, loading] = useFirebaseRef(`users/${id}`);
Expand All @@ -45,11 +38,6 @@ function User({
return null;
}

const handleClick = (e) => {
e.preventDefault();
history.push("/donate");
};

const Component = component || "span";
const userEl = (
<Component
Expand All @@ -67,10 +55,8 @@ function User({
{loadingStats ? "⋯" : Math.round(stats[showRating].rating)}
</span>
)}
{(user.patron || forcePatron) && (
<WhatshotIcon
className={classes.patronIcon}
onClick={handleClick}
{user.admin ? (
<Security
fontSize="inherit"
style={{
display: "inline",
Expand All @@ -80,6 +66,19 @@ function User({
color: "inherit",
}}
/>
) : (
(user.patron || forcePatron) && (
<WhatshotIcon
fontSize="inherit"
style={{
display: "inline",
position: "relative",
left: "-0.1em",
top: "0.15em",
color: "inherit",
}}
/>
)
)}
<span>{user.name}</span>
</Component>
Expand Down