-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' of https://github.com/HolodexNet/Holodex into next
- Loading branch information
Showing
13 changed files
with
435 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@/shadcn/ui/dropdown-menu"; | ||
import { useToast } from "@/shadcn/ui/use-toast"; | ||
import { blockedChannelsAtom } from "@/store/settings"; | ||
import { useAtom } from "jotai"; | ||
import { Children, ReactNode, useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useCopyToClipboard } from "usehooks-ts"; | ||
|
||
interface ChannelMenuProps extends ShortChannel { | ||
children: ReactNode; | ||
} | ||
|
||
export function ChannelMenu({ | ||
children, | ||
id: channelId, | ||
...rest | ||
}: ChannelMenuProps) { | ||
const [blockedChannels, setBlockedChannels] = useAtom(blockedChannelsAtom); | ||
const { toast } = useToast(); | ||
const [, copy] = useCopyToClipboard(); | ||
const { t } = useTranslation(); | ||
|
||
const isBlocked = blockedChannels.some(({ id }) => id === channelId); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger>{Children.only(children)}</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem | ||
className="flex gap-2" | ||
onClick={() => { | ||
copy(`${window.location.origin}/channel/${channelId}`); | ||
toast({ | ||
title: t("component.toast.copiedToClipboard"), | ||
}); | ||
}} | ||
> | ||
<div className="i-heroicons:link" /> | ||
{t("component.videoCard.copyLink")} | ||
</DropdownMenuItem> | ||
<DropdownMenuItem | ||
className="flex gap-2" | ||
onClick={() => | ||
setBlockedChannels((currVal) => | ||
isBlocked | ||
? currVal.filter(({ id }) => id !== channelId) | ||
: [...currVal, { id: channelId, ...rest }], | ||
) | ||
} | ||
> | ||
<div className="i-heroicons:no-symbol" /> | ||
{isBlocked | ||
? t("component.channelSocials.unblock") | ||
: t("component.channelSocials.block")} | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
} |
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,87 @@ | ||
import { useState, useEffect } from "react"; | ||
import { ChevronsUpDown } from "lucide-react"; | ||
import { Button } from "@/shadcn/ui/button"; | ||
import { | ||
Command, | ||
CommandEmpty, | ||
CommandGroup, | ||
CommandInput, | ||
CommandItem, | ||
CommandList, | ||
} from "@/shadcn/ui/command"; | ||
import { Popover, PopoverTrigger, PopoverContent } from "@/shadcn/ui/popover"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useAtom, useAtomValue } from "jotai/react"; | ||
import { useSearchAutoCompleteMutation } from "@/services/search.service"; | ||
import atomWithDebounce from "@/lib/atomWithDebounce"; | ||
|
||
const { debouncedValueAtom, currentValueAtom } = atomWithDebounce("", 300); | ||
|
||
interface TopicPickerProps { | ||
onSelect: (topicId: string) => void; | ||
} | ||
|
||
export function TopicPicker({ onSelect }: TopicPickerProps) { | ||
const [deboundcedValue, setDebouncedValue] = useAtom(debouncedValueAtom); | ||
const currentValue = useAtomValue(currentValueAtom); | ||
const { t } = useTranslation(); | ||
const [open, setOpen] = useState(false); | ||
|
||
const { data, isPending, mutate } = useSearchAutoCompleteMutation(); | ||
|
||
useEffect(() => { | ||
mutate({ | ||
q: deboundcedValue, | ||
t: "topic", | ||
n: 10, | ||
}); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [deboundcedValue]); | ||
|
||
return ( | ||
<Popover open={open} onOpenChange={setOpen}> | ||
<PopoverTrigger asChild> | ||
<Button | ||
variant="outline" | ||
role="combobox" | ||
size="lg" | ||
aria-expanded={open} | ||
className="w-full justify-between px-4" | ||
> | ||
{t("component.topicPicker.pickLabel")} | ||
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" /> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent className="max-w-[80vw] p-0"> | ||
<Command> | ||
<CommandInput | ||
value={currentValue} | ||
onValueChange={setDebouncedValue} | ||
placeholder={t("component.topicPicker.searchLabel")} | ||
/> | ||
<CommandList> | ||
<CommandEmpty>{t("component.topicPicker.notFound")}</CommandEmpty> | ||
<CommandGroup> | ||
{data?.topic?.map(({ id }) => ( | ||
<CommandItem | ||
key={id} | ||
onSelect={(topicId) => { | ||
onSelect(topicId); | ||
setOpen(false); | ||
}} | ||
> | ||
{id} | ||
</CommandItem> | ||
))} | ||
{isPending && ( | ||
<CommandItem className="flex justify-center py-2" disabled> | ||
<div className="i-lucide:loader-2 animate-spin" /> | ||
</CommandItem> | ||
)} | ||
</CommandGroup> | ||
</CommandList> | ||
</Command> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useFavorites } from "@/services/user.service"; | ||
import { ChannelCard } from "@/components/channel/ChannelCard"; | ||
import { VirtuosoGrid } from "react-virtuoso"; | ||
|
||
export default function Favorites() { | ||
const { data: favChannels } = useFavorites(); | ||
return ( | ||
<> | ||
<div className="h-full w-full p-4 md:p-8"> | ||
<VirtuosoGrid | ||
useWindowScroll | ||
listClassName="w-full grid grid-cols-[repeat(auto-fill,_minmax(240px,_1fr))] gap-x-4 gap-y-6" | ||
data={favChannels?.flat() ?? []} | ||
itemContent={(_, channel) => <ChannelCard {...channel} />} | ||
/> | ||
</div> | ||
</> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { blockedChannelsAtom } from "@/store/settings"; | ||
import { useAtom } from "jotai"; | ||
|
||
export default function SettingsBlocked() { | ||
const [blockedChannels, setBlockedChannels] = useAtom(blockedChannelsAtom); | ||
|
||
return <div className="flex flex-col gap-2"></div>; | ||
} |
Oops, something went wrong.