Merge branch 'feat/hud-bookmarks' into feat/hud-2d
This commit is contained in:
@@ -210,6 +210,21 @@ describe('HudDockComponent', () => {
|
|||||||
expect(host().querySelector('[aria-label="Forget Sirius"]')?.getAttribute('aria-pressed')).toBe('true');
|
expect(host().querySelector('[aria-label="Forget Sirius"]')?.getAttribute('aria-pressed')).toBe('true');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('keeps the one system whose catalogue id is zero, which truthiness would have lost', () => {
|
||||||
|
// The Sun is star 0. A `@if (id; as ...)` reads that as "no star" and hides the control.
|
||||||
|
const bookmarks = TestBed.inject(BookmarksStore);
|
||||||
|
setReadout();
|
||||||
|
fixture.componentRef.setInput('title', 'Sol');
|
||||||
|
fixture.componentRef.setInput('keepableStarId', 0);
|
||||||
|
fixture.componentRef.setInput('defaultTab', 'readout');
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
host().querySelector<HTMLButtonElement>('[aria-label="Keep Sol"]')?.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(bookmarks.has('star', 0)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('offers nothing to keep where the readout is a scale rather than a place', () => {
|
it('offers nothing to keep where the readout is a scale rather than a place', () => {
|
||||||
setReadout();
|
setReadout();
|
||||||
fixture.componentRef.setInput('defaultTab', 'readout');
|
fixture.componentRef.setInput('defaultTab', 'readout');
|
||||||
|
|||||||
@@ -94,16 +94,19 @@ function isWideViewport(): boolean {
|
|||||||
<p class="type-label text-muted">{{ eyebrow() }}</p>
|
<p class="type-label text-muted">{{ eyebrow() }}</p>
|
||||||
<div class="mt-1 flex items-start gap-2">
|
<div class="mt-1 flex items-start gap-2">
|
||||||
<p data-testid="hud-title" class="min-w-0 flex-1 text-lg font-bold tracking-[0.04em] text-text uppercase">{{ title() }}</p>
|
<p data-testid="hud-title" class="min-w-0 flex-1 text-lg font-bold tracking-[0.04em] text-text uppercase">{{ title() }}</p>
|
||||||
@if (keepableStarId(); as starId) {
|
<!-- Against null, not against falsiness: the Sun's catalogue id is 0, and a
|
||||||
|
truthiness test is what would quietly make the Solar System the one
|
||||||
|
system nobody could keep. -->
|
||||||
|
@if (keepableStarId() !== null) {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
[attr.aria-label]="(bookmarks.has('star', starId) ? 'Forget ' : 'Keep ') + title()"
|
[attr.aria-label]="(bookmarks.has('star', keepableStarId()!) ? 'Forget ' : 'Keep ') + title()"
|
||||||
[attr.aria-pressed]="bookmarks.has('star', starId)"
|
[attr.aria-pressed]="bookmarks.has('star', keepableStarId()!)"
|
||||||
(click)="bookmarks.toggle({ kind: 'star', id: starId, name: title() })"
|
(click)="bookmarks.toggle({ kind: 'star', id: keepableStarId()!, name: title() })"
|
||||||
class="shrink-0 p-1 transition-colors focus-visible:outline-1 focus-visible:-outline-offset-1 focus-visible:outline-accent"
|
class="shrink-0 p-1 transition-colors focus-visible:outline-1 focus-visible:-outline-offset-1 focus-visible:outline-accent"
|
||||||
[class]="bookmarks.has('star', starId) ? 'text-accent' : 'text-muted hover:text-accent'"
|
[class]="bookmarks.has('star', keepableStarId()!) ? 'text-accent' : 'text-muted hover:text-accent'"
|
||||||
>
|
>
|
||||||
<app-bookmark-icon class="h-3.5 w-3.5" [kept]="bookmarks.has('star', starId)" />
|
<app-bookmark-icon class="h-3.5 w-3.5" [kept]="bookmarks.has('star', keepableStarId()!)" />
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user