Skip to content

Commit

Permalink
Featured projects: welcome banner (#5650)
Browse files Browse the repository at this point in the history
* Projects welcome banner
Add a featured projects banner to the projects page.
Add some projects page styles.
Add projects page text to the English locale file.

* Remove constraint from admin interface. Remove line for prototyping now the API supports multiple

Co-authored-by: Sarah Allen <[email protected]>
  • Loading branch information
eatyourgreens and Sarah Allen authored Mar 18, 2020
1 parent 7221e48 commit f483263
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 23 deletions.
8 changes: 8 additions & 0 deletions app/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export default {
studyInfo: 'I do not want to take part in this messaging [study](+tab+https://docs.google.com/document/d/1gLyN6Dgff8dOCOC88f47OD6TtFrfSJltsLgJMKkYMso/preview).'
}
},
projects: {
welcome: {
heading: "Welcome! We're so glad you're here",
thanks: "Thank you for your interest in helping real research. Here we've gathered a few projects we could really use your help on right now. For more options just scroll down to browse all of our active projects.",
talk: "Make sure to also check out [Talk](/talk) where you can chat to other like-minded volunteers.",
scrollDown: "Scroll down for even more"
}
},
project: {
language: 'Language',
loading: 'Loading project',
Expand Down
26 changes: 3 additions & 23 deletions app/pages/admin/project-status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ class ProjectStatus extends Component {
this.state = {
dialogIsOpen: false,
error: null,
featuredProject: null,
project: null,
usedWorkflowLevels: [],
workflows: []
};
}

componentDidMount() {
this.getFeaturedProject();
this.getProjectAndWorkflows();
}

Expand All @@ -64,14 +62,6 @@ class ProjectStatus extends Component {
.catch(error => this.setState({ error }));
}

getFeaturedProject() {
return apiClient.type('projects')
.get({ featured: true, cards: true })
.then(([featuredProject]) => {
this.setState({ featuredProject });
});
}

getProject() {
const { owner, name } = this.props.params;
const slug = `${owner}/${name}`;
Expand Down Expand Up @@ -134,19 +124,9 @@ class ProjectStatus extends Component {
}

handleFeaturedProjectChange({ target }) {
const { featuredProject, project } = this.state;
project.update({ featured: target.checked });
if (featuredProject) {
return featuredProject.update({ featured: false }).save()
.then(() => project.save())
.then(newFeaturedProject => this.setState({
featuredProject: newFeaturedProject
}))
.catch(error => this.setState({ error }));
} else {
return project.save()
.catch(error => this.setState({ error }));
}
const { project } = this.state;
return project.update({ featured: target.checked }).save()
.catch(error => this.setState({ error }));
}

handleToggle(event, workflow) {
Expand Down
2 changes: 2 additions & 0 deletions app/pages/projects/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Translate from 'react-translate-component';
import { browserHistory } from 'react-router';
import { Helmet } from 'react-helmet';

import ProjectsWelcome from './projects-welcome'
import StatusLink from './status-link';

counterpart.registerTranslations('en', {
Expand Down Expand Up @@ -72,6 +73,7 @@ class ProjectsPage extends Component {
</div>
</section>
<section className="resources-container">
<ProjectsWelcome />
{children}
</section>
</div>
Expand Down
40 changes: 40 additions & 0 deletions app/pages/projects/projects-welcome.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import counterpart from 'counterpart';
import { Markdown } from 'markdownz';
import apiClient from 'panoptes-client/lib/api-client';
import React, { Component } from 'react';
import Translate from 'react-translate-component';
import ProjectCardList from './project-card-list';

class ProjectsWelcome extends Component {
constructor() {
super();
this.state = {
featuredProjects: []
};
}

componentDidMount() {
this.getFeaturedProjects();
}

getFeaturedProjects() {
const query = { featured: true, launch_approved: true, cards: true };
return apiClient.type('projects').get(query)
.then((featuredProjects) => {
this.setState({ featuredProjects });
});
}
render() {
return (
<div className="resources-container welcome-banner">
<Translate content="projects.welcome.heading" component="h2" />
<Translate content="projects.welcome.thanks" component="p" />
<Markdown>{counterpart('projects.welcome.talk')}</Markdown>
<ProjectCardList projects={this.state.featuredProjects} />
<p><Translate content="projects.welcome.scrollDown" component="em" /></p>
</div>
);
}
}

export default ProjectsWelcome;
1 change: 1 addition & 0 deletions css/main.styl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
@require './admin-page'
@require './highlights-page'
@require './donate-page'
@require './projects-page'

// Project
@require './project-page'
Expand Down
19 changes: 19 additions & 0 deletions css/projects-page.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

.resources-container .welcome-banner
background: #fff
padding: 2em 4em

h2
font-size: 1.1em
text-transform: uppercase

p
margin: 1.4em auto 0
text-align: center
max-width: 50em

em
color: COPY
font-style: normal
font-weight: normal
text-transform: uppercase

0 comments on commit f483263

Please sign in to comment.