Changeset 5347491 for reactapp/src/Components
- Timestamp:
- 07/30/22 21:53:22 (2 years ago)
- Branches:
- main
- Children:
- f5d4792
- Parents:
- e958037
- Location:
- reactapp/src/Components
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
reactapp/src/Components/OpinionCard.style.js
re958037 r5347491 5 5 width: fit-content; 6 6 `; 7 8 export const OpinionReplyCard = styled.div` 9 background-color: lavender; 10 width: fit-content; 11 margin-top: 7px; 12 margin-bottom: 7px; 13 margin-left: ${(props) => props.indent}; 14 `; -
reactapp/src/Components/OpinionTree.js
re958037 r5347491 1 import { OpinionCard } from "./OpinionCard.style"; 1 import { OpinionCard, OpinionReplyCard } from "./OpinionCard.style"; 2 import { dateConverter } from "../Util/dateConverter"; 2 3 3 4 function OpinionTree({ professor }) { … … 5 6 var postCount; // za da ne go pokazuva ispod postot 6 7 7 function displayChildPosts(child ) {8 function displayChildPosts(child, parentPostAuthorUsername, replyIndent) { 8 9 if (child == null) return; 9 10 postCount = renderedOpinionIds.push(child.postId); 10 11 return ( 11 12 <div key={child.postId}> 12 <p> 13 <a href="#">{child.author.username}</a> реплицирал 14 </p> 15 <p>Содржина: {child.content}</p> 16 {child.children.map((childOfChild) => displayChildPosts(childOfChild))} 13 <OpinionReplyCard indent={replyIndent + "px"}> 14 <p> 15 <a href="#">{child.author.username}</a> му реплицирал на{" "} 16 {parentPostAuthorUsername} 17 </p> 18 <p>{child.content}</p> 19 <p> 20 {dateConverter(new Date(child.timePosted).toString().slice(4, -43))} 21 </p> 22 </OpinionReplyCard> 23 {child.children.map((childOfChild) => 24 displayChildPosts( 25 childOfChild, 26 child.author.username, 27 replyIndent + 30 28 ) 29 )} 17 30 </div> 18 31 ); … … 24 37 if (!renderedOpinionIds.includes(opinion.postId)) { 25 38 postCount = renderedOpinionIds.push(opinion.postId); 39 var replyIndent = 30; 26 40 return ( 27 41 <div key={opinion.postId}> … … 33 47 <p>{opinion.title}</p> 34 48 <p>{opinion.content}</p> 35 <p>{Date(opinion.timePosted)}</p> 49 <p> 50 {dateConverter( 51 new Date(opinion.timePosted).toString().slice(4, -43) 52 )} 53 </p> 36 54 </OpinionCard> 37 {opinion.children.map((child) => displayChildPosts(child))} 55 {opinion.children.map((child) => 56 displayChildPosts(child, opinion.author.username, replyIndent) 57 )} 38 58 </div> 39 59 );
Note:
See TracChangeset
for help on using the changeset viewer.