Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add introductory panel and remove pop up card #692

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions rails/app/assets/images/number1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions rails/app/assets/images/number2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions rails/app/assets/stylesheets/components/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
@import 'balloon';
@import 'introPopup';
@import 'navigation';
@import 'button';
@import 'introductoryPanel';
9 changes: 9 additions & 0 deletions rails/app/assets/stylesheets/components/button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.explore-button{
background-color: $green;
border-radius: 10px;
color: $off-white;
cursor: pointer;
font-weight: bold;
margin: 20px auto;
padding: 15px 40px;
}
13 changes: 10 additions & 3 deletions rails/app/assets/stylesheets/components/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ $el-shadow: 0 1px 4px $lighter-gray;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}

.tab {
Expand Down Expand Up @@ -99,13 +98,17 @@ $el-shadow: 0 1px 4px $lighter-gray;
.card--nav {
display: flex;
flex-direction: column;
justify-content: space-around;
font-family: sans-serif;
margin-bottom: 0.75rem;

&-filter, &-sort {
&-filter, &-intro, &-sort {
font-family: 'OpenSansCondensed';
color: $default-text;
margin: 0.75rem 0;
}

&-usage {
margin-bottom: 0.75rem;
}

.categoryFilter .storiesSort {
Expand Down Expand Up @@ -169,6 +172,10 @@ $el-shadow: 0 1px 4px $lighter-gray;
}
}
}

.terrastory-info {
height: 100%;
}
}

// Responsive patches
Expand Down
23 changes: 23 additions & 0 deletions rails/app/assets/stylesheets/components/introductoryPanel.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
img {
width: 32px;
}

.first-info {
margin-bottom: 10px;
}

.first-img {
display: flex;
float: left;
height: 60px;
margin-right: 10px;
width: 32px;
}

.second-img {
display: flex;
float: left;
height: 36px;
margin-right: 10px;
width: 32px;
}
8 changes: 5 additions & 3 deletions rails/app/javascript/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import Map from "./Map";
import Card from "./Card";
import IntroPopup from "./IntroPopup";
import FILTER_CATEGORIES from "../constants/FilterConstants";
import bbox from "@turf/bbox";

Expand Down Expand Up @@ -39,7 +38,9 @@ class App extends Component {
ne_boundary_lat: PropTypes.string,
ne_boundary_long: PropTypes.string,
pitch: PropTypes.number,
bearing: PropTypes.string
bearing: PropTypes.string,
number_one_path: PropTypes.string,
number_two_path: PropTypes.string
};

componentDidMount() {
Expand Down Expand Up @@ -314,8 +315,9 @@ class App extends Component {
handleFilterCategoryChange={this.handleFilterCategoryChange}
handleFilterItemChange={this.handleFilterItemChange}
itemOptions={this.state.itemOptions}
numberOnePath={this.props.number_one_path}
numberTwoPath={this.props.number_two_path}
/>
<IntroPopup />
</div>
);
}
Expand Down
20 changes: 20 additions & 0 deletions rails/app/javascript/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import PropTypes from 'prop-types';

const Button = props => {
const { buttonText, handleClick, buttonType } = props;

return(
<button type="button" className={buttonType} onClick={handleClick}>
{buttonText}
</button>
)
}

Button.propTypes = {
buttonText: PropTypes.string.isRequired,
handleClick: PropTypes.func.isRequired,
buttonType: PropTypes.string.isRequired
};

export default Button;
7 changes: 5 additions & 2 deletions rails/app/javascript/components/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import StoryList from "./StoryList";

