forked from cerc-io/snowballtools-base
🎨 style: adjust the style of project search bar
This commit is contained in:
parent
64e3aa5b25
commit
abe1401a6d
@ -15,7 +15,7 @@ const SearchBar: React.ForwardRefRenderFunction<
|
|||||||
value={value}
|
value={value}
|
||||||
type="search"
|
type="search"
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
appearance={'borderless'}
|
appearance="borderless"
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,17 +3,12 @@ import { useCombobox } from 'downshift';
|
|||||||
import { Project } from 'gql-client';
|
import { Project } from 'gql-client';
|
||||||
import { useDebounce } from 'usehooks-ts';
|
import { useDebounce } from 'usehooks-ts';
|
||||||
|
|
||||||
import {
|
import SearchBar from 'components/SearchBar';
|
||||||
List,
|
import { useGQLClient } from 'context/GQLClientContext';
|
||||||
ListItem,
|
import { cn } from 'utils/classnames';
|
||||||
ListItemPrefix,
|
import { InfoRoundFilledIcon } from 'components/shared/CustomIcon';
|
||||||
Card,
|
import { Avatar } from 'components/shared/Avatar';
|
||||||
Typography,
|
import { getInitials } from 'utils/geInitials';
|
||||||
Avatar,
|
|
||||||
} from '@material-tailwind/react';
|
|
||||||
|
|
||||||
import SearchBar from '../SearchBar';
|
|
||||||
import { useGQLClient } from '../../context/GQLClientContext';
|
|
||||||
|
|
||||||
interface ProjectsSearchProps {
|
interface ProjectsSearchProps {
|
||||||
onChange?: (data: Project) => void;
|
onChange?: (data: Project) => void;
|
||||||
@ -67,59 +62,59 @@ const ProjectSearchBar = ({ onChange }: ProjectsSearchProps) => {
|
|||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<SearchBar {...getInputProps()} />
|
<SearchBar {...getInputProps()} />
|
||||||
<Card
|
<div
|
||||||
className={`absolute w-1/2 max-h-52 -mt-1 overflow-y-auto ${
|
{...getMenuProps()}
|
||||||
(!inputValue || !isOpen) && 'hidden'
|
className={cn(
|
||||||
}`}
|
'flex flex-col shadow-dropdown rounded-xl bg-surface-card absolute w-[459px] max-h-52 overflow-y-auto px-2 py-2 gap-1 z-50',
|
||||||
placeholder={''}
|
{ hidden: !inputValue || !isOpen },
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<List {...getMenuProps()}>
|
|
||||||
{items.length ? (
|
{items.length ? (
|
||||||
<>
|
<>
|
||||||
<div className="p-3">
|
<div className="px-2 py-2">
|
||||||
<Typography variant="small" color="gray" placeholder={''}>
|
<p className="text-elements-mid-em text-xs font-medium">
|
||||||
Suggestions
|
Suggestions
|
||||||
</Typography>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{items.map((item, index) => (
|
{items.map((item, index) => (
|
||||||
<ListItem
|
<div
|
||||||
selected={highlightedIndex === index || selectedItem === item}
|
|
||||||
key={item.id}
|
|
||||||
placeholder={''}
|
|
||||||
{...getItemProps({ item, index })}
|
{...getItemProps({ item, index })}
|
||||||
|
key={item.id}
|
||||||
|
className={cn(
|
||||||
|
'px-2 py-2 flex items-center gap-3 rounded-lg hover:bg-base-bg-emphasized',
|
||||||
|
{
|
||||||
|
'bg-base-bg-emphasized':
|
||||||
|
highlightedIndex === index || selectedItem === item,
|
||||||
|
},
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<ListItemPrefix placeholder={''}>
|
|
||||||
<Avatar
|
<Avatar
|
||||||
src={item.icon || '/gray.png'}
|
size={32}
|
||||||
variant="rounded"
|
imageSrc={item.icon}
|
||||||
placeholder={''}
|
initials={getInitials(item.name)}
|
||||||
/>
|
/>
|
||||||
</ListItemPrefix>
|
<div className="flex flex-col flex-1">
|
||||||
<div>
|
<p className="text-sm tracking-[-0.006em] text-elements-high-em">
|
||||||
<Typography variant="h6" color="blue-gray" placeholder={''}>
|
|
||||||
{item.name}
|
{item.name}
|
||||||
</Typography>
|
</p>
|
||||||
<Typography
|
<p className="text-xs text-elements-low-em">
|
||||||
variant="small"
|
|
||||||
color="gray"
|
|
||||||
className="font-normal"
|
|
||||||
placeholder={''}
|
|
||||||
>
|
|
||||||
{item.organization.name}
|
{item.organization.name}
|
||||||
</Typography>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ListItem>
|
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className="p-3">
|
<div className="flex items-center px-2 py-2 gap-3">
|
||||||
<Typography placeholder={''}>
|
<div className="w-8 h-8 rounded-lg flex items-center justify-center bg-orange-50 text-elements-warning">
|
||||||
^ No projects matching this name
|
<InfoRoundFilledIcon size={16} />
|
||||||
</Typography>
|
</div>
|
||||||
|
<p className="text-elements-low-em text-sm tracking-[-0.006em]">
|
||||||
|
No projects matching this name
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</List>
|
</div>
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -4,12 +4,14 @@ import { User } from 'gql-client';
|
|||||||
|
|
||||||
// import { Tooltip } from '@material-tailwind/react';
|
// import { Tooltip } from '@material-tailwind/react';
|
||||||
|
|
||||||
import HorizontalLine from '../components/HorizontalLine';
|
import HorizontalLine from 'components/HorizontalLine';
|
||||||
import ProjectSearchBar from '../components/projects/ProjectSearchBar';
|
import ProjectSearchBar from 'components/projects/ProjectSearchBar';
|
||||||
import { useGQLClient } from '../context/GQLClientContext';
|
import { useGQLClient } from 'context/GQLClientContext';
|
||||||
import { formatAddress } from '../utils/format';
|
|
||||||
import { NotificationBellIcon, PlusIcon } from 'components/shared/CustomIcon';
|
import { NotificationBellIcon, PlusIcon } from 'components/shared/CustomIcon';
|
||||||
import { Button } from 'components/shared/Button';
|
import { Button } from 'components/shared/Button';
|
||||||
|
import { Avatar } from 'components/shared/Avatar';
|
||||||
|
import { getInitials } from 'utils/geInitials';
|
||||||
|
import { formatAddress } from '../utils/format';
|
||||||
|
|
||||||
const ProjectSearch = () => {
|
const ProjectSearch = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -32,10 +34,11 @@ const ProjectSearch = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<section className="h-full flex flex-col">
|
||||||
<div className="sticky top-0 bg-white z-30">
|
{/* Header */}
|
||||||
<div className="flex pl-3 pr-8 pt-3 pb-3 items-center">
|
<div className="sticky hidden md:block top-0 border-b border-border-separator/[0.06] z-30">
|
||||||
<div className="grow">
|
<div className="flex pr-6 pl-2 py-2 items-center">
|
||||||
|
<div className="flex-1">
|
||||||
<ProjectSearchBar
|
<ProjectSearchBar
|
||||||
onChange={(project) => {
|
onChange={(project) => {
|
||||||
navigate(
|
navigate(
|
||||||
@ -44,8 +47,9 @@ const ProjectSearch = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
<Button
|
<Button
|
||||||
variant={'secondary'}
|
variant="secondary"
|
||||||
iconOnly
|
iconOnly
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
fetchOrgSlug().then((organizationSlug) => {
|
fetchOrgSlug().then((organizationSlug) => {
|
||||||
@ -55,19 +59,25 @@ const ProjectSearch = () => {
|
|||||||
>
|
>
|
||||||
<PlusIcon />
|
<PlusIcon />
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant={'ghost'} iconOnly>
|
<Button variant="ghost" iconOnly>
|
||||||
<NotificationBellIcon />
|
<NotificationBellIcon />
|
||||||
</Button>
|
</Button>
|
||||||
{user?.name ? (
|
{user?.name && (
|
||||||
<Button variant={'tertiary'}>{formatAddress(user.name)}</Button>
|
<Avatar
|
||||||
) : null}
|
size={44}
|
||||||
|
initials={getInitials(formatAddress(user.name))}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<HorizontalLine />
|
<HorizontalLine />
|
||||||
</div>
|
</div>
|
||||||
<div className="z-0">
|
|
||||||
|
{/* Content */}
|
||||||
|
<section className="z-0">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</section>
|
||||||
</div>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user