meshtastic/src/pages/showcase/_components/NetworkSection.tsx

68 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-12-22 06:42:57 -08:00
import React from 'react';
import { Showcase } from '../../../utils/apiTypes';
2021-12-22 23:05:23 -08:00
import { Card, PlaceholderCard } from './Card';
2021-12-22 06:42:57 -08:00
interface NetworkSectionProps {
title: string;
icon?: JSX.Element;
iconColor?: string;
networks?: Showcase[];
}
export const NetworkSection = ({
title,
icon,
iconColor,
networks,
}: NetworkSectionProps): JSX.Element => {
return (
<div className="margin-top--lg container">
2021-12-22 06:42:57 -08:00
<div
className="margin-bottom--sm"
style={{
display: 'flex',
alignItems: 'center',
2021-12-22 06:42:57 -08:00
}}
>
<h2>{title}</h2>
{icon && (
<span
style={{
marginBottom: '0.5rem',
marginLeft: '0.5rem',
fontSize: '1.25rem',
lineHeight: '1.75rem',
2021-12-22 06:42:57 -08:00
color: iconColor,
}}
>
{icon}
</span>
)}
</div>
<ul
style={{
position: 'relative',
display: 'grid',
gap: '1.5rem',
gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))',
paddingLeft: '0',
2021-12-22 06:42:57 -08:00
}}
>
{networks ? (
<>
{networks.map((network) => (
<Card key={network.title} network={network} />
))}
{networks.length === 0 && <h2>No result</h2>}
</>
) : (
2021-12-22 23:05:23 -08:00
<div>
<PlaceholderCard />
</div>
2021-12-22 06:42:57 -08:00
)}
</ul>
</div>
);
};