Skip to content

Commit

Permalink
fix: remove categories from catalog interface
Browse files Browse the repository at this point in the history
Signed-off-by: axel7083 <[email protected]>
  • Loading branch information
axel7083 committed Mar 7, 2024
1 parent b0ff03e commit ee82809
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 36 deletions.
1 change: 0 additions & 1 deletion packages/backend/src/managers/catalogManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class CatalogManager extends Publisher<Catalog> implements Disposable {
super(webview, MSG_NEW_CATALOG_STATE, () => this.getCatalog());
// We start with an empty catalog, for the methods to work before the catalog is loaded
this.catalog = {
categories: [],
models: [],
recipes: [],
};
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/src/lib/RecipeDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ vi.mock('../stores/localRepositories', () => ({
}));

const initialCatalog: Catalog = {
categories: [],
models: [
{
id: 'model1',
Expand Down
13 changes: 3 additions & 10 deletions packages/frontend/src/lib/RecipesCard.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<script lang="ts">
import Card from '/@/lib/Card.svelte';
import { getIcon } from '/@/utils/categoriesUtils';
import type { Category } from '@shared/src/models/ICategory';
import { catalog } from '/@/stores/catalog';
export let category: Category;
$: categories = $catalog.categories;
$: recipes = $catalog.recipes.filter(r => r.categories.includes(category.id)).map(r => ({ ...r, icon: category.id }));
$: recipes = $catalog.recipes;
export let primaryBackground: string = 'bg-charcoal-800';
export let secondaryBackground: string = 'bg-charcoal-700';
Expand All @@ -16,7 +12,7 @@ export let displayCategory: boolean = true;
export let displayDescription: boolean = true;
</script>

<Card title="{category.name}" classes="{primaryBackground} {$$props.class} text-xl font-medium mt-4">
<Card classes="{primaryBackground} {$$props.class} text-xl font-medium mt-4">
<div slot="content" class="w-full">
<div class="grid grid-cols-3 gap-4 mt-4">
{#if recipes.length === 0}
Expand All @@ -31,10 +27,7 @@ export let displayDescription: boolean = true;
<div slot="content" class="text-base font-normal mt-2">
{#if displayCategory}
{#each recipe.categories as categoryId}
<Card
title="{categories.find(category => category.id === categoryId)?.name || '?'}"
classes="{primaryBackground} p-1"
primaryBackground="{primaryBackground}" />
<Card title="{categoryId}" classes="{primaryBackground} p-1" primaryBackground="{primaryBackground}" />
{/each}
{/if}
{#if displayDescription}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ vi.mock('/@/stores/catalog', async () => {
});

const initialCatalog: Catalog = {
categories: [],
models: [
{
id: 'model1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ vi.mock('/@/utils/client', async () => {
});

const initialCatalog: Catalog = {
categories: [],
models: [],
recipes: [
{
Expand Down
2 changes: 0 additions & 2 deletions packages/frontend/src/pages/Recipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ vi.mock('/@/stores/catalog', async () => {
});

const initialCatalog: Catalog = {
categories: [],
models: [
{
id: 'model1',
Expand Down Expand Up @@ -123,7 +122,6 @@ const initialCatalog: Catalog = {
};

const updatedCatalog: Catalog = {
categories: [],
models: [
{
id: 'model1',
Expand Down
4 changes: 1 addition & 3 deletions packages/frontend/src/pages/Recipe.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ function setSelectedModel(modelId: string) {
<svelte:fragment slot="subtitle">
<div class="mt-2">
{#each recipe?.categories || [] as categoryId}
<Card
title="{categories.find(category => category.id === categoryId)?.name || '?'}"
classes="bg-charcoal-800 p-1 text-xs w-fit" />
<Card title="{categoryId}" classes="bg-charcoal-800 p-1 text-xs w-fit" />
{/each}
</div>
</svelte:fragment>
Expand Down
17 changes: 1 addition & 16 deletions packages/frontend/src/pages/Recipes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,13 @@ import NavPage from '/@/lib/NavPage.svelte';
import RecipesCard from '/@/lib/RecipesCard.svelte';
import { RECENT_CATEGORY_ID } from '/@/utils/client';
import { catalog } from '/@/stores/catalog';
$: categories = $catalog.categories;
</script>

<NavPage title="Recipe Catalog" searchEnabled="{false}">
<div slot="content" class="flex flex-col min-w-full min-h-full">
<div class="min-w-full min-h-full flex-1">
<div class="px-5 space-y-5 h-full">
<!-- Recent recipes -->
<RecipesCard
category="{{ id: RECENT_CATEGORY_ID, name: 'Recently-viewed recipes' }}"
class="p-6"
displayDescription="{false}" />

{#each categories as category}
<!-- Natural Language processing -->
<RecipesCard
category="{category}"
primaryBackground=""
secondaryBackground="bg-charcoal-800"
displayCategory="{false}" />
{/each}
<RecipesCard primaryBackground="" secondaryBackground="bg-charcoal-800" displayCategory="{false}" />
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/models/ICatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ import type { Recipe } from './IRecipe';
export interface Catalog {
recipes: Recipe[];
models: ModelInfo[];
categories: Category[];
}

0 comments on commit ee82809

Please sign in to comment.