Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to list #84

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions app/components/AddToListDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use client'

import { useEffect, useState } from 'react'
import { Dialog, DialogBackdrop, DialogPanel, DialogTitle } from '@headlessui/react'

interface IProps {
handleClose: () => void
isOpen: boolean
}

export default function AddToListDialog(props: IProps) {

const handleSave = () => {
props.handleClose()
}

return (
<Dialog open={props.isOpen} onClose={props.handleClose} className="relative z-10">
<DialogBackdrop
transition
className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity data-[closed]:opacity-0 data-[enter]:duration-300 data-[leave]:duration-200 data-[enter]:ease-out data-[leave]:ease-in"
/>

<div className="fixed inset-0 z-10 w-screen overflow-y-auto">
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
<DialogPanel
transition
className="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all data-[closed]:translate-y-4 data-[closed]:opacity-0 data-[enter]:duration-300 data-[leave]:duration-200 data-[enter]:ease-out data-[leave]:ease-in sm:my-8 sm:w-full sm:max-w-lg data-[closed]:sm:translate-y-0 data-[closed]:sm:scale-95"
>
<div className="bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4">
<div className="sm:flex sm:items-start">
<div className="mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left">
<DialogTitle as="h3" className="text-base font-semibold leading-6 text-gray-900">Add to list</DialogTitle>
{/* @TODO iterate lists here */}
<div className="mt-2">
<ul>
<li className="text-sm">
<button className="hover:cursor-pointer hover:bg-gray-100" onClick={() => console.log('make request')}>
Favorites
</button>
</li>
<li className="text-sm">
<button className="hover:cursor-pointer hover:bg-gray-100" onClick={() => console.log('make request')}>
Want to go
</button>
</li>
</ul>
</div>

</div>
</div>
</div>
<div className="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6">
<button
type="button"
onClick={props.handleClose}
className="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto"
>
Cancel
</button>
</div>
</DialogPanel>
</div>
</div>
</Dialog>
)
}
34 changes: 34 additions & 0 deletions app/components/AddToListDropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react'
import { ArrowTopRightOnSquareIcon, BookmarkIcon, PlusIcon } from '@heroicons/react/24/outline'

export default function AddToListDropdown() {

return (
<Menu>
<MenuButton>
<div
className="w-fit p-2 rounded-full border-2 border-yellow-400 hover:bg-yellow-100 hover:cursor-pointer"
>
<PlusIcon className="h-6 w-6" />
</div>
</MenuButton>

<MenuItems
transition
anchor="bottom end"
className="bg-slate-600 w-52 origin-top-right rounded-xl border border-white/5 bg-white/5 p-1 text-sm/6 text-white transition duration-100 ease-out [--anchor-gap:var(--spacing-1)] focus:outline-none data-[closed]:scale-95 data-[closed]:opacity-0"
>
<MenuItem>
<button className="group flex w-full items-center gap-2 rounded-lg py-1.5 px-3 data-[focus]:bg-white/10" onClick={() => console.log('make request')}>
Favorites
</button>
</MenuItem>
<MenuItem>
<button className="group flex w-full items-center gap-2 rounded-lg py-1.5 px-3 data-[focus]:bg-white/10" onClick={() => console.log('make request')}>
Want to go
</button>
</MenuItem>
</MenuItems>
</Menu>
)
}
15 changes: 11 additions & 4 deletions app/components/PanelContent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
'use client'

import { ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline'
import { useState } from 'react'
import { ArrowTopRightOnSquareIcon, BookmarkIcon, PlusIcon } from '@heroicons/react/24/outline'
import { TShop } from '@/types/shop-types'
import { TNeighborhood } from '@/types/neighborhood-types'
import NearbyShops from './NearbyShops'
import AddToListDialog from './AddToListDialog'
import AddToListDropdown from './AddToListDropdown'

interface IProps {
handleNearbyShopClick: (shop: TShop) => void
Expand All @@ -12,6 +15,7 @@ interface IProps {

// @TODO PanelBody might be a better name?
export default function PanelContent(props: IProps) {
const [addToListDialogIsOpen, setAddToListDialogIsOpen] = useState(false)
return (
<>
<div className="relative mt-6 flex-1 px-4 sm:px-6">
Expand All @@ -26,11 +30,14 @@ export default function PanelContent(props: IProps) {
</a>
)}
<address className="mt-1 text-sm text-gray-900">{props.shop.properties.address}</address>
<p className="mt-1 text-sm text-gray-900">
{props.shop.properties.neighborhood}
</p>
<p className="mt-1 text-sm text-gray-900">{props.shop.properties.neighborhood}</p>
<div className="flex mt-4">
<AddToListDropdown />
</div>
</div>
<NearbyShops shop={props.shop} handleClick={props.handleNearbyShopClick} />

{/* <AddToListDialog isOpen={addToListDialogIsOpen} handleClose={() => setAddToListDialogIsOpen(false)} /> */}
</>
)
}