Changeset 2998dc4 for reactapp/src
- Timestamp:
- 07/30/22 15:39:04 (2 years ago)
- Branches:
- main
- Children:
- e958037
- Parents:
- 3a44163
- Location:
- reactapp/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
reactapp/src/App.css
r3a44163 r2998dc4 2 2 text-align: center; 3 3 } 4 5 .App-logo {6 height: 40vmin;7 pointer-events: none;8 }9 10 @media (prefers-reduced-motion: no-preference) {11 .App-logo {12 animation: App-logo-spin infinite 20s linear;13 }14 }15 16 .App-header {17 background-color: #282c34;18 min-height: 100vh;19 display: flex;20 flex-direction: column;21 align-items: center;22 justify-content: center;23 font-size: calc(10px + 2vmin);24 color: white;25 }26 27 .App-link {28 color: #61dafb;29 }30 31 @keyframes App-logo-spin {32 from {33 transform: rotate(0deg);34 }35 to {36 transform: rotate(360deg);37 }38 } -
reactapp/src/App.js
r3a44163 r2998dc4 4 4 return ( 5 5 <div> 6 <h1>Main App Page</h1> 7 <nav 8 style={{ 9 borderBottom: "solid 1px", 10 paddingBottom: "1rem", 11 }} 12 > 13 <Link to="/professor">Professor</Link> 14 </nav> 6 <h1>profesori.mk</h1> 15 7 <Outlet /> 16 8 </div> -
reactapp/src/Components/OpinionTree.js
r3a44163 r2998dc4 1 1 function OpinionTree({ professor }) { 2 function displayChildPosts(post) { 3 if (post == null) return; 2 var renderedOpinionIds = []; 3 var postCount; // za da ne go pokazuva ispod postot 4 5 function displayChildPosts(child) { 6 if (child == null) return; 7 postCount = renderedOpinionIds.push(child.postId); 4 8 return ( 5 <div key={post.postId}> 6 <p>Содржина: {post.content}</p> 7 {post.children.map((child) => displayChildPosts(child))} 9 <div key={child.postId}> 10 <p>{child.author.username} реплицирал</p> 11 <p>Содржина: {child.content}</p> 12 {child.children.map((childOfChild) => displayChildPosts(childOfChild))} 8 13 </div> 9 14 ); … … 13 18 <div className="opinionTree"> 14 19 {professor.relatedOpinions.map((opinion) => { 15 if (opinion.hasOwnProperty("title")) { 20 if (!renderedOpinionIds.includes(opinion.postId)) { 21 postCount = renderedOpinionIds.push(opinion.postId); 16 22 return ( 17 23 <div key={opinion.postId}> 24 <p>{opinion.author.username} напишал</p> 18 25 <p>Наслов: {opinion.title}</p> 19 26 <p>Содржина: {opinion.content}</p> 20 27 {opinion.children.map((child) => displayChildPosts(child))} 28 <hr /> 21 29 </div> 22 30 ); -
reactapp/src/Pages/Professor.js
r3a44163 r2998dc4 1 1 import React, { useEffect, useState } from "react"; 2 2 import { Outlet, useParams } from "react-router-dom"; 3 import JSOG from "jsog"; 3 4 import OpinionTree from "../Components/OpinionTree"; 4 5 … … 15 16 try { 16 17 const response = await fetch(url); 17 const json = await response.json(); 18 setProfessor(json); 18 var cyclicGraph = await response.json(); 19 var jsogStructure = JSOG.encode(cyclicGraph); // has { '@ref': 'ID' } links instead of cycles 20 cyclicGraph = JSOG.decode(jsogStructure); 21 setProfessor(cyclicGraph); 19 22 setLoaded(true); 20 23 } catch (error) {
Note:
See TracChangeset
for help on using the changeset viewer.