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

111 lines
2.4 KiB
TypeScript
Raw Normal View History

2021-11-30 02:46:31 -08:00
import React from 'react';
2021-12-22 06:42:57 -08:00
import { Showcase } from '../../../utils/apiTypes';
import { mapUrl } from '../../../utils/map';
import { CardTags } from './CardTags';
2021-11-30 02:46:31 -08:00
2021-12-22 06:42:57 -08:00
export interface CardProps {
network: Showcase;
2021-11-30 02:46:31 -08:00
}
2021-12-22 06:42:57 -08:00
export const Card = React.memo(({ network }: CardProps) => (
<div className="card">
<div className="card__image">
2021-12-23 18:17:40 -08:00
<div style={{ height: "140px" }}>
<img img={mapUrl(network.nodes ?? [])} alt={network.title} />
2021-12-23 18:17:40 -08:00
</div>
2021-12-22 06:42:57 -08:00
</div>
<div className="card__body">
<h4>{network.title}</h4>
<small>{network.summary}</small>
</div>
<div className="card__footer">
<a
href={`?id=${network.id}`}
className="button button--primary button--block"
style={{ marginBottom: "0.5rem" }}
>
2021-12-22 22:22:01 -08:00
Read more
2021-12-22 06:42:57 -08:00
</a>
<CardTags tags={network.tags} />
2021-11-30 02:46:31 -08:00
</div>
2021-12-22 06:42:57 -08:00
</div>
));
2021-12-22 23:05:23 -08:00
export const PlaceholderCard = (): JSX.Element => (
<div
className="card"
style={{
animation: "pulse 2s infinite",
transform: "scale(1)",
}}
>
<div className="card__image">
<div
style={{
2021-12-23 18:17:40 -08:00
height: "140px",
2021-12-22 23:05:23 -08:00
}}
/>
</div>
<div className="card__body">
<div
style={{
width: "30%",
height: "2rem",
borderRadius: "0.4rem",
backgroundColor: "gray",
marginBottom: "1rem",
}}
/>
<div
style={{
width: "100%",
height: "1rem",
borderRadius: "0.4rem",
backgroundColor: "gray",
marginBottom: "0.5rem",
}}
/>
<div
style={{
width: "100%",
height: "1rem",
borderRadius: "0.4rem",
backgroundColor: "gray",
}}
/>
</div>
<div className="card__footer">
<a
className="button disabled button--primary button--block"
style={{ marginBottom: "0.5rem" }}
>
&nbsp;
</a>
2021-12-23 18:17:40 -08:00
<div
style={{
display: "flex",
gap: "0.5rem",
}}
>
<div
style={{
width: "4rem",
height: "1.5rem",
borderRadius: "0.4rem",
backgroundColor: "gray",
}}
/>
2021-12-22 23:05:23 -08:00
<div
style={{
width: "4rem",
height: "1.5rem",
borderRadius: "0.4rem",
backgroundColor: "gray",
}}
/>
</div>
</div>
</div>
);