mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 13:17:00 +04:00
86 lines
2.7 KiB
Plaintext
86 lines
2.7 KiB
Plaintext
---
|
|
import Avatar from '@ui/Avatar.astro'
|
|
import { people } from '@shared/lib/people'
|
|
import Icon from '@ui/Icon.astro'
|
|
import ListGroup from '@ui/ListGroup.astro'
|
|
import ListGroupItem from '@ui/ListGroupItem.astro'
|
|
import CardTitle from '@ui/CardTitle.astro'
|
|
import commits from '@data/commits.json'
|
|
import { randomNumber } from '@shared/lib/pseudo-random'
|
|
|
|
interface Props {
|
|
offset?: number
|
|
hoverable?: boolean
|
|
checkbox?: boolean
|
|
/** 1-based indices of the checked rows, e.g. [2, 5, 8] */
|
|
checkedIds?: number[]
|
|
title?: string
|
|
class?: string
|
|
}
|
|
|
|
const { offset = 0, hoverable = false, checkbox, checkedIds, title = 'Last commits', class: className } = Astro.props
|
|
|
|
const limit = 8
|
|
|
|
const colors = ['green', 'red', 'yellow', 'x', 'x']
|
|
const commitList = commits as { description: string }[]
|
|
|
|
const rows = people.slice(offset, offset + limit).map((person, idx) => {
|
|
const index = idx + 1
|
|
const color = colors[randomNumber(index + 5, 0, colors.length - 1)]
|
|
const checked = checkedIds?.includes(index) ?? false
|
|
const i = index + offset
|
|
return {
|
|
person,
|
|
color,
|
|
checked,
|
|
description: commitList[i]?.description,
|
|
starColor: checked ? 'text-yellow' : 'text-secondary',
|
|
}
|
|
})
|
|
---
|
|
|
|
<div class={`card${className ? ` ${className}` : ''}`}>
|
|
<div class="card-header">
|
|
<CardTitle>{title}</CardTitle>
|
|
</div>
|
|
<ListGroup flush hoverable={hoverable}>
|
|
{
|
|
rows.map((row) => (
|
|
<ListGroupItem active={row.checked}>
|
|
<div class="row align-items-center">
|
|
{checkbox ? (
|
|
<div class="col-auto">
|
|
<input type="checkbox" class="form-check-input" checked={row.checked} />
|
|
</div>
|
|
) : (
|
|
<div class="col-auto">
|
|
<span class={`badge${row.color !== 'x' ? ` bg-${row.color}` : ''}`} />
|
|
</div>
|
|
)}
|
|
<div class="col-auto">
|
|
<a href="#" tabindex="-1" aria-hidden="true">
|
|
<Avatar person={row.person} />
|
|
</a>
|
|
</div>
|
|
|
|
<div class="col text-truncate">
|
|
<a href="#" class="text-reset d-block">
|
|
{row.person.full_name}
|
|
</a>
|
|
<div class="d-block text-secondary text-truncate mt-n1">{row.description}</div>
|
|
</div>
|
|
{hoverable && (
|
|
<div class="col-auto">
|
|
<a href="#" class={`list-group-item-actions${row.checked ? ' show' : ''}`} aria-label={row.checked ? 'Remove from favorites' : 'Add to favorites'}>
|
|
<Icon name="star" class={row.starColor} />
|
|
</a>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</ListGroupItem>
|
|
))
|
|
}
|
|
</ListGroup>
|
|
</div>
|