use of selectable
This commit is contained in:
@@ -6,14 +6,12 @@ export function SelectableBox({
|
|||||||
selected,
|
selected,
|
||||||
children,
|
children,
|
||||||
...props
|
...props
|
||||||
}: {
|
}: { selected: () => boolean; children: JSXElement } & BoxOptions) {
|
||||||
selected: () => boolean;
|
|
||||||
children: JSXElement;
|
|
||||||
} & BoxOptions) {
|
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box
|
<box
|
||||||
|
border={!!props.border}
|
||||||
borderColor={selected() ? theme.surface : theme.border}
|
borderColor={selected() ? theme.surface : theme.border}
|
||||||
backgroundColor={selected() ? theme.primary : theme.surface}
|
backgroundColor={selected() ? theme.primary : theme.surface}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { useDiscoverStore, DISCOVER_CATEGORIES } from "@/stores/discover";
|
|||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
import { PodcastCard } from "./PodcastCard";
|
import { PodcastCard } from "./PodcastCard";
|
||||||
import { PageProps } from "@/App";
|
import { PageProps } from "@/App";
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
|
||||||
enum DiscoverPagePaneType {
|
enum DiscoverPagePaneType {
|
||||||
CATEGORIES = 1,
|
CATEGORIES = 1,
|
||||||
@@ -54,26 +55,28 @@ export function DiscoverPage(props: PageProps) {
|
|||||||
>
|
>
|
||||||
Categories:
|
Categories:
|
||||||
</text>
|
</text>
|
||||||
<box flexDirection="column" gap={1}>
|
<box flexDirection="column" gap={1}>
|
||||||
<For each={discoverStore.categories}>
|
<For each={discoverStore.categories}>
|
||||||
{(category) => {
|
{(category) => {
|
||||||
const isSelected = () =>
|
const isSelected = () =>
|
||||||
discoverStore.selectedCategory() === category.id;
|
discoverStore.selectedCategory() === category.id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box
|
<SelectableBox
|
||||||
border={isSelected()}
|
selected={isSelected}
|
||||||
backgroundColor={isSelected() ? theme.accent : undefined}
|
onMouseDown={() => handleCategorySelect(category.id)}
|
||||||
onMouseDown={() => handleCategorySelect(category.id)}
|
>
|
||||||
>
|
<SelectableText
|
||||||
<text fg={isSelected() ? theme.primary : theme.textMuted}>
|
selected={isSelected}
|
||||||
{category.icon} {category.name}
|
fg={theme.primary}
|
||||||
</text>
|
>
|
||||||
</box>
|
{category.icon} {category.name}
|
||||||
);
|
</SelectableText>
|
||||||
}}
|
</SelectableBox>
|
||||||
</For>
|
);
|
||||||
</box>
|
}}
|
||||||
|
</For>
|
||||||
|
</box>
|
||||||
</box>
|
</box>
|
||||||
<box
|
<box
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import { Show, For } from "solid-js";
|
import { Show, For } from "solid-js";
|
||||||
import type { Podcast } from "@/types/podcast";
|
import type { Podcast } from "@/types/podcast";
|
||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
|
||||||
type PodcastCardProps = {
|
type PodcastCardProps = {
|
||||||
podcast: Podcast;
|
podcast: Podcast;
|
||||||
@@ -21,59 +22,64 @@ export function PodcastCard(props: PodcastCardProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box
|
<SelectableBox
|
||||||
|
selected={() => props.selected}
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
padding={1}
|
padding={1}
|
||||||
backgroundColor={props.selected ? theme.backgroundElement : undefined}
|
|
||||||
onMouseDown={props.onSelect}
|
onMouseDown={props.onSelect}
|
||||||
>
|
>
|
||||||
{/* Title Row */}
|
|
||||||
<box flexDirection="row" gap={2} alignItems="center">
|
<box flexDirection="row" gap={2} alignItems="center">
|
||||||
<text fg={props.selected ? theme.primary : theme.text}>
|
<SelectableText selected={() => props.selected}>
|
||||||
<strong>{props.podcast.title}</strong>
|
<strong>{props.podcast.title}</strong>
|
||||||
</text>
|
</SelectableText>
|
||||||
|
|
||||||
<Show when={props.podcast.isSubscribed}>
|
<Show when={props.podcast.isSubscribed}>
|
||||||
<text fg={theme.success}>[+]</text>
|
<text fg={theme.success}>[+]</text>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
{/* Author */}
|
{/* Author */}
|
||||||
<Show when={props.podcast.author && !props.compact}>
|
<Show when={props.podcast.author && !props.compact}>
|
||||||
<text fg={theme.textMuted}>by {props.podcast.author}</text>
|
<SelectableText
|
||||||
|
selected={() => props.selected}
|
||||||
|
fg={theme.textMuted}
|
||||||
|
>
|
||||||
|
by {props.podcast.author}
|
||||||
|
</SelectableText>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
{/* Description */}
|
{/* Description */}
|
||||||
<Show when={props.podcast.description && !props.compact}>
|
<Show when={props.podcast.description && !props.compact}>
|
||||||
<text fg={props.selected ? theme.text : theme.textMuted}>
|
<SelectableText
|
||||||
|
selected={() => props.selected}
|
||||||
|
fg={theme.text}
|
||||||
|
>
|
||||||
{props.podcast.description!.length > 80
|
{props.podcast.description!.length > 80
|
||||||
? props.podcast.description!.slice(0, 80) + "..."
|
? props.podcast.description!.slice(0, 80) + "..."
|
||||||
: props.podcast.description}
|
: props.podcast.description}
|
||||||
</text>
|
</SelectableText>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
{/* Categories and Subscribe Button */}
|
{/**<box
|
||||||
<box
|
|
||||||
flexDirection="row"
|
flexDirection="row"
|
||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
marginTop={props.compact ? 0 : 1}
|
marginTop={props.compact ? 0 : 1}
|
||||||
>
|
/>**/}
|
||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
<Show when={(props.podcast.categories ?? []).length > 0}>
|
<Show when={(props.podcast.categories ?? []).length > 0}>
|
||||||
<For each={(props.podcast.categories ?? []).slice(0, 2)}>
|
<For each={(props.podcast.categories ?? []).slice(0, 2)}>
|
||||||
{(cat) => <text fg={theme.warning}>[{cat}]</text>}
|
{(cat) => <text fg={theme.warning}>[{cat}]</text>}
|
||||||
</For>
|
</For>
|
||||||
</Show>
|
|
||||||
</box>
|
|
||||||
|
|
||||||
<Show when={props.selected}>
|
|
||||||
<box onMouseDown={handleSubscribeClick}>
|
|
||||||
<text fg={props.podcast.isSubscribed ? theme.error : theme.success}>
|
|
||||||
{props.podcast.isSubscribed ? "[Unsubscribe]" : "[Subscribe]"}
|
|
||||||
</text>
|
|
||||||
</box>
|
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
|
||||||
|
<Show when={props.selected}>
|
||||||
|
<box onMouseDown={handleSubscribeClick}>
|
||||||
|
<text fg={props.podcast.isSubscribed ? theme.error : theme.success}>
|
||||||
|
{props.podcast.isSubscribed ? "[Unsubscribe]" : "[Subscribe]"}
|
||||||
|
</text>
|
||||||
|
</box>
|
||||||
|
</Show>
|
||||||
|
</SelectableBox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import type { Feed } from "@/types/feed";
|
|||||||
import type { Episode } from "@/types/episode";
|
import type { Episode } from "@/types/episode";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
|
||||||
interface FeedDetailProps {
|
interface FeedDetailProps {
|
||||||
feed: Feed;
|
feed: Feed;
|
||||||
@@ -139,11 +140,11 @@ export function FeedDetail(props: FeedDetailProps) {
|
|||||||
<scrollbox height={showInfo() ? 10 : 15} focused={props.focused}>
|
<scrollbox height={showInfo() ? 10 : 15} focused={props.focused}>
|
||||||
<For each={episodes()}>
|
<For each={episodes()}>
|
||||||
{(episode, index) => (
|
{(episode, index) => (
|
||||||
<box
|
<SelectableBox
|
||||||
|
selected={() => index() === selectedIndex()}
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
gap={0}
|
gap={0}
|
||||||
padding={1}
|
padding={1}
|
||||||
backgroundColor={index() === selectedIndex() ? theme.backgroundElement : undefined}
|
|
||||||
onMouseDown={() => {
|
onMouseDown={() => {
|
||||||
setSelectedIndex(index());
|
setSelectedIndex(index());
|
||||||
if (props.onPlayEpisode) {
|
if (props.onPlayEpisode) {
|
||||||
@@ -151,20 +152,24 @@ export function FeedDetail(props: FeedDetailProps) {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<box flexDirection="row" gap={1}>
|
<SelectableText
|
||||||
<text fg={index() === selectedIndex() ? theme.primary : theme.textMuted}>
|
selected={() => index() === selectedIndex()}
|
||||||
{index() === selectedIndex() ? ">" : " "}
|
fg={theme.primary}
|
||||||
</text>
|
>
|
||||||
<text fg={index() === selectedIndex() ? theme.text : undefined}>
|
{index() === selectedIndex() ? ">" : " "}
|
||||||
{episode.episodeNumber ? `#${episode.episodeNumber} - ` : ""}
|
</SelectableText>
|
||||||
{episode.title}
|
<SelectableText
|
||||||
</text>
|
selected={() => index() === selectedIndex()}
|
||||||
</box>
|
fg={theme.text}
|
||||||
|
>
|
||||||
|
{episode.episodeNumber ? `#${episode.episodeNumber} - ` : ""}
|
||||||
|
{episode.title}
|
||||||
|
</SelectableText>
|
||||||
<box flexDirection="row" gap={2} paddingLeft={2}>
|
<box flexDirection="row" gap={2} paddingLeft={2}>
|
||||||
<text fg={theme.textMuted}>{formatDate(episode.pubDate)}</text>
|
<text fg={theme.textMuted}>{formatDate(episode.pubDate)}</text>
|
||||||
<text fg={theme.textMuted}>{formatDuration(episode.duration)}</text>
|
<text fg={theme.textMuted}>{formatDuration(episode.duration)}</text>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</SelectableBox>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
</scrollbox>
|
</scrollbox>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import type { Feed, FeedVisibility } from "@/types/feed";
|
import type { Feed, FeedVisibility } from "@/types/feed";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
|
||||||
interface FeedItemProps {
|
interface FeedItemProps {
|
||||||
feed: Feed;
|
feed: Feed;
|
||||||
@@ -43,70 +44,111 @@ export function FeedItem(props: FeedItemProps) {
|
|||||||
if (props.compact) {
|
if (props.compact) {
|
||||||
// Compact single-line view
|
// Compact single-line view
|
||||||
return (
|
return (
|
||||||
<box
|
<SelectableBox
|
||||||
|
selected={() => props.isSelected}
|
||||||
flexDirection="row"
|
flexDirection="row"
|
||||||
gap={1}
|
gap={1}
|
||||||
backgroundColor={props.isSelected ? theme.backgroundElement : undefined}
|
|
||||||
paddingLeft={1}
|
paddingLeft={1}
|
||||||
paddingRight={1}
|
paddingRight={1}
|
||||||
|
onMouseDown={() => {}}
|
||||||
>
|
>
|
||||||
<text fg={props.isSelected ? theme.primary : theme.textMuted}>
|
<SelectableText
|
||||||
|
selected={() => props.isSelected}
|
||||||
|
fg={theme.primary}
|
||||||
|
>
|
||||||
{props.isSelected ? ">" : " "}
|
{props.isSelected ? ">" : " "}
|
||||||
</text>
|
</SelectableText>
|
||||||
<text fg={visibilityColor()}>{visibilityIcon()}</text>
|
<SelectableText
|
||||||
<text fg={props.isSelected ? theme.text : theme.accent}>
|
selected={() => props.isSelected}
|
||||||
|
fg={visibilityColor()}
|
||||||
|
>
|
||||||
|
{visibilityIcon()}
|
||||||
|
</SelectableText>
|
||||||
|
<SelectableText
|
||||||
|
selected={() => props.isSelected}
|
||||||
|
fg={theme.text}
|
||||||
|
>
|
||||||
{props.feed.customName || props.feed.podcast.title}
|
{props.feed.customName || props.feed.podcast.title}
|
||||||
</text>
|
</SelectableText>
|
||||||
{props.showEpisodeCount && (
|
{props.showEpisodeCount && (
|
||||||
<text fg={theme.textMuted}>({episodeCount()})</text>
|
<SelectableText
|
||||||
|
selected={() => props.isSelected}
|
||||||
|
fg={theme.textMuted}
|
||||||
|
>
|
||||||
|
({episodeCount()})
|
||||||
|
</SelectableText>
|
||||||
)}
|
)}
|
||||||
</box>
|
</SelectableBox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full view with details
|
// Full view with details
|
||||||
return (
|
return (
|
||||||
<box
|
<SelectableBox
|
||||||
|
selected={() => props.isSelected}
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
gap={0}
|
gap={0}
|
||||||
border={props.isSelected}
|
|
||||||
borderColor={props.isSelected ? theme.primary : undefined}
|
|
||||||
backgroundColor={props.isSelected ? theme.primary : undefined}
|
|
||||||
padding={1}
|
padding={1}
|
||||||
|
onMouseDown={() => {}}
|
||||||
>
|
>
|
||||||
{/* Title row */}
|
{/* Title row */}
|
||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
<text fg={props.isSelected ? theme.primary : theme.textMuted}>
|
<SelectableText
|
||||||
|
selected={() => props.isSelected}
|
||||||
|
fg={theme.primary}
|
||||||
|
>
|
||||||
{props.isSelected ? ">" : " "}
|
{props.isSelected ? ">" : " "}
|
||||||
</text>
|
</SelectableText>
|
||||||
<text fg={visibilityColor()}>{visibilityIcon()}</text>
|
<SelectableText
|
||||||
<text fg={theme.warning}>{pinnedIndicator()}</text>
|
selected={() => props.isSelected}
|
||||||
<text fg={props.isSelected ? theme.text : theme.text}>
|
fg={visibilityColor()}
|
||||||
|
>
|
||||||
|
{visibilityIcon()}
|
||||||
|
</SelectableText>
|
||||||
|
<SelectableText
|
||||||
|
selected={() => props.isSelected}
|
||||||
|
fg={theme.warning}
|
||||||
|
>
|
||||||
|
{pinnedIndicator()}
|
||||||
|
</SelectableText>
|
||||||
|
<SelectableText
|
||||||
|
selected={() => props.isSelected}
|
||||||
|
fg={theme.text}
|
||||||
|
>
|
||||||
<strong>{props.feed.customName || props.feed.podcast.title}</strong>
|
<strong>{props.feed.customName || props.feed.podcast.title}</strong>
|
||||||
</text>
|
</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<box flexDirection="row" gap={2} paddingLeft={4}>
|
<box flexDirection="row" gap={2} paddingLeft={4}>
|
||||||
{props.showEpisodeCount && (
|
{props.showEpisodeCount && (
|
||||||
<text fg={theme.textMuted}>
|
<SelectableText
|
||||||
|
selected={() => props.isSelected}
|
||||||
|
fg={theme.textMuted}
|
||||||
|
>
|
||||||
{episodeCount()} episodes ({unplayedCount()} new)
|
{episodeCount()} episodes ({unplayedCount()} new)
|
||||||
</text>
|
</SelectableText>
|
||||||
)}
|
)}
|
||||||
{props.showLastUpdated && (
|
{props.showLastUpdated && (
|
||||||
<text fg={theme.textMuted}>
|
<SelectableText
|
||||||
|
selected={() => props.isSelected}
|
||||||
|
fg={theme.textMuted}
|
||||||
|
>
|
||||||
Updated: {formatDate(props.feed.lastUpdated)}
|
Updated: {formatDate(props.feed.lastUpdated)}
|
||||||
</text>
|
</SelectableText>
|
||||||
)}
|
)}
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
{props.feed.podcast.description && (
|
{props.feed.podcast.description && (
|
||||||
<box paddingLeft={4} paddingTop={0}>
|
<SelectableText
|
||||||
<text fg={theme.textMuted}>
|
selected={() => props.isSelected}
|
||||||
{props.feed.podcast.description.slice(0, 60)}
|
paddingLeft={4}
|
||||||
{props.feed.podcast.description.length > 60 ? "..." : ""}
|
paddingTop={0}
|
||||||
</text>
|
fg={theme.textMuted}
|
||||||
</box>
|
>
|
||||||
|
{props.feed.podcast.description.slice(0, 60)}
|
||||||
|
{props.feed.podcast.description.length > 60 ? "..." : ""}
|
||||||
|
</SelectableText>
|
||||||
)}
|
)}
|
||||||
</box>
|
</SelectableBox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type { Episode } from "@/types/episode";
|
|||||||
import type { Feed } from "@/types/feed";
|
import type { Feed } from "@/types/feed";
|
||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
import { PageProps } from "@/App";
|
import { PageProps } from "@/App";
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
|
||||||
enum FeedPaneType {
|
enum FeedPaneType {
|
||||||
FEED = 1,
|
FEED = 1,
|
||||||
@@ -27,6 +28,18 @@ export function FeedPage(props: PageProps) {
|
|||||||
return format(date, "MMM d, yyyy");
|
return format(date, "MMM d, yyyy");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const episodesByDate = () => {
|
||||||
|
const groups: Record<string, { episode: Episode; feed: Feed }> = {};
|
||||||
|
const sortedEpisodes = allEpisodes();
|
||||||
|
|
||||||
|
for (const episode of sortedEpisodes) {
|
||||||
|
const dateKey = formatDate(new Date(episode.episode.pubDate));
|
||||||
|
groups[dateKey] = episode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
};
|
||||||
|
|
||||||
const formatDuration = (seconds: number): string => {
|
const formatDuration = (seconds: number): string => {
|
||||||
const mins = Math.floor(seconds / 60);
|
const mins = Math.floor(seconds / 60);
|
||||||
const hrs = Math.floor(mins / 60);
|
const hrs = Math.floor(mins / 60);
|
||||||
@@ -63,36 +76,43 @@ export function FeedPage(props: PageProps) {
|
|||||||
</box>
|
</box>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{/**TODO: figure out wtf to do here **/}
|
<scrollbox height="100%" focused={props.depth() == FeedPaneType.FEED}>
|
||||||
<scrollbox height="100%" focused={props.depth() == FeedPaneType.FEED}>
|
<For each={Object.entries(episodesByDate()).sort(([a], [b]) => b.localeCompare(a))}>
|
||||||
<For each={allEpisodes()}>
|
{([date, episode], groupIndex) => (
|
||||||
{(item, index) => (
|
<>
|
||||||
<box
|
<box flexDirection="column" gap={0} paddingLeft={1} paddingRight={1} paddingTop={1} paddingBottom={1}>
|
||||||
flexDirection="column"
|
<text fg={theme.primary}>{date}</text>
|
||||||
gap={0}
|
|
||||||
paddingLeft={1}
|
|
||||||
paddingRight={1}
|
|
||||||
paddingTop={0}
|
|
||||||
paddingBottom={0}
|
|
||||||
backgroundColor={
|
|
||||||
index() === selectedIndex() ? theme.backgroundElement : undefined
|
|
||||||
}
|
|
||||||
onMouseDown={() => setSelectedIndex(index())}
|
|
||||||
>
|
|
||||||
<box flexDirection="row" gap={1}>
|
|
||||||
<text fg={index() === selectedIndex() ? theme.primary : theme.textMuted}>
|
|
||||||
{index() === selectedIndex() ? ">" : " "}
|
|
||||||
</text>
|
|
||||||
<text fg={index() === selectedIndex() ? theme.text : theme.text}>
|
|
||||||
{item.episode.title}
|
|
||||||
</text>
|
|
||||||
</box>
|
</box>
|
||||||
<box flexDirection="row" gap={2} paddingLeft={2}>
|
<SelectableBox
|
||||||
<text fg={theme.primary}>{item.feed.podcast.title}</text>
|
selected={() => groupIndex() === selectedIndex()}
|
||||||
<text fg={theme.textMuted}>{formatDate(item.episode.pubDate)}</text>
|
flexDirection="column"
|
||||||
<text fg={theme.textMuted}>{formatDuration(item.episode.duration)}</text>
|
gap={0}
|
||||||
</box>
|
paddingLeft={1}
|
||||||
</box>
|
paddingRight={1}
|
||||||
|
paddingTop={0}
|
||||||
|
paddingBottom={0}
|
||||||
|
onMouseDown={() => setSelectedIndex(groupIndex())}
|
||||||
|
>
|
||||||
|
<SelectableText selected={() => groupIndex() === selectedIndex()}>
|
||||||
|
{groupIndex() === selectedIndex() ? ">" : " "}
|
||||||
|
</SelectableText>
|
||||||
|
<SelectableText
|
||||||
|
selected={() => groupIndex() === selectedIndex()}
|
||||||
|
fg={theme.text}
|
||||||
|
>
|
||||||
|
{episode.episode.title}
|
||||||
|
</SelectableText>
|
||||||
|
<box flexDirection="row" gap={2} paddingLeft={2}>
|
||||||
|
<text fg={theme.primary}>{episode.feed.podcast.title}</text>
|
||||||
|
<text fg={theme.textMuted}>
|
||||||
|
{formatDate(episode.episode.pubDate)}
|
||||||
|
</text>
|
||||||
|
<text fg={theme.textMuted}>
|
||||||
|
{formatDuration(episode.episode.duration)}
|
||||||
|
</text>
|
||||||
|
</box>
|
||||||
|
</SelectableBox>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
</scrollbox>
|
</scrollbox>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Show } from "solid-js";
|
|||||||
import type { SearchResult } from "@/types/source";
|
import type { SearchResult } from "@/types/source";
|
||||||
import { SourceBadge } from "./SourceBadge";
|
import { SourceBadge } from "./SourceBadge";
|
||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
|
||||||
type ResultCardProps = {
|
type ResultCardProps = {
|
||||||
result: SearchResult;
|
result: SearchResult;
|
||||||
@@ -15,12 +16,10 @@ export function ResultCard(props: ResultCardProps) {
|
|||||||
const podcast = () => props.result.podcast;
|
const podcast = () => props.result.podcast;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box
|
<SelectableBox
|
||||||
|
selected={() => props.selected}
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
padding={1}
|
padding={1}
|
||||||
border={props.selected}
|
|
||||||
borderColor={props.selected ? theme.primary : undefined}
|
|
||||||
backgroundColor={props.selected ? theme.backgroundElement : undefined}
|
|
||||||
onMouseDown={props.onSelect}
|
onMouseDown={props.onSelect}
|
||||||
>
|
>
|
||||||
<box
|
<box
|
||||||
@@ -29,9 +28,12 @@ export function ResultCard(props: ResultCardProps) {
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<box flexDirection="row" gap={2} alignItems="center">
|
<box flexDirection="row" gap={2} alignItems="center">
|
||||||
<text fg={props.selected ? theme.primary : theme.text}>
|
<SelectableText
|
||||||
|
selected={() => props.selected}
|
||||||
|
fg={theme.primary}
|
||||||
|
>
|
||||||
<strong>{podcast().title}</strong>
|
<strong>{podcast().title}</strong>
|
||||||
</text>
|
</SelectableText>
|
||||||
<SourceBadge
|
<SourceBadge
|
||||||
sourceId={props.result.sourceId}
|
sourceId={props.result.sourceId}
|
||||||
sourceName={props.result.sourceName}
|
sourceName={props.result.sourceName}
|
||||||
@@ -44,16 +46,24 @@ export function ResultCard(props: ResultCardProps) {
|
|||||||
</box>
|
</box>
|
||||||
|
|
||||||
<Show when={podcast().author}>
|
<Show when={podcast().author}>
|
||||||
<text fg={theme.textMuted}>by {podcast().author}</text>
|
<SelectableText
|
||||||
|
selected={() => props.selected}
|
||||||
|
fg={theme.textMuted}
|
||||||
|
>
|
||||||
|
by {podcast().author}
|
||||||
|
</SelectableText>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show when={podcast().description}>
|
<Show when={podcast().description}>
|
||||||
{(description) => (
|
{(description) => (
|
||||||
<text fg={props.selected ? theme.text : theme.textMuted}>
|
<SelectableText
|
||||||
|
selected={() => props.selected}
|
||||||
|
fg={theme.text}
|
||||||
|
>
|
||||||
{description().length > 120
|
{description().length > 120
|
||||||
? description().slice(0, 120) + "..."
|
? description().slice(0, 120) + "..."
|
||||||
: description()}
|
: description()}
|
||||||
</text>
|
</SelectableText>
|
||||||
)}
|
)}
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
@@ -80,6 +90,6 @@ export function ResultCard(props: ResultCardProps) {
|
|||||||
<text fg={theme.primary}>[+] Add to Feeds</text>
|
<text fg={theme.primary}>[+] Add to Feeds</text>
|
||||||
</box>
|
</box>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</SelectableBox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import { For, Show } from "solid-js"
|
import { For, Show } from "solid-js"
|
||||||
import { useTheme } from "@/context/ThemeContext"
|
import { useTheme } from "@/context/ThemeContext"
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable"
|
||||||
|
|
||||||
type SearchHistoryProps = {
|
type SearchHistoryProps = {
|
||||||
history: string[]
|
history: string[]
|
||||||
@@ -52,23 +53,31 @@ export function SearchHistory(props: SearchHistoryProps) {
|
|||||||
const isSelected = () => index() === props.selectedIndex && props.focused
|
const isSelected = () => index() === props.selectedIndex && props.focused
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box
|
<SelectableBox
|
||||||
|
selected={isSelected}
|
||||||
flexDirection="row"
|
flexDirection="row"
|
||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
padding={0}
|
padding={0}
|
||||||
paddingLeft={1}
|
paddingLeft={1}
|
||||||
paddingRight={1}
|
paddingRight={1}
|
||||||
backgroundColor={isSelected() ? theme.backgroundElement : undefined}
|
|
||||||
onMouseDown={() => handleSearchClick(index(), query)}
|
onMouseDown={() => handleSearchClick(index(), query)}
|
||||||
>
|
>
|
||||||
<box flexDirection="row" gap={1}>
|
<SelectableText
|
||||||
<text fg={theme.textMuted}>{">"}</text>
|
selected={isSelected}
|
||||||
<text fg={isSelected() ? theme.primary : theme.text}>{query}</text>
|
fg={theme.textMuted}
|
||||||
</box>
|
>
|
||||||
|
{">"}
|
||||||
|
</SelectableText>
|
||||||
|
<SelectableText
|
||||||
|
selected={isSelected}
|
||||||
|
fg={theme.primary}
|
||||||
|
>
|
||||||
|
{query}
|
||||||
|
</SelectableText>
|
||||||
<box onMouseDown={() => handleRemoveClick(query)} padding={0}>
|
<box onMouseDown={() => handleRemoveClick(query)} padding={0}>
|
||||||
<text fg={theme.error}>[x]</text>
|
<text fg={theme.error}>[x]</text>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</SelectableBox>
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</For>
|
</For>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { useFeedStore } from "@/stores/feed";
|
|||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
import { SourceType } from "@/types/source";
|
import { SourceType } from "@/types/source";
|
||||||
import type { PodcastSource } from "@/types/source";
|
import type { PodcastSource } from "@/types/source";
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
|
||||||
interface SourceManagerProps {
|
interface SourceManagerProps {
|
||||||
focused?: boolean;
|
focused?: boolean;
|
||||||
@@ -183,24 +184,20 @@ export function SourceManager(props: SourceManagerProps) {
|
|||||||
<text fg={focusArea() === "list" ? theme.primary : theme.textMuted}>
|
<text fg={focusArea() === "list" ? theme.primary : theme.textMuted}>
|
||||||
Sources:
|
Sources:
|
||||||
</text>
|
</text>
|
||||||
<scrollbox height={6}>
|
<scrollbox height={6}>
|
||||||
<For each={sources()}>
|
<For each={sources()}>
|
||||||
{(source, index) => (
|
{(source, index) => (
|
||||||
<box
|
<SelectableBox
|
||||||
flexDirection="row"
|
selected={() => focusArea() === "list" && index() === selectedIndex()}
|
||||||
gap={1}
|
flexDirection="row"
|
||||||
padding={0}
|
gap={1}
|
||||||
backgroundColor={
|
padding={0}
|
||||||
focusArea() === "list" && index() === selectedIndex()
|
onMouseDown={() => {
|
||||||
? theme.primary
|
setSelectedIndex(index());
|
||||||
: undefined
|
setFocusArea("list");
|
||||||
}
|
feedStore.toggleSource(source.id);
|
||||||
onMouseDown={() => {
|
}}
|
||||||
setSelectedIndex(index());
|
>
|
||||||
setFocusArea("list");
|
|
||||||
feedStore.toggleSource(source.id);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<text
|
<text
|
||||||
fg={
|
fg={
|
||||||
focusArea() === "list" && index() === selectedIndex()
|
focusArea() === "list" && index() === selectedIndex()
|
||||||
@@ -212,20 +209,13 @@ export function SourceManager(props: SourceManagerProps) {
|
|||||||
? ">"
|
? ">"
|
||||||
: " "}
|
: " "}
|
||||||
</text>
|
</text>
|
||||||
<text fg={source.enabled ? theme.success : theme.error}>
|
<SelectableText
|
||||||
{source.enabled ? "[x]" : "[ ]"}
|
selected={() => focusArea() === "list" && index() === selectedIndex()}
|
||||||
</text>
|
fg={theme.text}
|
||||||
<text fg={theme.accent}>{getSourceIcon(source)}</text>
|
|
||||||
<text
|
|
||||||
fg={
|
|
||||||
focusArea() === "list" && index() === selectedIndex()
|
|
||||||
? theme.text
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{source.name}
|
{source.name}
|
||||||
</text>
|
</SelectableText>
|
||||||
</box>
|
</SelectableBox>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
</scrollbox>
|
</scrollbox>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { useDialog } from "./dialog";
|
|||||||
import { useTheme } from "../context/ThemeContext";
|
import { useTheme } from "../context/ThemeContext";
|
||||||
import { TextAttributes } from "@opentui/core";
|
import { TextAttributes } from "@opentui/core";
|
||||||
import { emit } from "../utils/event-bus";
|
import { emit } from "../utils/event-bus";
|
||||||
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command option for the command palette.
|
* Command option for the command palette.
|
||||||
@@ -281,37 +282,53 @@ function CommandDialog(props: {
|
|||||||
<box flexDirection="column" maxHeight={maxHeight} borderColor={theme.border}>
|
<box flexDirection="column" maxHeight={maxHeight} borderColor={theme.border}>
|
||||||
<For each={filteredOptions().slice(0, 10)}>
|
<For each={filteredOptions().slice(0, 10)}>
|
||||||
{(option, index) => (
|
{(option, index) => (
|
||||||
<box
|
<SelectableBox
|
||||||
backgroundColor={
|
selected={() => index() === selectedIndex()}
|
||||||
index() === selectedIndex() ? theme.primary : undefined
|
flexDirection="column"
|
||||||
}
|
|
||||||
padding={1}
|
padding={1}
|
||||||
|
onMouseDown={() => {
|
||||||
|
setSelectedIndex(index());
|
||||||
|
const selectedOption = filteredOptions()[index()];
|
||||||
|
if (selectedOption) {
|
||||||
|
selectedOption.onSelect?.(dialog);
|
||||||
|
dialog.clear();
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<box flexDirection="column" flexGrow={1}>
|
<box flexDirection="column" flexGrow={1}>
|
||||||
<box flexDirection="row" justifyContent="space-between">
|
<SelectableText
|
||||||
<text
|
selected={() => index() === selectedIndex()}
|
||||||
fg={
|
fg={
|
||||||
index() === selectedIndex()
|
index() === selectedIndex()
|
||||||
? theme.selectedListItemText
|
? theme.selectedListItemText
|
||||||
: theme.text
|
: theme.text
|
||||||
}
|
}
|
||||||
attributes={
|
attributes={
|
||||||
index() === selectedIndex()
|
index() === selectedIndex()
|
||||||
? TextAttributes.BOLD
|
? TextAttributes.BOLD
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
>
|
||||||
|
{option.title}
|
||||||
|
</SelectableText>
|
||||||
|
<Show when={option.footer}>
|
||||||
|
<SelectableText
|
||||||
|
selected={() => index() === selectedIndex()}
|
||||||
|
fg={theme.textMuted}
|
||||||
>
|
>
|
||||||
{option.title}
|
{option.footer}
|
||||||
</text>
|
</SelectableText>
|
||||||
<Show when={option.footer}>
|
</Show>
|
||||||
<text fg={theme.textMuted}>{option.footer}</text>
|
|
||||||
</Show>
|
|
||||||
</box>
|
|
||||||
<Show when={option.description}>
|
<Show when={option.description}>
|
||||||
<text fg={theme.textMuted}>{option.description}</text>
|
<SelectableText
|
||||||
|
selected={() => index() === selectedIndex()}
|
||||||
|
fg={theme.textMuted}
|
||||||
|
>
|
||||||
|
{option.description}
|
||||||
|
</SelectableText>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</SelectableBox>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
<Show when={filteredOptions().length === 0}>
|
<Show when={filteredOptions().length === 0}>
|
||||||
|
|||||||
Reference in New Issue
Block a user