Skip to content

Commit 8fe124d

Browse files
committed
Project Page, Like, and Project fields refactored
* dashboard updated * contact modal * updated Like Button * like button in card and project page * home orders project by likes
1 parent 504e0cf commit 8fe124d

File tree

36 files changed

+629
-213
lines changed

36 files changed

+629
-213
lines changed

src/components/app/actions/project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const getProject = createAction('GET_PROJECT', async (pid) => {
2323
return normalize(response, schema.project);
2424
});
2525

26-
export const updateProject = createAction('UPDATE_PROJECT', async ({ values }) => {
26+
export const updateProject = createAction('UPDATE_PROJECT', async (values) => {
2727
let imageURLs = [ ...values.images ];
2828
if (values.images.length > 0 && values.images[0] instanceof File) {
2929
await storage.deleteProjectImages(values.id);

src/components/app/selectors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
33

44
const getTags = state => state.data.tags;
55

6-
const getProjects = state => orderBy(state.data.projects, [ 'title' ], [ 'asc' ]);
6+
const getProjects = state => orderBy(state.data.projects, [ 'name' ], [ 'asc' ]);
77

88
export default createSelector(
99
[ getTags, getProjects ],

src/components/home/Home.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import styled from 'styled-components';
33

44
import { Row, Col } from 'reactstrap';
5+
import { orderBy } from 'lodash';
56
import Banner from './components/banner';
67
import Card from '../shared/card';
78
import useProjects from '../../hooks/use-projects';
@@ -15,7 +16,8 @@ const SectionTitle = styled.h3`
1516
`;
1617

1718
const Home = ({ history }) => {
18-
const projects = useProjects();
19+
let projects = useProjects();
20+
projects = orderBy(projects, p => Object.keys(p.likes).length, [ 'desc' ]);
1921
return (
2022
<div>
2123
<Header>
Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,74 @@
11
import React, { useState, useEffect } from 'react';
2+
import styled from 'styled-components';
23
import { some, get, isNil } from 'lodash';
34
import { withRouter } from 'react-router-dom';
45

5-
import { Row } from 'reactstrap';
6-
76
import Dashboard from './components/dashboard';
8-
import BannerContent from './components/banner-content';
9-
import ProjectInfoContent from './components/project-info-content';
10-
import SocialContentSection from './components/social-content-section';
117
import EditProjectBanner from './components/edit-project-banner';
12-
8+
import Info from './components/info';
9+
import Need from './components/need';
10+
import About from './components/about';
11+
import Image from './components/image';
12+
import Likes from './components/likes';
13+
import ContactModal from '../shared/contact-modal';
1314
import useProject from '../../hooks/use-project';
1415
import useUser from '../../hooks/use-user';
16+
import useModal from '../../hooks/use-modal';
17+
18+
const Container = styled.section`
19+
display: grid;
20+
grid-template-columns: 20% 1fr 20%;
21+
grid-template-rows: auto auto auto auto;
22+
grid-template-areas: 'banner banner banner' 'image info likes' '. need .' '. about .';
23+
`;
24+
25+
const CONTACT_MODAL_ID = 'CONTACT_MODAL_ID';
1526

1627
const ProjectPage = ({ location }) => {
1728
const [ showDashboard, setShowDashboard ] = useState(false);
1829
const [ editable, setEditable ] = useState(false);
1930

2031
const pid = get(location, 'state.id', null);
21-
const { project } = useProject(pid);
32+
const { project, tags } = useProject(pid);
2233
const { user } = useUser();
34+
const { closeModal, openModal, isModalOpen } = useModal();
2335

2436
useEffect(() => {
2537
if (project && user) {
26-
const _editable = some(project.team, id => id === user.id)
27-
|| some(project.admin, id => id === user.id)
28-
|| project.owner === user.id;
38+
const _editable = some(project.admin, id => id === user.id) || project.owner === user.id;
2939
setEditable(_editable);
3040
}
3141
}, [ project, user ]);
3242

33-
const toggleDashboard = toggle => () => setShowDashboard(toggle);
34-
3543
if (isNil(project)) {
3644
return <div>Loading...</div>;
3745
}
3846
if (showDashboard) {
39-
return <Dashboard pid={pid} onClose={toggleDashboard(false)} />;
47+
return <Dashboard pid={pid} onClose={() => setShowDashboard(false)} />;
4048
}
4149
return (
42-
<section>
43-
{editable ? <EditProjectBanner onEdit={toggleDashboard(true)} /> : <div />}
44-
<Row>
45-
<BannerContent name={project.name} images={project.images} />
46-
<ProjectInfoContent project={project} />
47-
</Row>
48-
<SocialContentSection
49-
isOwner={editable}
50-
projectId={pid}
51-
ourstory={project.about ? project.about : ''}
52-
selected={location.hash}
50+
<Container>
51+
{editable && <EditProjectBanner onEdit={() => setShowDashboard(true)} />}
52+
<Image images={project.images} />
53+
<Info name={project.name} description={project.description} tags={tags} />
54+
<Likes pid={pid} />
55+
<Need roles={project.roles} onContact={openModal(CONTACT_MODAL_ID)} />
56+
<About about={project.about} images={project.images} links={project.links} />
57+
<ContactModal
58+
open={isModalOpen(CONTACT_MODAL_ID)}
59+
toggle={closeModal}
60+
buttonLabel={`Contact ${ project.name }`}
61+
modalBody={<a href={`mailto:${ project.contact }`}>{project.contact}</a>}
5362
/>
54-
</section>
63+
</Container>
5564
);
5665
};
5766

5867
export default withRouter(ProjectPage);
68+
69+
/* <SocialContentSection
70+
isOwner={editable}
71+
projectId={pid}
72+
ourstory={project.about ? project.about : ''}
73+
selected={location.hash}
74+
/> */
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import { isEmpty } from 'lodash';
4+
import Carousel from '../carousel';
5+
import Button from '../../../shared/button';
6+
7+
const Container = styled.div`
8+
padding: 50px 0px;
9+
grid-area: about;
10+
11+
h5 {
12+
margin-bottom: 20px;
13+
}
14+
15+
p {
16+
margin-top: 20px;
17+
font-size: 14pt;
18+
color: gray;
19+
}
20+
`;
21+
22+
const About = ({ about, images, links }) => {
23+
if (isEmpty(about) && images.length === 0) {
24+
return null;
25+
}
26+
return (
27+
<Container>
28+
<h5>More about us:</h5>
29+
{images.length > 0 && <Carousel items={images} />}
30+
<p>{about}</p>
31+
<div>
32+
{links.map(link => (
33+
<a href={link.url}>
34+
<Button variant="link">{link.name}</Button>
35+
</a>
36+
))}
37+
</div>
38+
</Container>
39+
);
40+
};
41+
export default About;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './About';

src/components/project-page/components/banner-content/BannerContent.jsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/components/project-page/components/banner-content/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/project-page/components/carousel/Carousel.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import React, { Component } from 'react';
22
import { Carousel as RSCarousel, CarouselItem, CarouselIndicators } from 'reactstrap';
33

4-
const imageStyle = { height: 'auto', maxHeight: '500px' };
4+
const imageStyle = {
5+
height: '320px',
6+
objectFit: 'contain',
7+
width: '100%',
8+
paddingLeft: '15%',
9+
paddingRight: '15%',
10+
};
511

612
class Carousel extends Component {
713
state = { activeIndex: 0 };

src/components/project-page/components/dashboard/Dashboard.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DescriptionForm from './components/description-form';
77
import TagsForm from './components/tags-form';
88
import TeamForm from './components/team-form';
99
import LinksForm from './components/links-form';
10+
import RolesForm from './components/roles-form';
1011
import SettingsForm from './components/settings-form';
1112
import Header from './components/header';
1213
import Sidebar from './components/sidebar';
@@ -19,7 +20,7 @@ const Container = styled.div`
1920
.dashboard {
2021
display: grid;
2122
grid-template-columns: 0.3fr 1fr;
22-
grid-template-rows: 1fr 45px;
23+
grid-template-rows: 1fr 50px;
2324
grid-template-areas:
2425
'menu forms'
2526
'menu toolbar';
@@ -82,6 +83,9 @@ const Dashboard = ({ pid, onClose }) => {
8283
case 'links':
8384
setCurrentForm(<LinksForm />);
8485
break;
86+
case 'roles':
87+
setCurrentForm(<RolesForm />);
88+
break;
8589
case 'settings':
8690
setCurrentForm(<SettingsForm pid={pid} />);
8791
break;
@@ -92,7 +96,7 @@ const Dashboard = ({ pid, onClose }) => {
9296
};
9397

9498
const handleSubmit = (values) => {
95-
updateProject({ values });
99+
updateProject(values);
96100
setTimeout(onClose, 3000);
97101
};
98102

@@ -103,7 +107,7 @@ const Dashboard = ({ pid, onClose }) => {
103107
enableReinitialize
104108
initialValues={{ ...project }}
105109
onSubmit={handleSubmit}
106-
render={() => (
110+
render={({ values }) => (
107111
<Form>
108112
<section className="dashboard">
109113
<Sidebar onSelectCategory={handleSidebar} />

0 commit comments

Comments
 (0)