Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Add Tools > People > Following page (#671)
Browse files Browse the repository at this point in the history
- Added PeopleToolPage.
- Refactored tool stylesheets.
  • Loading branch information
voidxnull committed Oct 9, 2016
1 parent 2dc533f commit fb9deb2
Show file tree
Hide file tree
Showing 15 changed files with 398 additions and 69 deletions.
8 changes: 8 additions & 0 deletions src/actions/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const TOOLS__SET_SCHOOLS_ALPHABET = 'TOOLS__SET_SCHOOLS_ALPHABET';
export const TOOLS__ADD_USER_POSTS_TO_RIVER = 'TOOLS__ADD_USER_POSTS_TO_RIVER';
export const TOOLS__SET_USER_POSTS_RIVER = 'TOOLS__SET_USER_POSTS_RIVER';

export const TOOLS__SET_FOLLOWED_USERS = 'TOOLS__SET_FOLLOWED_USERS';

export function addSchoolsToRiver(schools) {
return {
Expand Down Expand Up @@ -66,3 +67,10 @@ export function setUserPostsRiver(posts) {
posts
};
}

export function setFollowedUsers(users) {
return {
type: TOOLS__SET_FOLLOWED_USERS,
users
};
}
71 changes: 71 additions & 0 deletions src/components/tools/user-details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
This file is a part of libertysoil.org website
Copyright (C) 2016 Loki Education (Social Enterprise)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import { Link } from 'react-router';

import {
Immutable as ImmutablePropType
} from '../../prop-types/common';
import Avatar from '../user/avatar';
import FollowButton from '../follow-button';


export default function UserDetails({ current_user, following, triggers, user }) {
if (!user) {
return null;
}

const firstName = user.getIn(['more', 'firstName']) || '';
const lastName = user.getIn(['more', 'lastName']) || '';
const fullName = `${firstName} ${lastName}`;

if (user) {
return (
<div className="tools_page__details_col">
<div className="tools_details">
<div className="tools_details__left_col">
<Avatar isRound={false} size={140} user={user.toJS()} />
</div>
<div>
<Link className="tools_details__title" to={`/user/${user.get('username')}`}>
{user.get('username')}
</Link>
<div className="tools_details__description">
{fullName}
</div>
<FollowButton
active_user={current_user.toJS()}
following={following.toJS()}
triggers={triggers}
user={user.toJS()}
/>
</div>
</div>
</div>
);
}

return null;
}

UserDetails.propTypes = {
current_user: ImmutablePropType(FollowButton.propTypes.active_user),
following: ImmutablePropType(FollowButton.propTypes.following),
triggers: FollowButton.propTypes.triggers,
user: ImmutablePropType(FollowButton.propTypes.user)
};
61 changes: 61 additions & 0 deletions src/components/tools/user-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
This file is a part of libertysoil.org website
Copyright (C) 2016 Loki Education (Social Enterprise)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { PropTypes } from 'react';

import {
uuid4 as uuid4PropType,
Immutable as ImmutablePropType
} from '../../prop-types/common';
import {
ArrayOfUsers as ArrayOfUsersPropType
} from '../../prop-types/users';
import Avatar from '../user/avatar';


export default function UserList({ onClick, users, selectedUserId }) {
const items = users.map((user, index) => {
const handleClick = () => onClick(user.get('id'));
let className = 'tools_item tools_item-clickable';
if (user.get('id') === selectedUserId) {
className += ' tools_item-selected';
}

return (
<div
className={className}
key={index}
onClick={handleClick}
>
<Avatar size={23} user={user.toJS()} />
<span className="tools_item__child-padded">{user.get('username')}</span>
</div>
);
});

return (
<div className="tools_page__list_col">
{items}
</div>
);
}

UserList.propTypes = {
onClick: PropTypes.func.isRequired,
selectedUserId: uuid4PropType,
users: ImmutablePropType(ArrayOfUsersPropType).isRequired
};
38 changes: 1 addition & 37 deletions src/less/blocks/tools/schools_tool.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,16 @@
*/
.schools_tool {
@space: 20px;
@doubleSpace: @space * 2;
@subtextColor: #888;

&__list_col {
margin-right: @space;
width: 400px;
overflow-y: auto;
}

&__school_item {
display: flex;

&:hover {
cursor: pointer;
}
}

&__school_link {
margin: 0 @space;
}

&__post_count {
margin-left: auto;
}

&__info {
display: flex;
width: 100%;
padding: @doubleSpace;
}

&__info_icon {
margin-right: @doubleSpace;
&__details_icon {
font-size: 100px;
}

&__info_title {
display: block;
margin-bottom: @space;
}

&__info_description {
color: @subtextColor;
margin-bottom: @space;
}

&__filter {
margin-bottom: @space;
}
Expand Down
42 changes: 42 additions & 0 deletions src/less/blocks/tools/tools_details.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
This file is a part of libertysoil.org website
Copyright (C) 2016 Loki Education (Social Enterprise)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// The details window for items on tool pages.
.tools_details {
@space: 20px;
@doubleSpace: @space * 2;
@subtextColor: #888;

display: flex;
padding: 40px;
background-color: white;
border-bottom: 2px solid #EDEDED;

&__title {
display: block;
margin-bottom: @space;
}

&__description {
color: @subtextColor;
margin-bottom: @space;
}

&__left_col {
margin-right: @doubleSpace;
}
}
42 changes: 42 additions & 0 deletions src/less/blocks/tools/tools_item.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
This file is a part of libertysoil.org website
Copyright (C) 2016 Loki Education (Social Enterprise)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Visual block used in item lists on tool pages.
.tools_item {
@space: 20px;

display: flex;
margin-bottom: 15px;
padding: @space;
background-color: white;
border-bottom: 2px solid #EDEDED;

&-selected {
background: #FD9315;
color: white;
}

&-clickable {
&:hover {
cursor: pointer;
}
}

&__child-padded {
margin-left: @space;
}
}
22 changes: 8 additions & 14 deletions src/less/blocks/tools/tools_page.less
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,15 @@
}
}

// A universal element for items in collection (schools, posts, etc.)
&__item {
display: block;
margin-bottom: 15px;
padding: 20px;
background-color: white;
border-bottom: 2px solid #EDEDED;

&-selected {
background: #FD9315;
color: white;
}
// Column for lists of things (schools, users, posts, etc.)
&__list_col {
margin-right: @space;
max-width: 400px;
flex: 1 1;
}

&__paper:extend(&__item) {
width: 100%;
// Column for the selected item's details.
&__details_col {
flex: 1 1;
}
}
2 changes: 2 additions & 0 deletions src/less/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,7 @@
@import 'blocks/tools/tools_page';
@import 'blocks/tools/tools_menu_1';
@import 'blocks/tools/tools_menu_2';
@import 'blocks/tools/tools_item';
@import 'blocks/tools/tools_details';
@import 'blocks/tools/schools_tool';
@import 'blocks/v2/layout';
2 changes: 1 addition & 1 deletion src/pages/tools/my-posts-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class MyPostsToolPage extends React.Component {
<div>
<Helmet title="My posts tool on " />
{postsToDisplay.map((post, index) =>
<div className="tools_page__item" key={index}>
<div className="tools_item tools_item-clickable" key={index}>
<Link to={`/post/${post.get('id')}`}>{truncate(post.get('text'), { length: 70 })}</Link>
</div>
)}
Expand Down
Loading

0 comments on commit fb9deb2

Please sign in to comment.