-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(libs): remove unused jsdom library * feat(home): add empty home page * feat(home): add unsorted sprouts list * feat(cultivating): add sprout details dialog component * feat(home): add a learn button to the home page * feat(home): add a button and dialog to add new seeds * feat(home): add last seeds list * feat(planting): remove old new seed component * feat(home, planting): add AddTermsButtonComponent that wraps both a button and a modal, use it also on planting page * fix(routing): fix wildcart redirect
- Loading branch information
1 parent
b9ebd9d
commit f5cbd8d
Showing
16 changed files
with
260 additions
and
528 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/app/cultivating/sprout-details-dialog/sprout-details-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ChangeDetectionStrategy, Component, inject, input, output } from '@angular/core'; | ||
|
||
import { BarnService } from '../../barn/barn.service'; | ||
import { DialogComponent } from '../../ui/dialog/dialog.component'; | ||
import { SproutDetailsComponent, type SproutDetailsSprout } from '../sprout-details/sprout-details.component'; | ||
|
||
@Component({ | ||
selector: 'app-sprout-details-dialog', | ||
template: ` | ||
<app-dialog (close)="close.emit()"> | ||
<app-sprout-details | ||
[sprout]="sprout()" | ||
(cancel)="close.emit()" | ||
(remove)="onRemoveSprout(sprout().id)" | ||
(update)="onUpdateSprout(sprout().id, $event)" | ||
/> | ||
</app-dialog> | ||
`, | ||
imports: [DialogComponent, SproutDetailsComponent], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class SproutDetailsDialogComponent { | ||
private barnService = inject(BarnService); | ||
|
||
sprout = input.required<SproutDetailsSprout>(); | ||
|
||
close = output(); | ||
|
||
onRemoveSprout(id: string) { | ||
this.barnService.removeSprout(id); | ||
this.close.emit(); | ||
} | ||
|
||
onUpdateSprout(id: string, value: Partial<SproutDetailsSprout>) { | ||
this.barnService.updateSprout(id, value); | ||
this.close.emit(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/app/home/add-terms-button/add-terms-button.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ChangeDetectionStrategy, Component, signal } from '@angular/core'; | ||
|
||
import { IconComponent } from '../../ui/icon/icon'; | ||
import { AddTermsDialogComponent } from '../add-terms-dialog/add-terms-dialog.component'; | ||
|
||
@Component({ | ||
selector: 'app-add-terms-button', | ||
template: ` | ||
<button class="fixed bottom-16 right-6" title="Add" (click)="showAddTermsDialog.set(true)"> | ||
<app-icon class="size-10 text-action-primary" name="plusInCircle" /> | ||
</button> | ||
@if (showAddTermsDialog()) { | ||
<app-add-terms-dialog (close)="showAddTermsDialog.set(false)" /> | ||
} | ||
`, | ||
imports: [IconComponent, AddTermsDialogComponent], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class AddTermsButtonComponent { | ||
showAddTermsDialog = signal(false); | ||
} |
56 changes: 56 additions & 0 deletions
56
src/app/home/add-terms-dialog/add-terms-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { ChangeDetectionStrategy, Component, inject, output, signal } from '@angular/core'; | ||
|
||
import { BarnService } from '../../barn/barn.service'; | ||
import { ButtonDirective } from '../../ui/button/button'; | ||
import { DialogComponent } from '../../ui/dialog/dialog.component'; | ||
import { InputDirective } from '../../ui/input/input'; | ||
|
||
@Component({ | ||
selector: 'app-add-terms-dialog', | ||
template: ` | ||
<app-dialog (close)="close.emit()"> | ||
<div class="flex h-full flex-col gap-8 pt-10"> | ||
<textarea | ||
class="grow" | ||
appInput | ||
placeholder="One seed a line" | ||
autocapitalize="off" | ||
[value]="newSeed()" | ||
(input)="updateSeed($event)" | ||
></textarea> | ||
<div class="mt-auto flex shrink-0 justify-end gap-4"> | ||
<button appButton (click)="close.emit()">Cancel</button> | ||
<button appButton appButtonType="primary" (click)="add()">Add</button> | ||
</div> | ||
</div> | ||
</app-dialog> | ||
`, | ||
imports: [DialogComponent, ButtonDirective, InputDirective], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class AddTermsDialogComponent { | ||
private barnService = inject(BarnService); | ||
|
||
close = output(); | ||
|
||
newSeed = signal(''); | ||
|
||
updateSeed(event: Event) { | ||
this.newSeed.set((event.target as HTMLTextAreaElement).value); | ||
} | ||
|
||
add() { | ||
const newSeeds = this.newSeed() | ||
.split('\n') | ||
.map(seed => seed.trim()) | ||
.filter(seed => !!seed); | ||
|
||
if (newSeeds.length !== 0) { | ||
this.barnService.addSeeds(newSeeds); | ||
} | ||
|
||
this.close.emit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
import { LearnCardsComponent } from '../learning/learn-cards.component'; | ||
import { AddTermsButtonComponent } from './add-terms-button/add-terms-button.component'; | ||
import { LastSeedsListComponent } from './last-seeds-list/last-seeds-list.component'; | ||
import { UnsortedSproutsComponent } from './unsorted-sprouts/unsorted-sprouts.component'; | ||
|
||
@Component({ | ||
selector: 'app-home-page', | ||
template: ` | ||
<div class="flex flex-col gap-4"> | ||
<app-unsorted-sprouts /> | ||
<app-learn-cards /> | ||
<app-last-seeds-list /> | ||
<app-add-terms-button /> | ||
</div> | ||
`, | ||
imports: [UnsortedSproutsComponent, LearnCardsComponent, AddTermsButtonComponent, LastSeedsListComponent], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class HomePageComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Routes } from '@angular/router'; | ||
|
||
export const homeRoutes: Routes = [ | ||
{ | ||
path: '', | ||
title: 'Akker', | ||
loadComponent: () => import('./home-page.component').then(m => m.HomePageComponent), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core'; | ||
|
||
import { BarnService } from '../../barn/barn.service'; | ||
|
||
@Component({ | ||
selector: 'app-last-seeds-list', | ||
template: ` | ||
<section> | ||
<h2 class="text-lg text-secondary">Last seeds</h2> | ||
<ul class="columns-2 gap-4"> | ||
@for (seed of lastAddedSeeds(); track seed.name) { | ||
<li class="w-full truncate px-2 py-1"> | ||
{{ seed.name }} | ||
</li> | ||
} | ||
</ul> | ||
</section> | ||
`, | ||
imports: [], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class LastSeedsListComponent { | ||
private barnService = inject(BarnService); | ||
|
||
lastAddedSeeds = computed(() => | ||
this.barnService | ||
.seeds() | ||
?.toSorted((a, b) => b.lastAddedAt.localeCompare(a.lastAddedAt)) | ||
.slice(0, lastSeedsCount), | ||
); | ||
} | ||
|
||
const lastSeedsCount = 10; |
44 changes: 44 additions & 0 deletions
44
src/app/home/unsorted-sprouts/unsorted-sprouts.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core'; | ||
|
||
import { BarnService } from '../../barn/barn.service'; | ||
import { SproutDetailsDialogComponent } from '../../cultivating/sprout-details-dialog/sprout-details-dialog.component'; | ||
import { type SproutDetailsSprout } from '../../cultivating/sprout-details/sprout-details.component'; | ||
|
||
@Component({ | ||
selector: 'app-unsorted-sprouts', | ||
template: ` | ||
@if (someUnsortedSprouts().length > 0) { | ||
<section class="min-w-0 flex-grow"> | ||
<h2 class="text-lg text-secondary">Unsorted sprouts ({{ unsortedSproutsAmount() }})</h2> | ||
<ul class="columns-2 gap-4"> | ||
@for (sprout of someUnsortedSprouts(); track sprout.id) { | ||
<li> | ||
<button class="w-full truncate px-2 py-1 text-left" (click)="sproutDetails.set(sprout)"> | ||
{{ sprout.term }} | ||
</button> | ||
</li> | ||
} | ||
</ul> | ||
</section> | ||
@if (sproutDetails(); as sprout) { | ||
<app-sprout-details-dialog [sprout]="sprout" (close)="sproutDetails.set(null)" /> | ||
} | ||
} | ||
`, | ||
imports: [SproutDetailsDialogComponent], | ||
standalone: true, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class UnsortedSproutsComponent { | ||
private barnService = inject(BarnService); | ||
private unsortedSprouts = computed(() => this.barnService.sprouts()?.filter(sprout => !sprout.definition)); | ||
|
||
unsortedSproutsAmount = computed(() => this.unsortedSprouts()?.length ?? 0); | ||
someUnsortedSprouts = computed(() => this.unsortedSprouts()?.slice(0, someUnsortedSproutsAmount) ?? []); | ||
|
||
sproutDetails = signal<SproutDetailsSprout | null>(null); | ||
} | ||
|
||
const someUnsortedSproutsAmount = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.