Skip to content

Commit

Permalink
fix search width
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian-ubs committed Dec 20, 2024
1 parent eea56ee commit a93e505
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ export default function TabNavigationContentSearch({
onSearch,
searchPlaceholder,
headerTitle,
isSearchBarFullWidth = false,
}: 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}
onSearch={onSearch}
placeholder={searchPlaceholder}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,11 @@ export type SearchBarProps = {
/** Optional string that appears in the search bar without a search string */
placeholder?: string;

/** Optional boolean to set the input base to full width */
isFullWidth?: boolean;

/** Additional css classes to help with unique styling of the search bar */
className?: string;
};

export default function SearchBar({
onSearch,
placeholder,
isFullWidth,
className,
}: SearchBarProps) {
export default function SearchBar({ onSearch, placeholder, className }: SearchBarProps) {
const [searchQuery, setSearchQuery] = useState<string>('');

const handleInputChange = (searchString: string) => {
Expand All @@ -40,7 +32,7 @@ export default function SearchBar({
const dir: Direction = readDirection();

return (
<div className="tw-relative">
<div className={cn('tw-relative', 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 +41,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 +55,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 @@ -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 a93e505

Please sign in to comment.