diff --git a/src/components/Stories/TrendingStories.js b/src/components/Stories/TrendingStories.js
index 8166831..83b7924 100644
--- a/src/components/Stories/TrendingStories.js
+++ b/src/components/Stories/TrendingStories.js
@@ -56,7 +56,6 @@ class TrendingStories extends Component {
approvedStories: response.data.data,
approvedStoriesLength: response.data.data.length,
color: color,
- userSelectedStory: 'none',
loading: false
});
})
@@ -186,7 +185,6 @@ class TrendingStories extends Component {
approvedStories: response.data.data,
approvedStoriesLength: response.data.data.length,
color: color,
- userSelectedStory: 'none',
loading: false
});
})
@@ -217,7 +215,6 @@ class TrendingStories extends Component {
approvedStories: response.data.data,
approvedStoriesLength: response.data.data.length,
color: color,
- userSelectedStory: 'none',
loading: false
});
})
@@ -231,82 +228,85 @@ class TrendingStories extends Component {
//Displaying spinner untill API fetches the data
if (this.props.TrendingStoriesReducer.loading) {
return (
-
-
+
+
);
}
//Dislaying list of stories + search box
else {
return (
-
-
-
- {/* this is a working button in case we want a search button. I removed the css though
- but i can add it back pretty quickly if we wanted it.
-
- Search
-
-
-
*/}
-
- {this.getStoryDetails()}
-
-
-
-
+ {/* this is a working button in case we want a search button. I removed the css though
+ but i can add it back pretty quickly if we wanted it.
+
+ Search
+
+
+
*/}
+
+ {this.getStoryDetails()}
+
+
+
+
+
);
}
}
diff --git a/src/components/Stories/TrendingStoryDetail.js b/src/components/Stories/TrendingStoryDetail.js
index 9167bcc..207ee14 100644
--- a/src/components/Stories/TrendingStoryDetail.js
+++ b/src/components/Stories/TrendingStoryDetail.js
@@ -1,14 +1,5 @@
import React, { Component } from 'react';
-import {
- Media,
- Row,
- Badge,
- Alert,
- Card,
- Col,
- CardHeader,
- Button
-} from 'reactstrap';
+import { Row, Badge, Col, Button } from 'reactstrap';
import '../../styles/ViewStories.css';
import { connect } from 'react-redux';
import _ from 'lodash';
@@ -128,127 +119,77 @@ class TrendingStoryDetail extends Component {
}
render() {
- if (this.props.TrendingStoriesReducer.userSelectedStory === 'none') {
- return (
-
-
- Please select a story to view its details!
-
-
- );
- } else {
- return (
-
- {window.innerWidth <= mobileStyle && (
-
- Close
-
+ if (!this.props.TrendingStoriesReducer.userSelectedStory) return null;
+ return (
+
+
+
+ this.props.dispatch({
+ type: 'TRENDING_STORIES_CLEAR_SELECTION'
+ })
+ }
+ >
+ Back
+
+
+ {this.props.TrendingStoriesReducer.userSelectedStory.title}
+
+
+
+
+ this.handleUpVoteClick(
+ this.props.TrendingStoriesReducer.userSelectedStory
+ )
+ }
+ >
+
+ {this.props.TrendingStoriesReducer.userSelectedStory.upvote}
+
+
+
+ this.handleDownVoteClick(
+ this.props.TrendingStoriesReducer.userSelectedStory
+ )
+ }
+ >
+
+ {this.props.TrendingStoriesReducer.userSelectedStory.downvote}
+
+
+
+ By: {' '}
+
+ {this.props.TrendingStoriesReducer.userSelectedStory.author}
+
+
+
+
+ {this.contentHtml(
+ this.props.TrendingStoriesReducer.userSelectedStory.content
+ )}
+
+ {_.map(
+ this.props.TrendingStoriesReducer.userSelectedStory.tags,
+ tag => {
+ return (
+
+ {tag}
+
+
+ );
+ }
)}
-
-
-
-
- {this.props.TrendingStoriesReducer.userSelectedStory.title}
-
-
-
-
-
- Tags:
-
-
- {_.map(
- this.props.TrendingStoriesReducer.userSelectedStory.tags,
- tag => {
- return (
-
- {tag}
-
- );
- }
- )}
-
-
-
-
- {window.innerWidth > mobileStyle && (
-
-
- Description:
-
-
- {this.contentHtml(
- this.props.TrendingStoriesReducer.userSelectedStory
- .content
- )}
-
-
- )}
-
- {window.innerWidth <= mobileStyle && (
-
-
Description:
-
-
- {this.contentHtml(
- this.props.TrendingStoriesReducer.userSelectedStory
- .content
- )}
-
-
- )}
-
-
-
-
- {' '}
- Author:
-
-
-
- {this.props.TrendingStoriesReducer.userSelectedStory.author}
-
-
-
-
-
-
-
- this.handleUpVoteClick(
- this.props.TrendingStoriesReducer.userSelectedStory
- )
- }
- >
-
- {this.props.TrendingStoriesReducer.userSelectedStory.upvote}
-
-
-
-
- this.handleDownVoteClick(
- this.props.TrendingStoriesReducer.userSelectedStory
- )
- }
- >
-
- {
- this.props.TrendingStoriesReducer.userSelectedStory
- .downvote
- }
-
-
-
-
-
-
- );
- }
+
+
+ );
}
}
const mapDispatchToProps = dispatch => ({ dispatch });
diff --git a/src/components/Stories/index.js b/src/components/Stories/index.js
index 0ab8ac5..f1f43fb 100644
--- a/src/components/Stories/index.js
+++ b/src/components/Stories/index.js
@@ -1,8 +1,9 @@
import React, { Component } from 'react';
-import { Container, Card, Row, Col, CardBody, CardHeader } from 'reactstrap';
+import { Container } from 'reactstrap';
+import { connect } from 'react-redux';
import '../../styles/StoriesIndex.css';
-import ViewStories from './TrendingStoryDetail';
+import TrendingStoryDetail from './TrendingStoryDetail';
import TrendingStories from './TrendingStories';
import 'react-confirm-alert/src/react-confirm-alert.css';
@@ -10,35 +11,21 @@ const mobileStyle = 800;
class Stories extends Component {
render() {
+ const { selectedStory } = this.props;
+ console.log(this.props);
+ const shouldShowStories = selectedStory === 'none';
+ const trendingStoriesClassName = selectedStory ? 'd-none' : '';
return (
-
-
-
- Trending Stories
-
-
-
- {window.innerWidth <= mobileStyle && (
-
-
-
- )}
-
-
-
-
- {window.innerWidth > mobileStyle && (
-
-
-
- )}
-
-
-
+
+
);
}
}
-export default Stories;
+const mapStateToProps = store => ({
+ selectedStory: store.TrendingStoriesReducer.userSelectedStory
+});
+
+export default connect(mapStateToProps)(Stories);
diff --git a/src/reducers/TrendingStoriesReducer.js b/src/reducers/TrendingStoriesReducer.js
index 4abcc03..1ed3d76 100644
--- a/src/reducers/TrendingStoriesReducer.js
+++ b/src/reducers/TrendingStoriesReducer.js
@@ -3,13 +3,13 @@ const defaultState = {
approvedStoriesLength: 0,
color: [],
loading: true,
- userSelectedStory: 'none'
+ userSelectedStory: null
};
export default (state = defaultState, action) => {
switch (action.type) {
case 'APPROVED_STORIES_LIST':
- state = {
+ return {
...state,
approvedStories: action.approvedStories,
approvedStoriesLength: action.approvedStoriesLength,
@@ -17,9 +17,9 @@ export default (state = defaultState, action) => {
userSelectedStory: action.userSelectedStory,
loading: action.loading
};
- break;
+
case 'USER_SELECTED_STORY':
- state = {
+ return {
...state,
approvedStories: action.approvedStories,
approvedStoriesLength: action.approvedStoriesLength,
@@ -27,7 +27,12 @@ export default (state = defaultState, action) => {
userSelectedStory: action.userSelectedStory,
loading: action.loading
};
- break;
+
+ case 'TRENDING_STORIES_CLEAR_SELECTION':
+ return {
+ ...state,
+ userSelectedStory: null
+ };
default:
return state;
}
diff --git a/src/styles/StoriesIndex.css b/src/styles/StoriesIndex.css
index b804489..e3f8e12 100644
--- a/src/styles/StoriesIndex.css
+++ b/src/styles/StoriesIndex.css
@@ -1,26 +1,3 @@
.stories-page.container {
- padding-top: 80px;
- margin-left: 0px;
- margin-right: 0px;
- max-width: 100%;
-}
-
-.create-story {
- float: right;
-}
-.create-story.btn.btn-primary {
- color: rgba(13, 22, 38, 0.8) !important;
-}
-.trending-card {
- background-color: rgb(191, 217, 213) !important;
-}
-
-.trending-label {
- font-size: 20px;
- font-weight: 600;
- margin-top: 3px;
-}
-
-.trending-stories-overflow {
- overflow-x: scroll;
+ padding-top: 75px;
}