Add saved icon
This commit is contained in:
parent
3818c7190e
commit
20ef9b06a5
7 changed files with 35 additions and 11 deletions
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import Cookies from 'js-cookie';
|
import Cookies from 'js-cookie';
|
||||||
|
|
||||||
import { unSelectPost, markPostRead } from '../actions/posts.js';
|
import { unSelectPost, markPostRead, toggleSaved } from '../actions/posts.js';
|
||||||
import {
|
import {
|
||||||
CATEGORY_TYPE,
|
CATEGORY_TYPE,
|
||||||
RULE_TYPE,
|
RULE_TYPE,
|
||||||
|
|
@ -51,9 +51,11 @@ class PostModal extends React.Component {
|
||||||
const token = Cookies.get('csrftoken');
|
const token = Cookies.get('csrftoken');
|
||||||
const publicationDate = formatDatetime(post.publicationDate);
|
const publicationDate = formatDatetime(post.publicationDate);
|
||||||
const titleClassName = post.read ? 'post__title post__title--read' : 'post__title';
|
const titleClassName = post.read ? 'post__title post__title--read' : 'post__title';
|
||||||
const readButtonDisabled = post.read || this.props.isMarkingPost;
|
const readButtonDisabled = post.read || this.props.isUpdating;
|
||||||
|
const savedIconClass = post.saved ? 'saved-icon saved-icon--saved' : 'saved-icon';
|
||||||
|
|
||||||
let ruleUrl = '';
|
let ruleUrl = '';
|
||||||
|
|
||||||
switch (this.props.rule.type) {
|
switch (this.props.rule.type) {
|
||||||
case SUBREDDIT:
|
case SUBREDDIT:
|
||||||
ruleUrl = `${this.props.subredditUrl}/${this.props.rule.id}/`;
|
ruleUrl = `${this.props.subredditUrl}/${this.props.rule.id}/`;
|
||||||
|
|
@ -114,6 +116,10 @@ class PostModal extends React.Component {
|
||||||
>
|
>
|
||||||
<i className="fas fa-external-link-alt" />
|
<i className="fas fa-external-link-alt" />
|
||||||
</a>
|
</a>
|
||||||
|
<span
|
||||||
|
className={savedIconClass}
|
||||||
|
onClick={() => this.props.toggleSaved(post, token)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -128,8 +134,11 @@ class PostModal extends React.Component {
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
unSelectPost: () => dispatch(unSelectPost()),
|
unSelectPost: () => dispatch(unSelectPost()),
|
||||||
markPostRead: (post, token) => dispatch(markPostRead(post, token)),
|
markPostRead: (post, token) => dispatch(markPostRead(post, token)),
|
||||||
|
toggleSaved: (post, token) => dispatch(toggleSaved(post, token)),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapStateToProps = state => ({ isMarkingPost: state.posts.isMarking });
|
const mapStateToProps = state => ({
|
||||||
|
isUpdating: state.posts.isUpdating,
|
||||||
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(PostModal);
|
export default connect(mapStateToProps, mapDispatchToProps)(PostModal);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import { MARK_SECTION_READ } from '../actions/selected.js';
|
||||||
|
|
||||||
const defaultState = { items: {}, isFetching: false, isUpdating: false };
|
const defaultState = { items: {}, isFetching: false, isUpdating: false };
|
||||||
|
|
||||||
// TODO isMarking -> isUpdating
|
|
||||||
export const posts = (state = { ...defaultState }, action) => {
|
export const posts = (state = { ...defaultState }, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case REQUEST_POSTS:
|
case REQUEST_POSTS:
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__link {
|
|
||||||
& i {
|
|
||||||
padding: 0 0 0 7px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__date {
|
&__date {
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +97,6 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
gap: 5px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,4 @@
|
||||||
@import './small/index';
|
@import './small/index';
|
||||||
@import './select/index';
|
@import './select/index';
|
||||||
@import './checkbox/index';
|
@import './checkbox/index';
|
||||||
|
@import './saved-icon/index';
|
||||||
|
|
|
||||||
15
src/newsreader/scss/elements/saved-icon/_saved-icon.scss
Normal file
15
src/newsreader/scss/elements/saved-icon/_saved-icon.scss
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
.saved-icon {
|
||||||
|
@include font-awesome;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: "\f0c7";
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--saved {
|
||||||
|
color: var(--confirm-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/newsreader/scss/elements/saved-icon/index.scss
Normal file
1
src/newsreader/scss/elements/saved-icon/index.scss
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
@import './saved-icon';
|
||||||
|
|
@ -9,3 +9,8 @@
|
||||||
@mixin button-padding {
|
@mixin button-padding {
|
||||||
padding: 5px 20px;
|
padding: 5px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mixin font-awesome {
|
||||||
|
font-family: "Font Awesome 5 Free";
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue