-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from premieroctet/feat/add-bookmark-button-im…
…prove-ux Feat: Add "Add bookmark button"
- Loading branch information
Showing
9 changed files
with
147 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 21 additions & 16 deletions
37
src/components/bookmark/BookmarkButton.tsx → ...ponents/bookmark/CreateBookmarkButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
'use client'; | ||
|
||
import { PlusIcon } from '@heroicons/react/24/solid'; | ||
import { Team } from '@prisma/client'; | ||
import { FaTelegramPlane } from '@react-icons/all-files/fa/FaTelegramPlane'; | ||
import { BookmarkModal } from './BookmarkModal'; | ||
import { Dialog, DialogContent, DialogTrigger } from '../Dialog'; | ||
import { useState } from 'react'; | ||
import Button from '../Button'; | ||
import { Dialog, DialogContent, DialogTrigger } from '../Dialog'; | ||
import { BookmarkModal } from './BookmarkModal'; | ||
|
||
type Props = { team: Team }; | ||
interface Props { | ||
team: Team; | ||
} | ||
|
||
const BookmarkButton = ({ team }: Props) => { | ||
export default function CreateBookmarkButton({ team }: Props) { | ||
const [isDialogOpen, setIsDialogOpen] = useState(false); | ||
return ( | ||
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}> | ||
<DialogTrigger asChild> | ||
<button | ||
className="btn-add-link" | ||
aria-label="Add bookmark" | ||
title="Add bookmark" | ||
<Button | ||
onClick={() => setIsDialogOpen(true)} | ||
variant="default" | ||
size="md" | ||
icon={<PlusIcon className="h-4 w-4" aria-hidden="true" />} | ||
title="Create a new bookmark" | ||
className="px-0" | ||
> | ||
<span className="hidden md:block">Add Bookmark</span> | ||
<FaTelegramPlane /> | ||
</button> | ||
New bookmark | ||
</Button> | ||
</DialogTrigger> | ||
<DialogContent | ||
containerClassName="w-full sm:max-w-md" | ||
title="New Bookmark" | ||
title="New bookmark" | ||
description="Add a new link to your team feed" | ||
closeIcon | ||
> | ||
<BookmarkModal onSuccess={() => setIsDialogOpen(false)} team={team} /> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default BookmarkButton; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { PlusIcon } from '@heroicons/react/24/solid'; | ||
import { Team } from '@prisma/client'; | ||
import { useEffect, useState } from 'react'; | ||
import { Dialog, DialogContent, DialogTrigger } from '../Dialog'; | ||
import { BookmarkModal } from './BookmarkModal'; | ||
|
||
type Props = { team: Team }; | ||
|
||
const HeaderCreateBookmarkButton = ({ team }: Props) => { | ||
const [isDialogOpen, setIsDialogOpen] = useState(false); | ||
|
||
function onKeyDown(event: KeyboardEvent) { | ||
if (event.key === 'b' && event.ctrlKey) { | ||
setIsDialogOpen(true); | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
window.addEventListener('keydown', onKeyDown); | ||
return () => { | ||
window.removeEventListener('keydown', onKeyDown); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}> | ||
<DialogTrigger asChild> | ||
<button | ||
className="btn-add-link" | ||
aria-label="New bookmark" | ||
title="New bookmark" | ||
> | ||
<span className="hidden md:block whitespace-nowrap"> | ||
New bookmark | ||
</span> | ||
<PlusIcon className="h-3.5 w-3.5" aria-hidden="true" /> | ||
</button> | ||
</DialogTrigger> | ||
<DialogContent | ||
containerClassName="w-full sm:max-w-md" | ||
title="New Bookmark" | ||
description="Add a new link to your team feed" | ||
closeIcon | ||
> | ||
<BookmarkModal onSuccess={() => setIsDialogOpen(false)} team={team} /> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default HeaderCreateBookmarkButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.