Use the user's stored profile picture in content

Also adds styles!
This commit is contained in:
Justin Edmund 2022-03-04 05:17:23 -08:00
parent 6b999106b5
commit 7e5b90a6c7
3 changed files with 58 additions and 12 deletions

View file

@ -83,11 +83,12 @@ const GridRep = (props: Props) => {
if (props.user) if (props.user)
return ( return (
<img <img
alt="Gran" alt={props.user.picture.picture}
className="gran" className={`profile ${props.user.picture.element}`}
srcSet="/profile/gran.png, srcSet={`/profile/${props.user.picture.picture}.png,
/profile/gran@2x.png 2x" /profile/${props.user.picture.picture}@2x.png 2x`}
src="/profile/gran.png" /> src={`/profile/${props.user.picture.picture}.png`}
/>
) )
else else
return (<div className="no-user" />) return (<div className="no-user" />)

View file

@ -22,7 +22,12 @@ const ProfileRoute: React.FC = () => {
const [user, setUser] = useState<User>({ const [user, setUser] = useState<User>({
id: '', id: '',
username: '', username: '',
granblueId: 0 granblueId: 0,
picture: {
picture: '',
element: ''
},
private: false
}) })
// Filter states // Filter states
@ -63,7 +68,9 @@ const ProfileRoute: React.FC = () => {
setUser({ setUser({
id: response.data.user.id, id: response.data.user.id,
username: response.data.user.username, username: response.data.user.username,
granblueId: response.data.user.granblue_id granblueId: response.data.user.granblue_id,
picture: response.data.user.picture,
private: response.data.user.private
}) })
const parties: Party[] = response.data.user.parties const parties: Party[] = response.data.user.parties
@ -113,11 +120,12 @@ const ProfileRoute: React.FC = () => {
<FilterBar onFilter={receiveFilters} scrolled={scrolled}> <FilterBar onFilter={receiveFilters} scrolled={scrolled}>
<div className="UserInfo"> <div className="UserInfo">
<img <img
alt="Gran" alt={user.picture.picture}
className="gran" className={`profile ${user.picture.element}`}
srcSet="/profile/gran.png, srcSet={`/profile/${user.picture.picture}.png,
/profile/gran@2x.png 2x" /profile/${user.picture.picture}@2x.png 2x`}
src="/profile/gran.png" /> src={`/profile/${user.picture.picture}.png`}
/>
<h1>{user.username}</h1> <h1>{user.username}</h1>
</div> </div>
</FilterBar> </FilterBar>

View file

@ -290,6 +290,43 @@ select {
} }
} }
.profile {
background: $grey-90;
&.fire {
background: $fire-bg-light;
}
&.water {
background: $water-bg-light;
}
&.wind {
background: $wind-bg-light;
}
&.earth {
background: $earth-bg-light;
}
&.dark {
background: $dark-bg-light;
}
&.light {
background: $light-bg-light;
}
}
i.tag {
background: $grey-90;
border-radius: $unit / 2;
font-size: 10px;
font-weight: $bold;
padding: 4px 6px;
text-transform: uppercase;
}
@keyframes openModal { @keyframes openModal {
0% { 0% {
opacity: 0; opacity: 0;