- Timestamp:
- 08/06/22 18:16:44 (2 years ago)
- Branches:
- main
- Children:
- 800779d
- Parents:
- d654c74
- Location:
- reactapp/src
- Files:
-
- 1 added
- 5 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
reactapp/src/App.js
rd654c74 r3e98cea 1 1 import { Outlet } from "react-router-dom"; 2 import { MainWrapper, MainTitle } from "./Components/ Main.style";2 import { MainWrapper, MainTitle } from "./Components/Styled/Main.style"; 3 3 import Search from "./Components/Search.js"; 4 4 … … 16 16 } 17 17 </style> 18 <MainTitle>profesori.mk</MainTitle> <Search /> 18 <a href="/"> 19 <MainTitle>profesori.mk</MainTitle> 20 </a>{" "} 21 <Search /> 19 22 <Outlet /> 20 23 </MainWrapper> -
reactapp/src/Components/OpinionTree.js
rd654c74 r3e98cea 8 8 OpinionReplyCardContentTime, 9 9 StyledFontAwesomeIcon, 10 } from "./OpinionCard.style"; 11 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; 12 import { 13 solid, 14 regular, 15 brands, 16 } from "@fortawesome/fontawesome-svg-core/import.macro"; 10 } from "./Styled/OpinionCard.style"; 11 12 import { solid } from "@fortawesome/fontawesome-svg-core/import.macro"; 17 13 import { dateConverter } from "../Util/dateConverter"; 18 14 -
reactapp/src/Components/Search.js
rd654c74 r3e98cea 3 3 import { transliterate } from "../Util/transliterate"; 4 4 import { 5 SearchDropdownResultSmall, 6 SearchDropdownTextSmall, 7 SearchDropdownSmall, 8 SearchDropdownResultLinkSmall, 9 SearchSmall, 10 } from "./Search.style"; 5 SearchResult, 6 SearchResultText, 7 SearchDropdown, 8 SearchResultLink, 9 SearchBox, 10 } from "./Styled/Search.style"; 11 import { useNavigate } from "react-router"; 11 12 function Search() { 12 13 const [query, setQuery] = useState(""); … … 27 28 //setLoaded(true); 28 29 } catch (error) { 29 console.log(" Error", error);30 console.log("Fetching error occured", error); 30 31 } 31 32 }; … … 33 34 if (query.length > 2) fetchData(); 34 35 }, [query]); 36 37 const navigate = useNavigate(); 38 39 const handleKeyDown = (event) => { 40 if (event.key === "Enter") { 41 setExpanded(false); 42 navigate("/search", { state: professors }); 43 } 44 }; 45 46 const [expanded, setExpanded] = useState(false); 47 48 function expand() { 49 setExpanded(true); 50 } 51 52 function close() { 53 setExpanded(false); 54 } 35 55 36 56 return ( … … 42 62 }} 43 63 > 44 <Search Small64 <SearchBox 45 65 placeholder="Пребарувај..." 46 66 onChange={(e) => setQuery(e.target.value)} 67 onKeyDown={handleKeyDown} 68 tabIndex={0} 69 onFocus={expand} 70 onBlur={close} 47 71 /> 48 <SearchDropdownSmall 49 display={query.length > 2 && professors.length > 0 ? "block" : "none"} 72 <SearchDropdown 73 display={ 74 query.length > 2 && professors.length > 0 && expanded 75 ? "block" 76 : "none" 77 } 50 78 > 51 79 {query.length > 2 && 52 80 professors.slice(0, 7).map((professor) => ( 53 <SearchDropdownResultSmall key={professor.professorId}> 54 <SearchDropdownResultLinkSmall 55 href={"/professor/" + professor.professorId} 56 > 57 <SearchDropdownTextSmall weight="bold" size="medium"> 81 <SearchResult 82 key={professor.professorId} 83 onMouseDown={(event) => { 84 event.preventDefault(); 85 event.stopPropagation(); 86 }} 87 margin="0" 88 > 89 <SearchResultLink href={"/professor/" + professor.professorId}> 90 <SearchResultText weight="bold" size="medium"> 58 91 {professor.professorName} 59 </Search DropdownTextSmall>60 <Search DropdownTextSmall weight="normal" size="smaller">92 </SearchResultText> 93 <SearchResultText weight="normal" size="er"> 61 94 {professor.faculty.facultyName} 62 </Search DropdownTextSmall>63 </Search DropdownResultLinkSmall>64 </Search DropdownResultSmall>95 </SearchResultText> 96 </SearchResultLink> 97 </SearchResult> 65 98 ))} 66 </SearchDropdown Small>99 </SearchDropdown> 67 100 </div> 68 101 ); -
reactapp/src/Components/Styled/Main.style.js
rd654c74 r3e98cea 16 16 font-size: 36pt; 17 17 text-decoration: underline 3px; 18 margin-bottom: 30px;19 18 width: fit-content; 20 19 float: left; 20 color: black; 21 21 `; -
reactapp/src/Components/Styled/Search.style.js
rd654c74 r3e98cea 1 1 import styled from "styled-components"; 2 import searchicon from "../ searchicon.png";2 import searchicon from "../../searchicon.png"; 3 3 4 export const Search Small= styled.input`4 export const SearchBox = styled.input` 5 5 width: 350px; 6 6 box-sizing: border-box; … … 15 15 `; 16 16 17 export const SearchDropdown Small= styled.div`17 export const SearchDropdown = styled.div` 18 18 display: ${(props) => props.display}; 19 19 position: absolute; … … 27 27 `; 28 28 29 export const Search DropdownResultSmall= styled.div`29 export const SearchResult = styled.div` 30 30 &:hover { 31 31 background-color: papayawhip; … … 34 34 } 35 35 padding: 10px; 36 border: 1px solid transparent; 37 margin: ${(props) => props.margin}; 36 38 `; 37 39 38 export const Search DropdownResultLinkSmall= styled.a`40 export const SearchResultLink = styled.a` 39 41 text-decoration: none; 40 42 color: black; 41 43 `; 42 44 43 export const Search DropdownTextSmall= styled.p`45 export const SearchResultText = styled.p` 44 46 font-weight: ${(props) => props.weight}; 45 47 font-size: ${(props) => props.size}; 46 48 `; 49 50 export const SearchResultsWrapper = styled.div` 51 margin-top: 140px; 52 `; -
reactapp/src/Pages/Professor.js
rd654c74 r3e98cea 9 9 ProfessorCardName, 10 10 ProfessorCardSeparator, 11 } from "../Components/ ProfessorCard.style";11 } from "../Components/Styled/ProfessorCard.style"; 12 12 13 13 function Professor(props) { … … 34 34 35 35 fetchData(); 36 }, [ ]);36 }, [params.professorId]); 37 37 38 38 if (loaded) { -
reactapp/src/index.js
rd654c74 r3e98cea 3 3 import App from "./App"; 4 4 import Professor from "./Pages/Professor"; 5 import SearchResults from "./Pages/SearchResults"; 5 6 6 7 const root = ReactDOM.createRoot(document.getElementById("root")); … … 12 13 <Route path=":professorId" element={<Professor />} /> 13 14 </Route> 15 <Route path="search" element={<SearchResults />}></Route> 14 16 </Route> 15 17 </Routes>
Note:
See TracChangeset
for help on using the changeset viewer.