feat: delete unnecessary components
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
import { FONT_CATEGORIES } from './model/state';
|
import { FONT_CATEGORIES } from './model/state';
|
||||||
import { categoryFilterStore } from './store/categoryFilterStore';
|
import { categoryFilterStore } from './store/categoryFilterStore';
|
||||||
import CategoryFilter from './ui/CategoryFilter.svelte';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
CategoryFilter,
|
|
||||||
categoryFilterStore,
|
categoryFilterStore,
|
||||||
FONT_CATEGORIES,
|
FONT_CATEGORIES,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import type { FilterModel } from '$shared/store/createFilterStore';
|
import type {
|
||||||
|
Category,
|
||||||
|
FilterModel,
|
||||||
|
} from '$shared/store/createFilterStore';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model of state for CategoryFilter
|
* Model of state for CategoryFilter
|
||||||
*/
|
*/
|
||||||
export type CategoryFilterModel = FilterModel;
|
export type CategoryFilterModel = FilterModel;
|
||||||
|
|
||||||
export const FONT_CATEGORIES = [
|
export const FONT_CATEGORIES: Category[] = [
|
||||||
{
|
{
|
||||||
id: 'serif',
|
id: 'serif',
|
||||||
name: 'Serif',
|
name: 'Serif',
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { FONT_CATEGORIES } from '$entities/Font/model/font';
|
|
||||||
import { createFilterStore } from '$shared/store/createFilterStore';
|
import { createFilterStore } from '$shared/store/createFilterStore';
|
||||||
import type { CategoryFilterModel } from '../model/state';
|
import {
|
||||||
|
type CategoryFilterModel,
|
||||||
|
FONT_CATEGORIES,
|
||||||
|
} from '../model/state';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial state for CategoryFilter
|
* Initial state for CategoryFilter
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import CheckboxFilter from '$shared/ui/CheckboxFilter/CheckboxFilter.svelte';
|
|
||||||
import { categoryFilterStore } from '../store/categoryFilterStore';
|
|
||||||
|
|
||||||
const { categories } = $derived($categoryFilterStore);
|
|
||||||
|
|
||||||
function didCategoryToggle(categoryId: string) {
|
|
||||||
if (categories?.find(category => category.id === categoryId)?.selected) {
|
|
||||||
categoryFilterStore.deselectCategory(categoryId);
|
|
||||||
} else {
|
|
||||||
categoryFilterStore.selectCategory(categoryId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<CheckboxFilter
|
|
||||||
filterName="Font category"
|
|
||||||
categories={categories}
|
|
||||||
onCategoryToggle={didCategoryToggle}
|
|
||||||
/>
|
|
||||||
@@ -77,6 +77,12 @@ export interface FilterStore<T extends FilterModel> extends Writable<T> {
|
|||||||
* @param category - Category to deselect
|
* @param category - Category to deselect
|
||||||
*/
|
*/
|
||||||
deselectCategory: (categoryId: string) => void;
|
deselectCategory: (categoryId: string) => void;
|
||||||
|
/**
|
||||||
|
* Toggle a category.
|
||||||
|
*
|
||||||
|
* @param categoryId - Category ID
|
||||||
|
*/
|
||||||
|
toggleCategory: (categoryId: string) => void;
|
||||||
/**
|
/**
|
||||||
* Select all categories.
|
* Select all categories.
|
||||||
*/
|
*/
|
||||||
@@ -185,6 +191,19 @@ export function createFilterStore<T extends FilterModel>(
|
|||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Toggle a category.
|
||||||
|
*
|
||||||
|
* @param categoryId - Category ID
|
||||||
|
*/
|
||||||
|
toggleCategory: (categoryId: string) => {
|
||||||
|
update(state => ({
|
||||||
|
...state,
|
||||||
|
categories: state.categories.map(c =>
|
||||||
|
c.id === categoryId ? { ...c, selected: !c.selected } : c
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Select all categories
|
* Select all categories
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ const hasSelection = $derived(selectedCount > 0);
|
|||||||
class="border-t"
|
class="border-t"
|
||||||
>
|
>
|
||||||
<div class="px-4 py-3">
|
<div class="px-4 py-3">
|
||||||
<div class="flex flex-col gap-2.5">
|
<div class="flex flex-col gap-1.5">
|
||||||
<!-- Each item: checkbox + label with interactive hover/focus states -->
|
<!-- Each item: checkbox + label with interactive hover/focus states -->
|
||||||
<!-- Keyed by category.id for efficient DOM updates -->
|
<!-- Keyed by category.id for efficient DOM updates -->
|
||||||
{#each categories as category (category.id)}
|
{#each categories as category (category.id)}
|
||||||
|
|||||||
@@ -1,10 +1,31 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { CategoryFilter } from '$features/CategoryFilter';
|
import { categoryFilterStore } from '$features/CategoryFilter';
|
||||||
|
import { providersFilterStore } from '$features/ProvidersFilter';
|
||||||
|
import { subsetsFilterStore } from '$features/SubsetsFilter';
|
||||||
import * as Sidebar from '$shared/shadcn/ui/sidebar/index';
|
import * as Sidebar from '$shared/shadcn/ui/sidebar/index';
|
||||||
|
import CheckboxFilter from '$shared/ui/CheckboxFilter/CheckboxFilter.svelte';
|
||||||
|
|
||||||
|
const { categories: providers } = $derived($providersFilterStore);
|
||||||
|
const { categories: subsets } = $derived($subsetsFilterStore);
|
||||||
|
const { categories } = $derived($categoryFilterStore);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Sidebar.Root>
|
<Sidebar.Root>
|
||||||
<Sidebar.Content>
|
<Sidebar.Content>
|
||||||
<CategoryFilter />
|
<CheckboxFilter
|
||||||
|
filterName="Font provider"
|
||||||
|
categories={providers}
|
||||||
|
onCategoryToggle={providersFilterStore.toggleCategory}
|
||||||
|
/>
|
||||||
|
<CheckboxFilter
|
||||||
|
filterName="Font subset"
|
||||||
|
categories={subsets}
|
||||||
|
onCategoryToggle={subsetsFilterStore.toggleCategory}
|
||||||
|
/>
|
||||||
|
<CheckboxFilter
|
||||||
|
filterName="Font category"
|
||||||
|
categories={categories}
|
||||||
|
onCategoryToggle={categoryFilterStore.toggleCategory}
|
||||||
|
/>
|
||||||
</Sidebar.Content>
|
</Sidebar.Content>
|
||||||
</Sidebar.Root>
|
</Sidebar.Root>
|
||||||
|
|||||||
Reference in New Issue
Block a user