Skip to content

Commit

Permalink
just commit
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmegood committed Feb 18, 2024
1 parent d357d1e commit 1a3f080
Show file tree
Hide file tree
Showing 10 changed files with 576 additions and 155 deletions.
58 changes: 30 additions & 28 deletions app/components/search-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function SearchBar({
onSubmitHandler,
className,
searchParam,
searchRef,
}: {
action: string
status: 'idle' | 'pending' | 'success' | 'error'
Expand All @@ -22,6 +23,7 @@ export function SearchBar({
autoSubmit?: boolean
className?: string
searchParam?: string
searchRef?: React.RefObject<HTMLInputElement>
}) {
const id = useId()
const [searchParams] = useSearchParams()
Expand All @@ -38,38 +40,38 @@ export function SearchBar({
}, 400)

return (
<Form
method="GET"
action={action}
className={cn(
'flex w-full flex-wrap items-center justify-center gap-2',
className,
)}
onChange={e => autoSubmit && handleFormChange(e.currentTarget)}
onSubmit={onSubmitHandler}
>
<div className="flex-1" key={defaultValue}>
<Label htmlFor={id} className="sr-only">
Search
</Label>
<Input
type="search"
name={searchParam ?? 'search'}
id={id}
defaultValue={defaultValue}
placeholder="Search"
className="h-full w-full"
autoFocus={autoFocusSearch}
/>
</div>
<div className="flex gap-4">
<Form
method="GET"
action={action}
className={cn('w-full', className)}
onChange={e => autoSubmit && handleFormChange(e.currentTarget)}
onSubmit={onSubmitHandler}
>
<div key={defaultValue}>
<Label htmlFor={id} className="sr-only">
Search
</Label>
<Input
ref={searchRef}
type="search"
name={searchParam ?? 'search'}
id={id}
defaultValue={defaultValue}
placeholder="Search"
autoFocus={autoFocusSearch}
/>
</div>
</Form>
<StatusButton
tabIndex={autoSubmit ? -1 : 0}
type="submit"
status={isSubmitting ? 'pending' : status}
size="sm"
>
<Icon name="magnifying-glass" size="sm" />
<span className="sr-only">Search</span>
<Icon name="magnifying-glass">
<span className="hidden md:flex">Search</span>
</Icon>
</StatusButton>
</Form>
</div>
)
}
11 changes: 6 additions & 5 deletions app/components/ui/dropdown-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
'flex select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent',
'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent',
inset && 'pl-8',
className,
)}
Expand Down Expand Up @@ -62,7 +62,8 @@ const DropdownMenuContent = React.forwardRef<
ref={ref}
sideOffset={sideOffset}
className={cn(
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md',
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
className,
)}
{...props}
Expand All @@ -80,7 +81,7 @@ const DropdownMenuItem = React.forwardRef<
<DropdownMenuPrimitive.Item
ref={ref}
className={cn(
'relative flex select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
inset && 'pl-8',
className,
)}
Expand All @@ -96,7 +97,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
<DropdownMenuPrimitive.CheckboxItem
ref={ref}
className={cn(
'relative flex select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
className,
)}
checked={checked}
Expand Down Expand Up @@ -129,7 +130,7 @@ const DropdownMenuRadioItem = React.forwardRef<
<DropdownMenuPrimitive.RadioItem
ref={ref}
className={cn(
'relative flex select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
className,
)}
{...props}
Expand Down
11 changes: 10 additions & 1 deletion app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ensure the user gets the right status code and we can display a nicer error
// message for them than the Remix and/or browser default.

import { Link, useLocation } from '@remix-run/react'
import { Link, useLocation, useNavigate } from '@remix-run/react'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
import { Icon } from '#app/components/ui/icon.tsx'

Expand All @@ -21,6 +21,9 @@ export default function NotFound() {

export function ErrorBoundary() {
const location = useLocation()

const navigate = useNavigate()

return (
<GeneralErrorBoundary
statusHandlers={{
Expand All @@ -35,6 +38,12 @@ export function ErrorBoundary() {
<Link to="/" className="text-body-md underline">
<Icon name="arrow-left">Back to home</Icon>
</Link>
<button
onClick={() => navigate(-1)}
className="text-body-md underline"
>
<Icon name="arrow-left">Go back</Icon>
</button>
</div>
),
}}
Expand Down
5 changes: 2 additions & 3 deletions app/routes/c.$companyId+/_layout_company.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const companyRoutes = [
href: 'reports',
},
{
title: 'Search',
title: 'Discover',
href: 'search',
},
]
Expand All @@ -41,7 +41,6 @@ const mobileCompanyRoutes = [

export default function LayoutCompany() {
const matches = useMatches()
console.log(matches)
const isSearchPage = matches.find(m => m.id === 'routes/c.$companyId+/search')

return (
Expand Down Expand Up @@ -84,7 +83,7 @@ export default function LayoutCompany() {
<nav className="hidden w-full gap-4 lg:flex">
{!isSearchPage && (
<SearchBar
action="/search"
action="search"
status="idle"
className="hidden max-w-lg lg:flex"
/>
Expand Down
Loading

0 comments on commit 1a3f080

Please sign in to comment.