first commit

This commit is contained in:
2026-10-03 13:40:26 +02:00
parent 732a5b5a16
commit 566f415fa7
555 changed files with 62704 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { initials } from './copy';
/** Overlapping initials (members of a project, people on a ticket). */
@Component({
selector: 'ts-avatars',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@for (name of names().slice(0, max()); track $index) {
<span class="ts-avatar" [attr.title]="name">{{ initialsOf(name) }}</span>
}
@if (names().length > max()) {
<span class="ts-avatar ts-avatar--more"
>+{{ names().length - max() }}</span
>
}
`,
styles: `
:host {
display: inline-flex;
align-items: center;
padding-left: 0.375rem;
}
.ts-avatar {
display: inline-grid;
place-items: center;
width: var(--ts-avatar-size, 1.75rem);
height: var(--ts-avatar-size, 1.75rem);
margin-left: -0.375rem;
border-radius: 50%;
border: 2px solid var(--ts-surface);
background: color-mix(in srgb, var(--ts-brand) 18%, var(--ts-surface));
color: color-mix(in srgb, var(--ts-brand) 70%, var(--ts-ink));
font-family: var(--ts-font-mono);
font-size: 0.625rem;
font-weight: 600;
letter-spacing: 0;
}
.ts-avatar--more {
background: var(--ts-sunken);
color: var(--ts-muted);
}
`,
})
export class AvatarsComponent {
readonly names = input.required<readonly string[]>();
readonly max = input(5);
protected readonly initialsOf = initials;
}

View File

@@ -0,0 +1,243 @@
import { DatasetColor } from '@pi/ui';
import {
IssueArea,
IssueLinkType,
IssuePriority,
IssueStatus,
IssueType,
ProjectRole,
ReleaseStatus,
} from '@task-stream/web/tracker/domain';
type ChipColor =
| 'accent'
| 'grey'
| 'highlighted'
| 'primary'
| 'success'
| 'warn';
type IconColor =
| 'primary'
| 'accent'
| 'warn'
| 'success'
| 'grey'
| 'highlighted';
/* UI copy (es) and the visual language of the tracker. */
/** `tone`: CSS colour token of the status/type (see `--ts-s-*`, `--ts-t-*` in styles.scss). */
export const STATUS: Record<
IssueStatus,
{ label: string; color: ChipColor; chart: DatasetColor; tone: string }
> = {
[IssueStatus.BACKLOG]: {
label: 'Backlog',
color: 'grey',
chart: DatasetColor.grey,
tone: 'var(--ts-s-backlog)',
},
[IssueStatus.TODO]: {
label: 'Por hacer',
color: 'grey',
chart: DatasetColor.grey300,
tone: 'var(--ts-s-todo)',
},
[IssueStatus.IN_PROGRESS]: {
label: 'En curso',
color: 'primary',
chart: DatasetColor.primary,
tone: 'var(--ts-s-progress)',
},
[IssueStatus.IN_REVIEW]: {
label: 'En revisión',
color: 'accent',
chart: DatasetColor.accent,
tone: 'var(--ts-s-review)',
},
[IssueStatus.READY_FOR_QA]: {
label: 'Listo para QA',
color: 'highlighted',
chart: DatasetColor.highlighted,
tone: 'var(--ts-s-ready)',
},
[IssueStatus.IN_QA]: {
label: 'En QA',
color: 'highlighted',
chart: DatasetColor.highlighted50,
tone: 'var(--ts-s-qa)',
},
[IssueStatus.QA_FAILED]: {
label: 'QA fallido',
color: 'warn',
chart: DatasetColor.warn,
tone: 'var(--ts-s-failed)',
},
[IssueStatus.DONE]: {
label: 'Hecho',
color: 'success',
chart: DatasetColor.success,
tone: 'var(--ts-s-done)',
},
[IssueStatus.CANCELLED]: {
label: 'Cancelado',
color: 'grey',
chart: DatasetColor.grey50,
tone: 'var(--ts-s-cancelled)',
},
};
export const TYPE: Record<
IssueType,
{ label: string; icon: string; color: IconColor; tone: string }
> = {
[IssueType.BUG]: {
label: 'Bug',
icon: 'bug',
color: 'warn',
tone: 'var(--ts-t-bug)',
},
[IssueType.FEATURE]: {
label: 'Feature',
icon: 'feature',
color: 'primary',
tone: 'var(--ts-t-feature)',
},
[IssueType.UI_CHANGE]: {
label: 'Cambio de UI',
icon: 'palette',
color: 'accent',
tone: 'var(--ts-t-ui)',
},
[IssueType.TASK]: {
label: 'Tarea',
icon: 'task',
color: 'grey',
tone: 'var(--ts-t-task)',
},
[IssueType.QA]: {
label: 'QA',
icon: 'qa',
color: 'highlighted',
tone: 'var(--ts-t-qa)',
},
};
/** Signal strength of a priority, drawn as bars (1–4) like a phone signal. */
export const PRIORITY_LEVEL: Record<IssuePriority, number> = {
[IssuePriority.CRITICAL]: 4,
[IssuePriority.HIGH]: 3,
[IssuePriority.MEDIUM]: 2,
[IssuePriority.LOW]: 1,
[IssuePriority.LOWEST]: 0,
};
export const PRIORITY: Record<
IssuePriority,
{ label: string; color: ChipColor }
> = {
[IssuePriority.CRITICAL]: { label: 'Crítica', color: 'warn' },
[IssuePriority.HIGH]: { label: 'Alta', color: 'accent' },
[IssuePriority.MEDIUM]: { label: 'Media', color: 'primary' },
[IssuePriority.LOW]: { label: 'Baja', color: 'grey' },
[IssuePriority.LOWEST]: { label: 'Mínima', color: 'grey' },
};
export const AREA: Record<IssueArea, string> = {
[IssueArea.FRONTEND]: 'Frontend',
[IssueArea.BACKEND]: 'Backend',
[IssueArea.MOBILE]: 'Mobile',
[IssueArea.QA]: 'QA',
[IssueArea.DESIGN]: 'Diseño',
[IssueArea.DEVOPS]: 'DevOps',
};
export const LINK: Record<IssueLinkType, { outward: string; inward: string }> =
{
[IssueLinkType.BLOCKS]: {
outward: 'bloquea a',
inward: 'está bloqueado por',
},
[IssueLinkType.DEPENDS_ON]: {
outward: 'depende de',
inward: 'es dependencia de',
},
[IssueLinkType.TESTS]: { outward: 'prueba', inward: 'es probado por' },
[IssueLinkType.DUPLICATES]: {
outward: 'duplica a',
inward: 'está duplicado por',
},
[IssueLinkType.RELATES_TO]: {
outward: 'relacionado con',
inward: 'relacionado con',
},
};
export const ROLE: Record<ProjectRole, string> = {
[ProjectRole.OWNER]: 'Propietario',
[ProjectRole.ADMIN]: 'Admin',
[ProjectRole.MEMBER]: 'Miembro',
[ProjectRole.VIEWER]: 'Lector',
};
export const RELEASE_STATUS: Record<
ReleaseStatus,
{ label: string; color: ChipColor }
> = {
[ReleaseStatus.PLANNED]: { label: 'Planificada', color: 'primary' },
[ReleaseStatus.RELEASED]: { label: 'Publicada', color: 'success' },
[ReleaseStatus.ARCHIVED]: { label: 'Archivada', color: 'grey' },
};
export const options = <T extends string>(
record: Record<T, string | { label: string }>,
) =>
(Object.keys(record) as T[]).map((value) => {
const entry = record[value];
return { value, label: typeof entry === 'string' ? entry : entry.label };
});
/** "hace 5 min", "ayer"… */
export function timeAgo(iso: string, now = Date.now()): string {
const seconds = Math.max(0, Math.round((now - Date.parse(iso)) / 1000));
const rtf = new Intl.RelativeTimeFormat('es', { numeric: 'auto' });
if (seconds < 60) return rtf.format(-seconds, 'second');
if (seconds < 3600) return rtf.format(-Math.round(seconds / 60), 'minute');
if (seconds < 86400) return rtf.format(-Math.round(seconds / 3600), 'hour');
return rtf.format(-Math.round(seconds / 86400), 'day');
}
const PROJECT_TONES = [
'var(--ts-t-feature)',
'var(--ts-s-review)',
'var(--ts-t-ui)',
'var(--ts-t-qa)',
'var(--ts-s-done)',
'var(--ts-s-qa)',
];
/** A stable colour per project (from its key), so it is recognisable everywhere. */
export function projectTone(key: string): string {
let hash = 0;
for (const char of key) hash = (hash * 31 + char.charCodeAt(0)) >>> 0;
return PROJECT_TONES[hash % PROJECT_TONES.length];
}
/** "Ana García" → "AG". */
export function initials(name: string): string {
return name
.split(/\s+/)
.filter(Boolean)
.map((part) => part[0])
.join('')
.slice(0, 2)
.toUpperCase();
}
/** "14:05" today, "3 oct" otherwise (logs and histories). */
export function clock(iso: string, now = new Date()): string {
const date = new Date(iso);
return date.toDateString() === now.toDateString()
? date.toLocaleTimeString('es', { hour: '2-digit', minute: '2-digit' })
: date.toLocaleDateString('es', { day: 'numeric', month: 'short' });
}

View File

@@ -0,0 +1,216 @@
import {
ChangeDetectionStrategy,
Component,
computed,
input,
} from '@angular/core';
import { RouterLink } from '@angular/router';
import { PiIconComponent } from '@pi/ui';
import { IssueSummary } from '@task-stream/web/tracker/domain';
import { AREA, initials, PRIORITY, PRIORITY_LEVEL, TYPE } from './copy';
/** A ticket on the board / in lists: type stripe, key, title, signals. */
@Component({
selector: 'ts-issue-card',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [RouterLink, PiIconComponent],
template: `
<a
class="ts-card"
[routerLink]="['..', 'issues', issue().key]"
[style.--type]="type().tone"
[class.ts-card--critical]="issue().priority === 'CRITICAL'"
>
<div class="ts-card__top">
<span class="ts-card__type" [attr.title]="type().label">
<pi-icon [icon]="type().icon" size="small" />
</span>
<span class="ts-card__key">{{ issue().key }}</span>
@if (issue().area; as area) {
<span class="ts-card__area">{{ areaLabel(area) }}</span>
}
</div>
<p class="ts-card__title">{{ issue().title }}</p>
<div class="ts-card__bottom">
<span
class="ts-signal"
[attr.data-level]="level()"
[attr.title]="'Prioridad ' + priority().label.toLowerCase()"
[attr.aria-label]="'Prioridad ' + priority().label.toLowerCase()"
>
<i></i><i></i><i></i><i></i>
</span>
@if (issue().release; as release) {
<span class="ts-card__meta" title="Release"
>◆ {{ release.name }}</span
>
}
@if (issue().commentCount) {
<span class="ts-card__meta" title="Comentarios">
<pi-icon icon="chat" size="x-small" />
{{ issue().commentCount }}
</span>
}
<span class="ts-card__spacer"></span>
@if (issue().assignee; as assignee) {
<span class="ts-card__who" [attr.title]="assignee.name">{{
initialsOf(assignee.name)
}}</span>
} @else {
<span class="ts-card__who ts-card__who--none" title="Sin asignar"
>—</span
>
}
</div>
</a>
`,
styles: `
:host {
display: block;
}
.ts-card {
--type: var(--ts-muted);
position: relative;
display: grid;
gap: 0.5rem;
padding: 0.75rem 0.75rem 0.6875rem 0.9375rem;
overflow: hidden;
border-radius: 0.625rem;
background: var(--ts-surface);
border: 1px solid var(--ts-line);
color: inherit;
text-decoration: none;
box-shadow: 0 1px 0 rgb(0 0 0 / 3%);
transition:
box-shadow 0.15s ease,
transform 0.15s ease,
border-color 0.15s ease;
&::before {
content: '';
position: absolute;
inset: 0 auto 0 0;
width: 3px;
background: var(--type);
}
&:hover {
border-color: color-mix(in srgb, var(--type) 40%, var(--ts-line));
box-shadow: 0 10px 22px -16px
color-mix(in srgb, var(--type) 70%, transparent);
transform: translateY(-1px);
}
&:focus-visible {
outline: 2px solid var(--type);
outline-offset: 2px;
}
}
.ts-card__top,
.ts-card__bottom {
display: flex;
align-items: center;
gap: 0.5rem;
min-width: 0;
}
.ts-card__type {
display: inline-grid;
place-items: center;
width: 1.375rem;
height: 1.375rem;
border-radius: 0.375rem;
color: var(--type);
background: color-mix(in srgb, var(--type) 13%, transparent);
--pi-icon-size: 0.875rem;
}
.ts-card__key {
font-family: var(--ts-font-mono);
font-size: 0.75rem;
font-weight: 600;
color: var(--ts-ink-soft);
}
.ts-card__area {
margin-left: auto;
font-family: var(--ts-font-mono);
font-size: 0.625rem;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--ts-muted);
}
.ts-card__title {
margin: 0;
font-size: 0.9rem;
font-weight: 500;
line-height: 1.35;
color: var(--ts-ink);
}
.ts-card__meta {
display: inline-flex;
align-items: center;
gap: 0.25rem;
font-family: var(--ts-font-mono);
font-size: 0.6875rem;
color: var(--ts-muted);
white-space: nowrap;
}
.ts-card__spacer {
flex: 1;
}
.ts-card__who {
display: inline-grid;
place-items: center;
width: 1.5rem;
height: 1.5rem;
border-radius: 50%;
background: color-mix(in srgb, var(--ts-brand) 16%, var(--ts-surface));
color: color-mix(in srgb, var(--ts-brand) 70%, var(--ts-ink));
font-family: var(--ts-font-mono);
font-size: 0.5625rem;
font-weight: 600;
}
.ts-card__who--none {
background: transparent;
border: 1px dashed var(--ts-line-strong);
color: var(--ts-muted);
}
/* Priority as signal bars: as many lit bars as the level. */
.ts-signal {
display: inline-flex;
align-items: flex-end;
gap: 2px;
height: 0.75rem;
i {
width: 3px;
border-radius: 1px;
background: var(--ts-line-strong);
}
i:nth-child(1) {
height: 35%;
}
i:nth-child(2) {
height: 55%;
}
i:nth-child(3) {
height: 78%;
}
i:nth-child(4) {
height: 100%;
}
&[data-level='1'] i:nth-child(-n + 1),
&[data-level='2'] i:nth-child(-n + 2),
&[data-level='3'] i:nth-child(-n + 3) {
background: var(--ts-ink-soft);
}
&[data-level='4'] i {
background: var(--ts-s-failed);
}
}
`,
})
export class IssueCardComponent {
readonly issue = input.required<IssueSummary>();
protected readonly type = computed(() => TYPE[this.issue().type]);
protected readonly priority = computed(() => PRIORITY[this.issue().priority]);
protected readonly level = computed(
() => PRIORITY_LEVEL[this.issue().priority],
);
protected readonly areaLabel = (area: keyof typeof AREA) => AREA[area];
protected readonly initialsOf = initials;
}