Skip to content

Commit

Permalink
fix search
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian-ubs committed Dec 20, 2024
1 parent eea56ee commit a729be0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ export type TabNavigationContentSearchProps = {
/** Optional title to include in the header */
headerTitle?: string;

/** Optional flag to make the search bar appear full width */
isSearchBarFullWidth?: boolean;
/** Optional className to modify the search input */
searchClassName?: string;
};

export default function TabNavigationContentSearch({
tabList,
onSearch,
searchPlaceholder,
headerTitle,
isSearchBarFullWidth = false,
searchClassName,
}: TabNavigationContentSearchProps) {
return (
<div className="pr-twp">
<div className="tw-sticky tw-top-0 tw-space-y-2 tw-pb-2">
{headerTitle ? <h1>{headerTitle}</h1> : ''}
<SearchBar
isFullWidth={isSearchBarFullWidth}
className={searchClassName}
onSearch={onSearch}
placeholder={searchPlaceholder}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function SearchBar({
const dir: Direction = readDirection();

return (
<div className="tw-relative">
<div className={cn('tw-relative', {'tw-w-full': isFullWidth}, className)}>
<Search
className={cn(
'tw-absolute tw-top-1/2 tw-h-4 tw-w-4 tw--translate-y-1/2 tw-transform tw-opacity-50',
Expand All @@ -49,7 +49,7 @@ export default function SearchBar({
)}
/>
<Input
className={cn('tw-text-ellipsis tw-pe-9 tw-ps-9', { 'tw-w-full': isFullWidth }, className)}
className="tw-w-full tw-text-ellipsis tw-pe-9 tw-ps-9"
placeholder={placeholder}
value={searchQuery}
onChange={(e) => handleInputChange(e.target.value)}
Expand All @@ -63,13 +63,11 @@ export default function SearchBar({
{ 'tw-left-0': dir === 'rtl' },
{ 'tw-right-0': dir === 'ltr' },
)}
onClick={() => {
handleInputChange('');
}}
>
<X
className="tw-h-4 tw-w-4"
onClick={() => {
handleInputChange('');
}}
/>
<X className="tw-h-4 tw-w-4" />
<span className="tw-sr-only">Clear</span>
</Button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ScriptureResultsViewerExample from './advanced/scripture-results-viewer.e
import SettingsListExamples from './advanced/settings-list.examples.component';
import { columns, data } from './data-sources/data-table-content';
import UiLanguageSelectorExample from './advanced/ui-language-selector-example.component';
import SettingSidebarContentSearchExamples from './advanced/settings-sidebar-content-search.example.component';

function Compositions() {
const [scrRef, setScrRef] = useState(defaultScrRef);
Expand Down Expand Up @@ -85,6 +86,9 @@ function Compositions() {
<VerticalTabsTrigger value="Scroll Group Selector">
Scroll Group Selector
</VerticalTabsTrigger>
<VerticalTabsTrigger value="Settings Sidebar Content Search">
Settings Sidebar Content Search
</VerticalTabsTrigger>
<VerticalTabsTrigger value="Markdown Renderer">Markdown Renderer</VerticalTabsTrigger>
<VerticalTabsTrigger value="UI Language Selector">
UI Language Selector
Expand Down Expand Up @@ -139,7 +143,7 @@ function Compositions() {
tabList={tabList}
onSearch={handleSearchChange}
searchPlaceholder="Search..."
isSearchBarFullWidth
searchClassName='tw-w-9/12 tw-py-2'
/>
</VerticalTabsContent>

Expand All @@ -160,6 +164,10 @@ function Compositions() {
<div>Scroll Group Id: {`${scrollGroupId}`}</div>
</VerticalTabsContent>

<VerticalTabsContent value="Settings Sidebar Content Search">
<SettingSidebarContentSearchExamples />
</VerticalTabsContent>

<VerticalTabsContent value="Markdown Renderer">
<MarkdownRendererExample />
</VerticalTabsContent>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import SettingsSidebarContentSearch from '@/components/advanced/settings-components/settings-sidebar-content-search.component';

export default function SettingSidebarContentSearchExamples() {
return (
<div>
<SettingsSidebarContentSearch
buttonPlaceholderText="?? Select a project"
extensionLabels={['A', 'B', 'C']}
projectInfo={[
{ projectName: 'a', projectId: '1' },
{ projectName: 'b', projectId: '2' },
{ projectName: 'c', projectId: '3' },
]}
selectedSidebarItem={{ label: '', projectId: '' }}
projectsSidebarGroupLabel=""
extensionsSidebarGroupLabel=""
handleSelectSidebarItem={(key: string, projId?: string) =>
console.log('Selected:', key, projId)
}
onSearch={(query) => console.log('Searching for:', query)}
/>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
TableHeader,
TableRow,
} from '@/components/shadcn-ui/table';
import { cn } from '@/utils/shadcn-ui.util';
import { DialogTitle } from '@radix-ui/react-dialog';
import MultiSelectComboBox from '@/components/advanced/multi-select-combo-box';

Expand Down Expand Up @@ -237,11 +236,7 @@ export default function GetResourcesExample() {

<div className="tw-space-y-4">
<div className="tw-grid tw-grid-cols-1 tw-gap-4 md:tw-grid-cols-3">
<SearchBar
onSearch={setSearchQuery}
placeholder="Search by name, language, type..."
className={cn('tw-px-8', searchQuery && 'tw-border-primary')}
/>
<SearchBar onSearch={setSearchQuery} placeholder="Search by name, language, type..." />

<MultiSelectComboBox
entries={types}
Expand Down

0 comments on commit a729be0

Please sign in to comment.