- Spotify playlist, library, album and artist browsing with in-app playback - Song, playlist and album downloads via spotdl with YouTube and Bandcamp fallbacks - Electron desktop app (castLabs Widevine) with a permanent sidebar layout - Linux and Windows packaging scripts
173 lines
5.3 KiB
TypeScript
173 lines
5.3 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu"
|
|
import { Check, ChevronRight } from "lucide-react";
|
|
import styles from "./ContextMenu.module.css";
|
|
|
|
const ContextMenu = ContextMenuPrimitive.Root;
|
|
|
|
const ContextMenuTrigger = ContextMenuPrimitive.Trigger
|
|
|
|
const ContextMenuGroup = ContextMenuPrimitive.Group
|
|
|
|
const ContextMenuPortal = ContextMenuPrimitive.Portal
|
|
|
|
const ContextMenuSub = ContextMenuPrimitive.Sub
|
|
|
|
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup
|
|
|
|
const ContextMenuSubTrigger = React.forwardRef<
|
|
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
|
inset?: boolean
|
|
}
|
|
>(({ className, inset, children, ...props }, ref) => (
|
|
<ContextMenuPrimitive.SubTrigger
|
|
ref={ref}
|
|
className={`${styles.subTrigger} ${className ?? ""} ${inset ? styles.inset : ""}`}
|
|
{...props}
|
|
>
|
|
{children}
|
|
<ChevronRight className={styles.chevronRightIcon} />
|
|
</ContextMenuPrimitive.SubTrigger>
|
|
))
|
|
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName
|
|
|
|
const ContextMenuSubContent = React.forwardRef<
|
|
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
|
>(({ className, ...props }, ref) => (
|
|
<ContextMenuPrimitive.SubContent
|
|
ref={ref}
|
|
className={`${styles.subContent} ${className ?? ""}`}
|
|
{...props}
|
|
/>
|
|
))
|
|
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName
|
|
|
|
const ContextMenuContent = React.forwardRef<
|
|
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
|
>(({ className, ...props }, ref) => (
|
|
<ContextMenuPrimitive.Portal>
|
|
<ContextMenuPrimitive.Content
|
|
ref={ref}
|
|
className={`${styles.content} ${className ?? ""}`}
|
|
{...props}
|
|
/>
|
|
</ContextMenuPrimitive.Portal>
|
|
))
|
|
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
|
|
|
|
const ContextMenuItem = React.forwardRef<
|
|
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
|
inset?: boolean
|
|
}
|
|
>(({ className, inset, ...props }, ref) => (
|
|
<ContextMenuPrimitive.Item
|
|
ref={ref}
|
|
className={`${styles.item} ${className ?? ""} ${inset ? styles.inset : ""}`}
|
|
{...props}
|
|
/>
|
|
))
|
|
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName
|
|
|
|
const ContextMenuCheckboxItem = React.forwardRef<
|
|
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
|
>(({ className, children, checked, ...props }, ref) => (
|
|
<ContextMenuPrimitive.CheckboxItem
|
|
ref={ref}
|
|
className={`${styles.checkboxItem} ${className ?? ""}`}
|
|
checked={checked}
|
|
{...props}
|
|
>
|
|
<span className={styles.checkboxItemIndicator}>
|
|
<ContextMenuPrimitive.ItemIndicator>
|
|
<Check className={`${styles.checkIcon}`} />
|
|
</ContextMenuPrimitive.ItemIndicator>
|
|
</span>
|
|
{children}
|
|
</ContextMenuPrimitive.CheckboxItem>
|
|
))
|
|
ContextMenuCheckboxItem.displayName =
|
|
ContextMenuPrimitive.CheckboxItem.displayName
|
|
|
|
const ContextMenuRadioItem = React.forwardRef<
|
|
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
|
>(({ className, children, ...props }, ref) => (
|
|
<ContextMenuPrimitive.RadioItem
|
|
ref={ref}
|
|
className={`${styles.radioItem} ${className ?? ""}`}
|
|
{...props}
|
|
>
|
|
<span className={styles.radioItemIndicator}>
|
|
<ContextMenuPrimitive.ItemIndicator>
|
|
<div className={styles.radioIndicatorCircle} />
|
|
</ContextMenuPrimitive.ItemIndicator>
|
|
</span>
|
|
{children}
|
|
</ContextMenuPrimitive.RadioItem>
|
|
))
|
|
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName
|
|
|
|
const ContextMenuLabel = React.forwardRef<
|
|
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
|
inset?: boolean
|
|
}
|
|
>(({ className, inset, ...props }, ref) => (
|
|
<ContextMenuPrimitive.Label
|
|
ref={ref}
|
|
className={`${styles.label} ${className ?? ""} ${inset ? styles.inset : ""}`}
|
|
{...props}
|
|
/>
|
|
))
|
|
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName
|
|
|
|
const ContextMenuSeparator = React.forwardRef<
|
|
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
|
>(({ className, ...props }, ref) => (
|
|
<ContextMenuPrimitive.Separator
|
|
ref={ref}
|
|
className={`${styles.separator} ${className ?? ""}`}
|
|
{...props}
|
|
/>
|
|
))
|
|
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName
|
|
|
|
const ContextMenuShortcut = ({
|
|
className,
|
|
...props
|
|
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
return (
|
|
<span
|
|
className={`${styles.shortcut} ${className ?? ""}`}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
ContextMenuShortcut.displayName = "ContextMenuShortcut"
|
|
|
|
export {
|
|
ContextMenu,
|
|
ContextMenuTrigger,
|
|
ContextMenuContent,
|
|
ContextMenuItem,
|
|
ContextMenuCheckboxItem,
|
|
ContextMenuRadioItem,
|
|
ContextMenuLabel,
|
|
ContextMenuSeparator,
|
|
ContextMenuShortcut,
|
|
ContextMenuGroup,
|
|
ContextMenuPortal,
|
|
ContextMenuSub,
|
|
ContextMenuSubContent,
|
|
ContextMenuSubTrigger,
|
|
ContextMenuRadioGroup,
|
|
}
|