🎨 style: adjust the style of project search bar

This commit is contained in:
Wahyu Kurniawan 2024-03-05 16:15:11 +07:00
parent 64e3aa5b25
commit abe1401a6d
No known key found for this signature in database
GPG Key ID: 040A1549143A8E33
3 changed files with 96 additions and 91 deletions

View File

@ -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>

View File

@ -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="px-2 py-2">
<div className="p-3"> <p className="text-elements-mid-em text-xs font-medium">
<Typography variant="small" color="gray" placeholder={''}> Suggestions
Suggestions </p>
</Typography>
</div>
{items.map((item, index) => (
<ListItem
selected={highlightedIndex === index || selectedItem === item}
key={item.id}
placeholder={''}
{...getItemProps({ item, index })}
>
<ListItemPrefix placeholder={''}>
<Avatar
src={item.icon || '/gray.png'}
variant="rounded"
placeholder={''}
/>
</ListItemPrefix>
<div>
<Typography variant="h6" color="blue-gray" placeholder={''}>
{item.name}
</Typography>
<Typography
variant="small"
color="gray"
className="font-normal"
placeholder={''}
>
{item.organization.name}
</Typography>
</div>
</ListItem>
))}
</>
) : (
<div className="p-3">
<Typography placeholder={''}>
^ No projects matching this name
</Typography>
</div> </div>
)} {items.map((item, index) => (
</List> <div
</Card> {...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,
},
)}
>
<Avatar
size={32}
imageSrc={item.icon}
initials={getInitials(item.name)}
/>
<div className="flex flex-col flex-1">
<p className="text-sm tracking-[-0.006em] text-elements-high-em">
{item.name}
</p>
<p className="text-xs text-elements-low-em">
{item.organization.name}
</p>
</div>
</div>
))}
</>
) : (
<div className="flex items-center px-2 py-2 gap-3">
<div className="w-8 h-8 rounded-lg flex items-center justify-center bg-orange-50 text-elements-warning">
<InfoRoundFilledIcon size={16} />
</div>
<p className="text-elements-low-em text-sm tracking-[-0.006em]">
No projects matching this name
</p>
</div>
)}
</div>
</div> </div>
); );
}; };

View File

@ -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,30 +47,37 @@ const ProjectSearch = () => {
}} }}
/> />
</div> </div>
<Button <div className="flex items-center gap-3">
variant={'secondary'} <Button
iconOnly variant="secondary"
onClick={() => { iconOnly
fetchOrgSlug().then((organizationSlug) => { onClick={() => {
navigate(`/${organizationSlug}/projects/create`); fetchOrgSlug().then((organizationSlug) => {
}); navigate(`/${organizationSlug}/projects/create`);
}} });
> }}
<PlusIcon /> >
</Button> <PlusIcon />
<Button variant={'ghost'} iconOnly> </Button>
<NotificationBellIcon /> <Button variant="ghost" iconOnly>
</Button> <NotificationBellIcon />
{user?.name ? ( </Button>
<Button variant={'tertiary'}>{formatAddress(user.name)}</Button> {user?.name && (
) : null} <Avatar
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>
); );
}; };