tsconfig used jsx:"preserve"+jsxImportSource, which trips a TS 5.9
internal crash ("Expected sourceFile.imports[0] to be the synthesized JSX
runtime import") so tsc could never run clean. Switch to jsx:"react-jsx"
with the package's real jsx-runtime types, and fix the real errors that
surfaced:
- delete dead src/components/Navigation.tsx (imported ./Tab that doesn't
exist; the component has no importers)
- PlaybackControls: fix relative path to @/utils/audio-player
- SourceBadge: drop dead module-level typeColor (bare 'theme')
- command palette: bind to the real 'command' keybind (:) instead of the
never-defined 'command_list' action (palette was unreachable)
- yazi-pane-row test: destroy() must return Promise<void> as typed
Also fold in the package.json lint fix (bun tsc --noEmit) and doc polish.
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { SourceType } from "@/types/source";
|
|
import { useTheme } from "@/context/ThemeContext";
|
|
|
|
type SourceBadgeProps = {
|
|
sourceId: string;
|
|
sourceName?: string;
|
|
sourceType?: SourceType;
|
|
};
|
|
|
|
const typeLabel = (sourceType?: SourceType) => {
|
|
if (sourceType === SourceType.API) return "API";
|
|
if (sourceType === SourceType.RSS) return "RSS";
|
|
if (sourceType === SourceType.CUSTOM) return "Custom";
|
|
return "Source";
|
|
};
|
|
|
|
// No module-level typeColor here — it needs the theme from the component.
|
|
// The correct definition lives inside SourceBadge below.
|
|
export function SourceBadge(props: SourceBadgeProps) {
|
|
const { theme } = useTheme();
|
|
const label = () => props.sourceName || props.sourceId;
|
|
|
|
const typeColor = (sourceType?: SourceType) => {
|
|
if (sourceType === SourceType.API) return theme.primary;
|
|
if (sourceType === SourceType.RSS) return theme.success;
|
|
if (sourceType === SourceType.CUSTOM) return theme.warning;
|
|
return theme.textMuted;
|
|
};
|
|
|
|
return (
|
|
<box flexDirection="row" gap={1} padding={0}>
|
|
<text fg={typeColor(props.sourceType)}>
|
|
[{typeLabel(props.sourceType)}]
|
|
</text>
|
|
<text fg={theme.textMuted}>{label()}</text>
|
|
</box>
|
|
);
|
|
}
|