🦄 Came back to this project after a year.... implemented lots of things

This commit is contained in:
Alicia Sykes
2023-06-18 16:02:57 +01:00
parent a6043d51d4
commit 920ab64410
9 changed files with 227 additions and 24 deletions

View File

@@ -8,7 +8,6 @@ export const Card = styled.section`
box-shadow: 4px 4px 0px ${colors.bgShadowColor};
border-radius: 8px;
padding: 1rem;
margin: 1rem;
`;
// interface CardProps {

View File

@@ -0,0 +1,69 @@
import styled from 'styled-components';
import { TechnologyGroup, Technology } from 'utils/result-processor';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
const Outer = styled(Card)`
grid-row: span 2
`;
const Row = styled.div`
display: flex;
justify-content: space-between;
padding: 0.25rem;
&:not(:last-child) { border-bottom: 1px solid ${colors.primary}; }
span.lbl { font-weight: bold; }
span.val {
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
`;
const DataRow = (props: { lbl: string, val: string }) => {
const { lbl, val } = props;
return (
<Row>
<span className="lbl">{lbl}</span>
<span className="val" title={val}>{val}</span>
</Row>
);
};
const ListRow = (props: { list: Technology[], title: string }) => {
const { list, title } = props;
return (
<>
<Heading as="h3" size="small" align="left" color={colors.primary}>{title}</Heading>
{ list.map((entry: Technology, index: number) => {
return (
<Row key={`${title.toLocaleLowerCase()}-${index}`}><span>{ entry.Name }</span></Row>
)}
)}
</>
);
}
const BuiltWithCard = (props: { technologies: TechnologyGroup[] }): JSX.Element => {
// const { created, updated, expires, nameservers } = whois;
const { technologies } = props;
return (
<Outer>
<Heading as="h3" size="small" align="left" color={colors.primary}>Technologies</Heading>
{ technologies.map((group: TechnologyGroup) => {
return (
<ListRow key={group.tag} title={group.tag} list={group.technologies} />
);
})}
{/* { created && <DataRow lbl="Created" val={formatDate(created)} /> }
{ updated && <DataRow lbl="Updated" val={formatDate(updated)} /> }
{ expires && <DataRow lbl="Expires" val={formatDate(expires)} /> }
{ nameservers && <ListRow title="Name Servers" list={nameservers} /> } */}
</Outer>
);
}
export default BuiltWithCard;

View File

@@ -6,7 +6,8 @@ import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
const Outer = styled(Card)`
max-width: 24rem;
max-height: 20rem;
overflow: auto;
`;
const Row = styled.div`

View File

@@ -5,9 +5,7 @@ import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
const Outer = styled(Card)`
max-width: 24rem;
`;
const Outer = styled(Card)``;
const Row = styled.div`
display: flex;
@@ -34,7 +32,7 @@ const DataRow = (props: { lbl: string, val: string }) => {
};
const ServerInfoCard = (info: ServerInfo): JSX.Element => {
const { org, asn, isp, os } = info;
const { org, asn, isp, os, ports } = info;
return (
<Outer>
<Heading as="h3" size="small" align="left" color={colors.primary}>Server Info</Heading>
@@ -42,6 +40,7 @@ const ServerInfoCard = (info: ServerInfo): JSX.Element => {
{ (isp && isp !== org) && <DataRow lbl="Service Provider" val={isp} /> }
{ os && <DataRow lbl="Operating System" val={os} /> }
{ asn && <DataRow lbl="ASN Code" val={asn} /> }
{ ports && <DataRow lbl="Ports" val={ports} /> }
</Outer>
);
}

View File

@@ -9,7 +9,7 @@ import Flag from 'components/misc/Flag';
import { TextSizes } from 'styles/typography';
const Outer = styled(Card)`
max-width: 24rem;
grid-row: span 2
`;
const Row = styled.div`

View File

@@ -0,0 +1,71 @@
import styled from 'styled-components';
import { Whois } from 'utils/result-processor';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
const Outer = styled(Card)``;
const Row = styled.div`
display: flex;
justify-content: space-between;
padding: 0.25rem;
&:not(:last-child) { border-bottom: 1px solid ${colors.primary}; }
span.lbl { font-weight: bold; }
span.val {
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
`;
const formatDate = (dateString: string): string => {
const date = new Date(dateString);
const formatter = new Intl.DateTimeFormat('en-GB', {
day: 'numeric',
month: 'long',
year: 'numeric'
});
return formatter.format(date);
}
const DataRow = (props: { lbl: string, val: string }) => {
const { lbl, val } = props;
return (
<Row>
<span className="lbl">{lbl}</span>
<span className="val" title={val}>{val}</span>
</Row>
);
};
const ListRow = (props: { list: string[], title: string }) => {
const { list, title } = props;
return (
<>
<Heading as="h3" size="small" align="left" color={colors.primary}>{title}</Heading>
{ list.map((entry: string, index: number) => {
return (
<Row key={`${title.toLocaleLowerCase()}-${index}`}><span>{ entry }</span></Row>
)}
)}
</>
);
}
const ServerInfoCard = (whois: Whois): JSX.Element => {
const { created, updated, expires, nameservers } = whois;
return (
<Outer>
<Heading as="h3" size="small" align="left" color={colors.primary}>Who Is Info</Heading>
{ created && <DataRow lbl="Created" val={formatDate(created)} /> }
{ updated && <DataRow lbl="Updated" val={formatDate(updated)} /> }
{ expires && <DataRow lbl="Expires" val={formatDate(expires)} /> }
{ nameservers && <ListRow title="Name Servers" list={nameservers} /> }
</Outer>
);
}
export default ServerInfoCard;