stacker.news/components/user-list.js

75 lines
2.6 KiB
JavaScript
Raw Normal View History

2022-10-25 17:13:06 +00:00
import Link from 'next/link'
import { Image } from 'react-bootstrap'
2022-10-25 21:35:32 +00:00
import { abbrNum } from '../lib/format'
2023-02-01 14:44:35 +00:00
import CowboyHat from './cowboy-hat'
2022-10-25 17:13:06 +00:00
import styles from './item.module.css'
import userStyles from './user-header.module.css'
export default function UserList ({ users }) {
return (
<> {users.map(user => (
<div className={`${styles.item} mb-2`} key={user.name}>
<Link href={`/${user.name}`} passHref>
<a>
<Image
src={user.photoId ? `https://${process.env.NEXT_PUBLIC_AWS_UPLOAD_BUCKET}.s3.amazonaws.com/${user.photoId}` : '/dorian400.jpg'} width='32' height='32'
className={`${userStyles.userimg} mr-2`}
/>
</a>
</Link>
<div className={styles.hunk}>
<Link href={`/${user.name}`} passHref>
2023-02-01 14:44:35 +00:00
<a className={`${styles.title} d-inline-flex align-items-center text-reset`}>
2023-05-01 21:49:47 +00:00
@{user.name}<CowboyHat className='ml-1 fill-grey' height={14} width={14} user={user} />
2022-10-25 17:13:06 +00:00
</a>
</Link>
<div className={styles.other}>
2022-10-25 21:35:32 +00:00
<span>{abbrNum(user.stacked)} stacked</span>
2022-10-25 17:13:06 +00:00
<span> \ </span>
2022-10-25 21:35:32 +00:00
<span>{abbrNum(user.spent)} spent</span>
2022-10-25 17:13:06 +00:00
<span> \ </span>
<Link href={`/${user.name}/posts`} passHref>
<a className='text-reset'>
2022-10-25 21:35:32 +00:00
{abbrNum(user.nitems)} posts
2022-10-25 17:13:06 +00:00
</a>
</Link>
<span> \ </span>
<Link href={`/${user.name}/comments`} passHref>
<a className='text-reset'>
2022-10-25 21:35:32 +00:00
{abbrNum(user.ncomments)} comments
2022-10-25 17:13:06 +00:00
</a>
</Link>
2022-12-19 23:00:53 +00:00
{user.referrals > 0 && <span> \ {abbrNum(user.referrals)} referrals</span>}
2022-10-25 17:13:06 +00:00
</div>
</div>
</div>
))}
</>
)
}
2022-10-25 21:35:32 +00:00
export function UsersSkeleton () {
const users = new Array(21).fill(null)
return (
<div>{users.map((_, i) => (
<div className={`${styles.item} ${styles.skeleton} mb-2`} key={i}>
<Image
src='/clouds.jpeg' width='32' height='32'
className={`${userStyles.userimg} clouds mr-2`}
/>
<div className={styles.hunk}>
<div className={`${styles.name} clouds text-reset`} />
<div className={styles.other}>
<span className={`${styles.otherItem} clouds`} />
<span className={`${styles.otherItem} clouds`} />
<span className={`${styles.otherItem} ${styles.otherItemLonger} clouds`} />
<span className={`${styles.otherItem} ${styles.otherItemLonger} clouds`} />
</div>
</div>
</div>
))}
</div>
)
}