Skip to content

Commit

Permalink
Add Settings page link to the user profile card when a user is viewin…
Browse files Browse the repository at this point in the history
…g their own profile page.
  • Loading branch information
MatthewWid committed Sep 16, 2019
1 parent 4499343 commit fb8972f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/client/js/components/ProfileCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ import React from "react";
import {Link} from "react-router-dom";
import Banner from "./Banner.js";
import Avatar from "./Avatar.js";
import InlineSvg from "react-inlinesvg";

/*
Presentational component to render a users' profile card.
Requires a `user` object prop that represents the given user.
*/
const ProfileCard = (props) => {
const {user} = props;
const {user, withSettings} = props;

if (!user) {
return null;
}

return (
<div className={`${props.className && `${props.className} ` || ""}profile-card`}>
<div className={`${props.className && `${props.className} ` || ""}profile-card${withSettings ? " profile-card--settings" : ""}`}>
{/* If the `className` prop is supplied then add the classNames to this component. */}
<Banner user={user} />
<div className="profile-card__info">
Expand All @@ -27,6 +28,18 @@ const ProfileCard = (props) => {
<p className="profile-card__name">@{user.name}</p>
</Link>
</div>
{
withSettings &&
<div className="profile-card__settings-link">
<Link to="/settings">
<InlineSvg
className="svg profile-card__settings-icon"
src="/images/icons/cog.svg"
cacheGetRequests
/>
</Link>
</div>
}
</div>
{props.children}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/client/js/components/ProfileUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ const ProfileUser = (props) => {

return (
<ProfileCard
user={user}
className="content__panel card"
user={user}
withSettings={loggedUser.user && user._id === loggedUser.user._id}
>
{followButton}
</ProfileCard>
Expand Down
37 changes: 37 additions & 0 deletions src/client/scss/components/_ProfileCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,41 @@
margin: 10px;
margin-top: 0;
}
&--settings & {
&__settings {
display: block;
}
&__names {
margin-right: 0px !important;
}
}
&__settings {
display: none;

&-link:hover &-icon svg {
transform: rotateZ(180deg);
}
&-link {
width: 50px;
height: 50px;
margin: 0 auto;

a {
display: block;
padding: 14px;
}
}
&-icon {
width: 100%;
height: 100%;

svg {
fill: $text-grey;
transition: transform .2s ease;
}
path {
fill: inherit;
}
}
}
}

0 comments on commit fb8972f

Please sign in to comment.