From 73743667263e1940e9cbc82bfef3e0ee3ca38a79 Mon Sep 17 00:00:00 2001 From: Jesper Wrang Date: Sun, 14 Jan 2018 11:57:42 +0100 Subject: [PATCH] Translated all lodash templates to react --- src/js/components/Comment.js | 49 +++++++++++++----------- src/js/components/CommentSection.js | 9 +++++ src/js/components/Menu.js | 32 ++++++++-------- src/js/components/SubredditPagination.js | 34 +++++++++------- src/js/components/SubredditSort.js | 35 ++++++++++------- src/js/components/ThreadInfo.js | 13 ++++--- 6 files changed, 101 insertions(+), 71 deletions(-) diff --git a/src/js/components/Comment.js b/src/js/components/Comment.js index 8dbf16a..de15c55 100644 --- a/src/js/components/Comment.js +++ b/src/js/components/Comment.js @@ -1,25 +1,28 @@ -// <% -// var isRemoved = _.has(comment,"removed"); -// var isDeleted = _.has(comment,"deleted"); +import React from 'react' +import { prettyScore, prettyDate, parse } from 'utils' -// var commentCss = "comment comment-" + (isRemoved ? "removed" : (isDeleted ? "deleted" : (comment.depth % 2 == 0 ? "even" : "odd"))); -// %> - -//
-//
-// [–] -// -// <%= comment.author+(isDeleted ? " (deleted by user)" : "") %> -// -// <%= Format.prettyScore(comment.score) %> point<%= ((comment.score == 1) ? "": "s") %> -// <%= Format.prettyDate(comment.created_utc) %> -//
-//
-// <%= (comment.body === "[removed]" && isRemoved ? "

[likely removed by automoderator]

" : Format.parse(comment.body)) %> -//
-// -//
+export default (props) => { + const commentCss = 'comment comment-' + (props.removed ? 'removed' : (props.deleted ? 'deleted' : (props.depth % 2 == 0 ? 'even' : 'odd'))); + const innerHTML = (props.body === '[removed]' && props.removed) ? '

[removed too quickly to be archived]

' : parse(comment.body) + const permalink = `/r/${props.subreddit}/comments/${props.threadID}/_/${props.id}/` + return ( +
+
+ [–] + + {props.author} + {props.deleted && ' (deleted by user)'} + + {prettyScore(props.score)} point{(comment.score !== 1) && 's'} + {prettyDate(props.created_utc)} +
+
+
+ permalink + reddit + ceddit +
+
+ ) +} \ No newline at end of file diff --git a/src/js/components/CommentSection.js b/src/js/components/CommentSection.js index e69de29..0fa0d9d 100644 --- a/src/js/components/CommentSection.js +++ b/src/js/components/CommentSection.js @@ -0,0 +1,9 @@ +import React from 'react' + +export default (props) => { + return ( +
+ {props.children} +
+ ) +} \ No newline at end of file diff --git a/src/js/components/Menu.js b/src/js/components/Menu.js index 7008003..d202c14 100644 --- a/src/js/components/Menu.js +++ b/src/js/components/Menu.js @@ -2,21 +2,19 @@ import React from 'react' import {Link} from 'react-router-dom' import StatusBox from 'components/StatusBox' -export default class Menu extends React.Component { - render () { - return ( -
- - -
- ) - } +export default (props) => { + return ( +
+ + +
+ ) } \ No newline at end of file diff --git a/src/js/components/SubredditPagination.js b/src/js/components/SubredditPagination.js index 85ec6dd..76c734b 100644 --- a/src/js/components/SubredditPagination.js +++ b/src/js/components/SubredditPagination.js @@ -1,14 +1,22 @@ -// {/* */} \ No newline at end of file +export default (props) => { + let pageination = <> + + for(var i = start; i <= end; i++) { + if(currentPage === i) { + pageination += {i} + } else { + pageination += {i} + } + } + return ( + + ) +} \ No newline at end of file diff --git a/src/js/components/SubredditSort.js b/src/js/components/SubredditSort.js index 79835b5..90830a2 100644 --- a/src/js/components/SubredditSort.js +++ b/src/js/components/SubredditSort.js @@ -1,13 +1,22 @@ -// {/*
-// top post of /r/<%= subreddit %> from: -// -//
*/} \ No newline at end of file +import React from 'react' + +export default (props) => { + const isSelected = time => props.time == time + + return ( +
+ top post of /r/{subreddit} from: + {/* + + + + + + + + + +
+ ) +} \ No newline at end of file diff --git a/src/js/components/ThreadInfo.js b/src/js/components/ThreadInfo.js index f550f3f..751b2e5 100644 --- a/src/js/components/ThreadInfo.js +++ b/src/js/components/ThreadInfo.js @@ -1,9 +1,12 @@ import React from 'react' export default (props) => { -{/*
- removed comments: <%= removedComments %>/<%= totalComments %> (<%= (100 * removedComments / totalComments).toFixed(1) %>%) -
-
sorted by: top
*/} - + return ( + <> +
+ removed comments: {props.removedComments}/${props.totalComments} ({(100 * removedComments / totalComments).toFixed(1)}%) +
+
sorted by: top
+ + ) } \ No newline at end of file