-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update front-end setup according to review
- Loading branch information
Showing
7 changed files
with
124 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
interface LinkProps { | ||
href: string; // Required - links with no `href` are not accessible | ||
external?: boolean; | ||
children: string | HTMLElement | JSX.Element; | ||
onClick?: JSX.MouseEventHandler<HTMLAnchorElement>; | ||
} | ||
|
||
const ExternalLink = ({ | ||
children, | ||
href, | ||
external, | ||
onClick, | ||
}: LinkProps) => { | ||
const target = external ? '_blank' : '_self'; | ||
// Protect older browsers - see https://mathiasbynens.github.io/rel-noopener | ||
const rel = external && 'external noopener noreferrer'; | ||
|
||
return ( | ||
<a href={href} target={target} rel={rel} onClick={onClick}> | ||
<span className="link__text">{children}</span> | ||
</a> | ||
); | ||
}; | ||
|
||
export default ExternalLink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import {Box, PopoverBody, PopoverCloseButton, PopoverFooter, PopoverHeader, Text} from "@chakra-ui/react"; | ||
import DynamicFAIcon from "./dynamicFAIcon"; | ||
import {ExtraInfoOnPerson, PersonResponse} from "../api/api-generated-types"; | ||
import useGetPerson from "../api/useGetPerson"; | ||
import * as React from "react"; | ||
|
||
export interface DrawInfoOnPerson { | ||
information: string; | ||
icon: string; | ||
iconColor: string; | ||
} | ||
|
||
|
||
const ExtraInfoComponent = ({ information, icon, iconColor }: DrawInfoOnPerson) => { | ||
return ( | ||
<Box p={2} style={{ display: "flex", alignItems: "center" }}> | ||
<DynamicFAIcon icon={icon} color={iconColor} style={{ display: "inline-block" }} /> | ||
<Text style={{ display: "inline-block", marginLeft: "10px" }}>{information}</Text> | ||
</Box> | ||
); | ||
}; | ||
|
||
const URLExtraInfoComponent = ({ information, icon, iconColor, url }: ExtraInfoOnPerson) => { | ||
return ( | ||
<> | ||
{url ? | ||
<a href={url} target="_blank"> | ||
<ExtraInfoComponent information={information} icon={icon} iconColor={iconColor}/> | ||
</a> | ||
: <ExtraInfoComponent information={information} icon={icon} iconColor={iconColor}/> | ||
} | ||
</> | ||
); | ||
}; | ||
|
||
const PersonImage = ({person}: {person: PersonResponse}) => { | ||
{/* Inspiration from https://www.webfx.com/blog/web-design/circular-images-css/. Thanks William Craig! */} | ||
return ( | ||
<div> | ||
{person.imgHeight != null && person.imgWidth != null && person.imgWidth > person.imgHeight | ||
? <div className="circular--landscape"> | ||
<img src={import.meta.env.VITE_API_ADDRESS + "person_img/" + person.imgFilename} alt={person.username}/> | ||
</div> | ||
: <div className="circular--portrait"> | ||
<img src={import.meta.env.VITE_API_ADDRESS + "person_img/" + person.imgFilename} alt={person.username}/> | ||
</div> | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
const PersonLazyLoading = ({ personUid }: { personUid: number }) => { | ||
const { data: apiPerson } = useGetPerson({ personUid }); | ||
|
||
return ( | ||
<> | ||
<PopoverHeader mt="5px" pl="20px" pb="10px" style={{fontWeight: "bold", fontSize: "20px"}}> | ||
{apiPerson?.username || apiPerson?.email || "unknown"} | ||
</PopoverHeader> | ||
<PopoverCloseButton pt={"22px"} pr={"22px"} fontSize={"12px"}/> | ||
<PopoverBody> | ||
{apiPerson?.imgFilename && | ||
<Box mb={"10px"} mt={"10px"}> | ||
<PersonImage person={apiPerson}/> | ||
</Box> | ||
} | ||
{apiPerson?.extraAttributes.map((extraAttribute: ExtraInfoOnPerson, index) => ( | ||
<URLExtraInfoComponent {...extraAttribute} key={index} /> | ||
))} | ||
</PopoverBody> | ||
<PopoverFooter> | ||
Last updated: {apiPerson?.lastUpdate} | ||
<br /> | ||
Sync enabled: {apiPerson?.sync ? "True" : "False"} | ||
</PopoverFooter> | ||
</> | ||
); | ||
}; | ||
|
||
export default PersonLazyLoading; |