class Card extends Component {

constructor(props) {
super(props);
this.state = {
Expand All @@ -26,7 +25,9 @@ class Card extends Component {
filterItem: PropTypes.string,
handleFilterCategoryChange: PropTypes.func,
handleFilterItemChange: PropTypes.func,
itemOptions: PropTypes.array
itemOptions: PropTypes.array,
numberOnePath: PropTypes.string,
numberTwoPath: PropTypes.string
};

static defaultProps = {
Expand Down Expand Up @@ -92,6 +93,8 @@ class Card extends Component {
handleFilterCategoryChange={this.props.handleFilterCategoryChange}
handleFilterItemChange={this.props.handleFilterItemChange}
itemOptions={this.props.itemOptions}
numberOnePath={this.props.numberOnePath}
numberTwoPath={this.props.numberTwoPath}
/>

<div className="card--tasks">
Expand Down
36 changes: 36 additions & 0 deletions rails/app/javascript/components/IntroductoryPanel.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from "react";
import PropTypes from 'prop-types';

const IntroductoryPanel = (props) => {
const { numberOnePath, numberTwoPath } = props;

return (
<React.Fragment>
<span className="card--nav-intro">{I18n.t("intro.question")}</span>
<p>{I18n.t("intro.explanation")}</p>
<span className="card--nav-intro">{I18n.t("usage.question")}</span>
<div className="card--nav-usage">
<div className="first-info">
<div className="first-img">
<img src={numberOnePath} alt="First" />
</div>
<p>{I18n.t("usage.category_explanation")}</p>
</div>
<div>
<div className="second-img">
<img src={numberTwoPath} alt="Second" />
</div>
<p>{I18n.t("usage.option_explanation")}</p>
</div>
</div>
<p>{I18n.t("usage.explore_explanation")}</p>
</React.Fragment>
)
}

IntroductoryPanel.propTypes = {
numberOnePath: PropTypes.string,
numberTwoPath: PropTypes.string
};

export default IntroductoryPanel;
65 changes: 52 additions & 13 deletions rails/app/javascript/components/StoryList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ import Story from "./Story";
import Filter from "./Filter";
import Sort from "./Sort";
import ReactList from 'react-list';
import IntroductoryPanel from "./IntroductoryPanel";
import Button from "./Button";

class StoryList extends Component {
constructor() {
super();
this.state = {
showStories: false
};
}

static propTypes = {
stories: PropTypes.array,
handleStoriesChanged: PropTypes.func,
Expand All @@ -19,15 +28,26 @@ class StoryList extends Component {
filterItem: PropTypes.string,
handleFilterCategoryChange: PropTypes.func,
handleFilterItemChange: PropTypes.func,
itemOptions: PropTypes.array
itemOptions: PropTypes.array,
numberOnePath: PropTypes.string,
numberTwoPath: PropTypes.string
};

handleClickExplore = () => {
this.setState(prevState => ({
showStories: !prevState.showStories
}));
}

handleClickStory = (story, index) => {
this.props.onStoryClick(story);
}

handleFilterItemChange = (item) => {
this.props.handleFilterItemChange(item);
this.setState(() => ({
showStories: true
}));
this._list.scrollTo(0);
}

Expand Down Expand Up @@ -73,19 +93,38 @@ class StoryList extends Component {
handleFilterItemChange={this.handleFilterItemChange}
itemOptions={this.props.itemOptions}
/>
<Sort
stories={this.props.stories}
handleStoriesChanged={this.props.handleStoriesChanged}
/>
</div>
<div className="stories">
<ReactList
ref={list => this._list = list }
itemRenderer={this.renderStory}
length={this.props.stories ? this.props.stories.length : 0}
type='variable'
/>
</div>
{!this.state.showStories && window.innerWidth > 600
?
<div className="card--nav terrastory-info">
<IntroductoryPanel
numberOnePath={this.props.numberOnePath}
numberTwoPath={this.props.numberTwoPath}
/>
<Button
buttonType='explore-button'
handleClick={this.handleClickExplore}
buttonText='EXPLORE'
/>
</div>
:
<React.Fragment>
<div className="card--nav">
<Sort
stories={this.props.stories}
handleStoriesChanged={this.props.handleStoriesChanged}
/>
</div>
<div className="stories">
<ReactList
ref={list => this._list = list }
itemRenderer={this.renderStory}
length={this.props.stories ? this.props.stories.length : 0}
type='variable'
/>
</div>
</React.Fragment>
}
</React.Fragment>
);
}
Expand Down
2 changes: 2 additions & 0 deletions rails/app/views/home/_home.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ json.zoom @theme.zoom.to_f
json.pitch @theme.pitch.to_f
json.bearing @theme.bearing
json.marker_image_url image_url("marker1.png")
json.number_one_path image_path("number1.svg")
json.number_two_path image_path("number2.svg")
Loading