diff --git a/src/components/Selectable.tsx b/src/components/Selectable.tsx new file mode 100644 index 0000000..77436e7 --- /dev/null +++ b/src/components/Selectable.tsx @@ -0,0 +1,41 @@ +import { useTheme } from "@/context/ThemeContext"; +import type { JSXElement } from "solid-js"; +import type { BoxOptions, TextOptions } from "@opentui/core"; + +export function SelectableBox({ + selected, + children, + ...props +}: { + selected: () => boolean; + children: JSXElement; +} & BoxOptions) { + const { theme } = useTheme(); + + return ( + + {children} + + ); +} + +export function SelectableText({ + selected, + children, + ...props +}: { + selected: () => boolean; + children: JSXElement; +} & TextOptions) { + const { theme } = useTheme(); + + return ( + + {children} + + ); +} diff --git a/src/components/TabNavigation.tsx b/src/components/TabNavigation.tsx index 91e7358..d8573eb 100644 --- a/src/components/TabNavigation.tsx +++ b/src/components/TabNavigation.tsx @@ -1,6 +1,7 @@ import { useTheme } from "@/context/ThemeContext"; import { TABS } from "@/utils/navigation"; import { For } from "solid-js"; +import { SelectableBox, SelectableText } from "@/components/Selectable"; interface TabNavigationProps { activeTab: TABS; @@ -29,24 +30,18 @@ export function TabNavigation(props: TabNavigationProps) { > {(tab) => ( - tab.id == props.activeTab} onMouseDown={() => props.onTabSelect(tab.id)} - style={{ - backgroundColor: - tab.id == props.activeTab ? theme.primary : "transparent", - }} > - tab.id == props.activeTab} + alignSelf="center" > {tab.label} - - + + )}