-
Notifications
You must be signed in to change notification settings - Fork 6
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
Unlike functionality #113
base: staging
Are you sure you want to change the base?
Unlike functionality #113
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ import CommentList from "../../components/comment/CommentList"; | |
import ArticleAPI from "../../lib/api/article"; | ||
import { Article } from "../../lib/types/articleType"; | ||
import ArticleTags from "../../components/article/ArticleTags"; | ||
import { ppid } from "process"; | ||
|
||
const ArticleContain = styled.div` | ||
width: 880px; | ||
|
@@ -71,12 +72,12 @@ const StyledEmoji = styled.div` | |
|
||
` | ||
const StyledEmoji2 = styled.div` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make heart emoji white not grey There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is white not grey Bryan |
||
background: red; | ||
border-radius: 22px; | ||
padding: 0.2em 0.4em 0.2em 0.4em; | ||
margin :0.5em; | ||
background: red; | ||
border-radius: 22px; | ||
padding: 0.5em; | ||
margin :0.5em; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The emoji should have a hover click effect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should there be a change i color on hover ? |
||
img { | ||
width: 16px; | ||
width: 20px; | ||
} | ||
` | ||
|
||
|
@@ -85,28 +86,38 @@ const Image = styled.img` | |
object-fit: cover; | ||
object-position: 0 40%; | ||
` | ||
|
||
const ArticlePage = (initialArticle) => { | ||
const ArticlePage = (id) => { | ||
const [mainArticles,setMainArticles] = React.useState([]) | ||
const [fetchedArticle,setFetchedArticle] =React.useState([]) | ||
const router = useRouter(); | ||
const { | ||
query: { pid }, | ||
} = router; | ||
|
||
const { | ||
data: fetchedArticle, | ||
} = useSWR( | ||
`${SERVER_BASE_URL}/articles/${encodeURIComponent(String(pid))}`, | ||
fetcher | ||
); | ||
|
||
const { article }: Article = fetchedArticle || initialArticle; | ||
|
||
const { data: fetchedArticles } = useSWR( | ||
`${SERVER_BASE_URL}/articles?author=${article.author.username}`, | ||
fetcher | ||
); | ||
const getArticles = async (currentUser) => { | ||
if (id != null) { | ||
const { data: fetchedArticle } = await ArticleAPI.get(id.id, currentUser); | ||
setPreview({ ...article, favorited: fetchedArticle.article.favorited,bookmarked: false, bookmarkCount: null | ||
}) | ||
setMainArticles(fetchedArticle) | ||
} | ||
} | ||
|
||
React.useEffect(() => { | ||
let user = JSON.parse(localStorage.getItem("user")) | ||
getArticles(user) | ||
let { article }: any = mainArticles; | ||
if(article != null){ | ||
const { data: fetchedArticles } = useSWR( | ||
`${SERVER_BASE_URL}/articles?author=${article.author.username}`, | ||
fetcher | ||
); | ||
setFetchedArticle(fetchedArticles) | ||
} | ||
}, [id]); | ||
|
||
let { articles } = fetchedArticles || []; | ||
let { article }: any = mainArticles; | ||
let { articles } : any = fetchedArticle || []; | ||
|
||
articles = articles ? articles.slice(0, Math.min(articles.length, 5)) : []; | ||
|
||
|
@@ -134,15 +145,15 @@ const ArticlePage = (initialArticle) => { | |
: preview.favoritesCount + 1, | ||
}); | ||
} else { | ||
await axios.post( | ||
await axios.post( | ||
`${SERVER_BASE_URL}/articles/${slug}/favorite`, | ||
{}, | ||
{ | ||
headers: { | ||
Authorization: `Token ${currentUser?.token}`, | ||
}, | ||
} | ||
); | ||
) | ||
} | ||
setPreview({ | ||
...preview, | ||
|
@@ -198,11 +209,10 @@ const ArticlePage = (initialArticle) => { | |
}); | ||
} | ||
}; | ||
|
||
if(article != null){ | ||
const markup = { | ||
__html: marked(article.body, { sanitize: true }), | ||
}; | ||
|
||
return ( | ||
<div className="article-page"> | ||
|
||
|
@@ -234,11 +244,14 @@ const ArticlePage = (initialArticle) => { | |
</StickyRight> | ||
</div> | ||
); | ||
}; | ||
}else{ | ||
return (<div></div>) | ||
} | ||
} | ||
|
||
ArticlePage.getInitialProps = async ({ query: { pid } }) => { | ||
const { data } = await ArticleAPI.get(pid); | ||
return data; | ||
let id = pid | ||
return { id }; | ||
}; | ||
|
||
export default ArticlePage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spacing for the right side is way off. It looks like the image container has moved to the left side of the like bar when it should be above the title
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay will check this out! I am not seeing this spacing in my laptop actually