Skip to content

Commit

Permalink
dev: Updated search to button and modal
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-crowell committed Jun 16, 2024
1 parent 2a999b7 commit 648ccbe
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 36 deletions.
2 changes: 0 additions & 2 deletions packages/ui/src/Navigation/Navigation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const Standard: Story = {
title: 'Navigation',
links,
search: '#search',
className: 'bg-foreground/10',
},
};

Expand All @@ -88,7 +87,6 @@ export const Island: Story = {
variant: 'island',
links,
search: '#search',
className: 'bg-foreground/10',
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/Navigation/NavigationIsland.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function NavigationIsland({
<NavigationPart_Brand title={title} image={image} />
</NavbarContent>
<NavbarContent justify="center">
<div className={clmg(clsx(color && colors, 'flex rounded-full px-4', className))}>
<div className={clmg(clsx(color && colors, 'flex rounded-full border-1 border-foreground-200 px-4', className))}>
<NavigationPart_Links links={links} colors={colors} />
</div>
</NavbarContent>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/Navigation/NavigationStandard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function NavigationStandard({
const [ colors ] = twColors(color);

return (
<Navbar className={clmg(clsx(color && colors, className))}>
<Navbar className={clmg(clsx(color && colors, 'border-b-1 border-b-foreground-200', className))}>
<NavbarContent justify="start">
<NavigationPart_Brand title={title} />
</NavbarContent>
Expand Down
54 changes: 28 additions & 26 deletions packages/ui/src/Navigation/parts/NavigationPart_Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface NavigationPart_LinksProps {

function LinkLeaf({ link }: { link: LinkType }) {
return (
<NavbarMenuItem className="border-y-4 border-transparent hover:border-b-primary-500">
<NavbarMenuItem className="border-y-4 border-transparent hover:border-b-primary-200">
<Button
as={Link}
href={link.url}
Expand All @@ -42,38 +42,40 @@ function LinkBranch({ links, level }: { links: LinkType[], level: number }) {

const pl = level * 1;

return links.map((link) => (<div className="relative w-full">
<Divider
orientation="vertical"
className="absolute top-0 h-full"
style={{
display: level === 1 ? 'none' : 'block',
left: `${pl - 1}rem`,
}}
/>
<Link
href={link.url}
className={clsx(...classes, 'box-border w-full rounded py-2 pr-4 text-inherit hover:bg-black/10 hover:underline dark:hover:bg-white/10')}
style={{
paddingLeft: `${pl}rem`,
}}
>
{link.title}
</Link>
{link.links?.length && (
<div className="w-full [&:last-child]:mb-0">
<LinkBranch links={link.links} level={level + 1} />
</div>
)}
</div>));
return links.map((link) => (
<div key={link.title} className="relative w-full">
<Divider
orientation="vertical"
className="absolute top-0 h-full"
style={{
display: level === 1 ? 'none' : 'block',
left: `${pl - 1}rem`,
}}
/>
<Link
href={link.url}
className={clsx(...classes, 'box-border w-full rounded py-2 pr-4 text-inherit hover:bg-black/10 hover:underline dark:hover:bg-white/10')}
style={{
paddingLeft: `${pl}rem`,
}}
>
{link.title}
</Link>
{link.links?.length && (
<div className="w-full [&:last-child]:mb-0">
<LinkBranch links={link.links} level={level + 1} />
</div>
)}
</div>
));
}

function LinkTrunk({ link, colors }: { link: LinkType, colors?: string }) {
return (
<Popover
placement="bottom"
>
<NavbarMenuItem className="border-y-4 border-transparent hover:border-b-primary-500">
<NavbarMenuItem className="border-y-4 border-transparent hover:border-b-primary-200">
<PopoverTrigger>
<Button
variant="light"
Expand Down
42 changes: 36 additions & 6 deletions packages/ui/src/Navigation/parts/NavigationPart_Search.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MagnifyingGlassIcon } from '@heroicons/react/24/solid';
import { Button, Modal, useDisclosure } from '@nextui-org/react';
import { Button, Modal, ModalHeader, ModalBody, useDisclosure, ModalContent, Input, Kbd } from '@nextui-org/react';

/**
* Navigation Brand properties
Expand All @@ -18,11 +18,41 @@ export function NavigationPart_Search({
search = '#'
}: NavigationPart_SearchProps) {

const { isOpen, onOpen } = useDisclosure();
const { isOpen, onOpen, onOpenChange, onClose } = useDisclosure();

return (
<Button isIconOnly onClick={onOpen}>
<MagnifyingGlassIcon className="size-6" />
return (<>
<Button isIconOnly onPress={onOpen} size="sm">
<MagnifyingGlassIcon className="size-5" />
</Button>
);
<Modal
isOpen={isOpen}
onOpenChange={onOpenChange}
title="Search"
size="md"
hideCloseButton
>
<ModalContent>
<ModalHeader className="p-1">
<form action={search} method="get" className="w-full">
<Input
classNames={{
base: 'max-w-full h-12',
mainWrapper: 'h-full',
input: 'text-xl',
inputWrapper: 'h-full font-normal text-default-500 bg-transparent shadow-none',
}}
placeholder="Search website..."
size="lg"
startContent={<MagnifyingGlassIcon className="size-7" />}
endContent={<Kbd onClick={onClose} className="cursor-pointer">ESC</Kbd>}
type="search"
/>
</form>
</ModalHeader>
<ModalBody className="p-2">
&nbsp;
</ModalBody>
</ModalContent>
</Modal>
</>);
}

0 comments on commit 648ccbe

Please sign in to comment.