Make full app area a link

This commit is contained in:
Brandon Dean 2021-04-23 17:59:14 -04:00
parent 62d89e31c3
commit 7c0cd58fcc

View file

@ -3,10 +3,16 @@ import Icon from "./icon";
import styled from "styled-components"; import styled from "styled-components";
import selectedTheme from "../lib/theme"; import selectedTheme from "../lib/theme";
const AppContainer = styled.div` const AppContainer = styled.a`
display: flex; display: flex;
flex: auto 25%; flex: 1 0 auto;
padding: 1rem; padding: 1rem;
color: ${selectedTheme.mainColor};
font-weight: 500;
text-transform: uppercase;
margin: 0;
text-decoration: none;
font-size: 1rem;
`; `;
const IconContainer = styled.div` const IconContainer = styled.div`
@ -21,16 +27,8 @@ const DetailsContainer = styled.div`
flex-direction: column; flex-direction: column;
`; `;
const AppLink = styled.a` const AppName = styled.div`
flex: 1 0 auto; a:hover & {
color: ${selectedTheme.mainColor};
font-weight: 500;
text-transform: uppercase;
margin: 0;
text-decoration: none;
font-size: 1rem;
&:hover {
text-decoration: underline; text-decoration: underline;
} }
`; `;
@ -59,18 +57,18 @@ export const App = ({ name, icon, url, displayURL, newTab }: IAppProps) => {
useEffect(() => { console.log(newTab) }, [newTab]) useEffect(() => { console.log(newTab) }, [newTab])
const linkAttrs = (newTab !== undefined && newTab) ? {
target: '_blank',
rel: 'noopener noreferrer',
} : {};
return ( return (
<AppContainer> <AppContainer href={url} {...linkAttrs}>
<IconContainer> <IconContainer>
<Icon name={icon} /> <Icon name={icon} />
</IconContainer> </IconContainer>
<DetailsContainer> <DetailsContainer>
<AppName>{name}</AppName>
{
(newTab !== undefined && newTab) ?
<AppLink href={url} target="_blank" rel="noopener noreferrer">{name}</AppLink> : <AppLink href={url}>{name}</AppLink>
}
<AppDescription>{displayURL}</AppDescription> <AppDescription>{displayURL}</AppDescription>
</DetailsContainer> </DetailsContainer>
</AppContainer> </AppContainer>