Skip to content

Commit

Permalink
Type improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMDoerner committed Dec 12, 2024
1 parent 60a5312 commit 0f5c09b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
11 changes: 5 additions & 6 deletions src/app/campaign/pages/graph-page/graph-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import {
DEFAULT_SEARCH_PREFERENCES,
SidebarOption,
} from 'src/design/molecules';
import {
CategoryLabel,
GRAPH_CATEGORIES,
} from 'src/design/molecules/_models/search-preferences';
import { GraphMenuService } from 'src/design/organisms/graph/graph-menu.service';
import { GraphService } from 'src/design/organisms/graph/graph.service';
import { filterNil } from 'src/utils/rxjs-operators';
Expand Down Expand Up @@ -132,12 +136,7 @@ export class GraphPageComponent {
}),
);

private AVAILABLE_NODE_TYPES = new Set([
'Character',
'Item',
'Organization',
'Location',
]);
private AVAILABLE_NODE_TYPES = new Set<CategoryLabel>(GRAPH_CATEGORIES);
private nodeTypeOptions = DEFAULT_SEARCH_PREFERENCES.filter((option) =>
this.AVAILABLE_NODE_TYPES.has(option.label),
);
Expand Down
14 changes: 12 additions & 2 deletions src/design/molecules/_models/search-preferences.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface CategoryOption {
export interface ArticleCategory {
label: string;
active: boolean;
color: string;
Expand All @@ -17,4 +17,14 @@ export const DEFAULT_SEARCH_PREFERENCES = [
{ label: 'SessionAudio', active: false, color: '--sessionaudio-color' },
{ label: 'Rules', active: false, color: '--rules-color' },
{ label: 'Spell', active: false, color: '--spell-color' },
] as const satisfies CategoryOption[];
] as const satisfies ArticleCategory[];

export type CategoryLabel =
(typeof DEFAULT_SEARCH_PREFERENCES)[number]['label'];

export const GRAPH_CATEGORIES = [
'Character',
'Item',
'Organization',
'Location',
] as const satisfies CategoryLabel[];
2 changes: 1 addition & 1 deletion src/design/molecules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export { BadgeListEntry, BadgeListSelectOptions } from './_models/badge-list';
export { ListEntry } from './_models/list';
export {
DEFAULT_SEARCH_PREFERENCES,
CategoryOption as SidebarOption,
ArticleCategory as SidebarOption,
} from './_models/search-preferences';
export { ToggleState } from './_models/toggle';
export { ArticleFooterComponent } from './article-footer/article-footer.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@angular/core';
import { SelectableEntryComponent } from '../../atoms/selectable-entry/selectable-entry.component';
import {
CategoryOption,
ArticleCategory,
DEFAULT_SEARCH_PREFERENCES,
} from '../_models/search-preferences';

Expand All @@ -21,10 +21,10 @@ import {
})
export class SidebarLegendComponent {
interactable = input(false);
sidebarEntries = input<CategoryOption[]>(DEFAULT_SEARCH_PREFERENCES);
sidebarEntries = input<ArticleCategory[]>(DEFAULT_SEARCH_PREFERENCES);

@Output() sidebarChange: EventEmitter<CategoryOption[]> = new EventEmitter<
CategoryOption[]
@Output() sidebarChange: EventEmitter<ArticleCategory[]> = new EventEmitter<
ArticleCategory[]
>();

constructor() {}
Expand Down

0 comments on commit 0f5c09b

Please sign in to comment.