-
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * Improve merging of tags by simple drag and drop #144 Added drag&drop functionality Allowing sorting the tags by name, as this is more intuitive * Improve merging of tags by simple drag and drop #144 minor renamings removed some unnecessary code * Improve merging of tags by simple drag and drop #144 extracted out the drag and drop functionality to be more encapsulated and reusable * Improve merging of tags by simple drag and drop #144 improved the usage sorter to additionally compare by name if the usage is the same * Improve merging of tags by simple drag and drop #144 replaced checkboxes with toggles floating on the right --------- Co-authored-by: kamtschatka <simon.schatka@gmx.at>
- Loading branch information
1 parent
6eea671
commit 1fee129
Showing
6 changed files
with
365 additions
and
43 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,48 @@ | ||
import Link from "next/link"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Separator } from "@/components/ui/separator"; | ||
import { X } from "lucide-react"; | ||
|
||
import DeleteTagConfirmationDialog from "./DeleteTagConfirmationDialog"; | ||
|
||
const PILL_STYLE = | ||
"flex gap-2 rounded-md border border-border bg-background px-2 py-1 text-foreground hover:bg-foreground hover:text-background"; | ||
|
||
export function TagPill({ | ||
id, | ||
name, | ||
count, | ||
isDraggable, | ||
}: { | ||
id: string; | ||
name: string; | ||
count: number; | ||
isDraggable: boolean; | ||
}) { | ||
// When the element is draggable, do not generate a link. Links can be dragged into e.g. the tab-bar and therefore dragging the TagPill does not work properly | ||
if (isDraggable) { | ||
return ( | ||
<div className={PILL_STYLE} data-id={id}> | ||
{name} <Separator orientation="vertical" /> {count} | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="group relative flex"> | ||
<Link className={PILL_STYLE} href={`/dashboard/tags/${id}`}> | ||
{name} <Separator orientation="vertical" /> {count} | ||
</Link> | ||
|
||
<DeleteTagConfirmationDialog tag={{ name, id }}> | ||
<Button | ||
size="none" | ||
variant="secondary" | ||
className="-translate-1/2 absolute -right-1 -top-1 hidden rounded-full group-hover:block" | ||
> | ||
<X className="size-3" /> | ||
</Button> | ||
</DeleteTagConfirmationDialog> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"use client"; | ||
|
||
import type { VariantProps } from "class-variance-authority"; | ||
import * as React from "react"; | ||
import { cn } from "@/lib/utils"; | ||
import * as TogglePrimitive from "@radix-ui/react-toggle"; | ||
import { cva } from "class-variance-authority"; | ||
|
||
const toggleVariants = cva( | ||
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground", | ||
{ | ||
variants: { | ||
variant: { | ||
default: "bg-transparent", | ||
outline: | ||
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground", | ||
}, | ||
size: { | ||
default: "h-10 px-3", | ||
sm: "h-9 px-2.5", | ||
lg: "h-11 px-5", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
size: "default", | ||
}, | ||
}, | ||
); | ||
|
||
const Toggle = React.forwardRef< | ||
React.ElementRef<typeof TogglePrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & | ||
VariantProps<typeof toggleVariants> | ||
>(({ className, variant, size, ...props }, ref) => ( | ||
<TogglePrimitive.Root | ||
ref={ref} | ||
className={cn(toggleVariants({ variant, size, className }))} | ||
{...props} | ||
/> | ||
)); | ||
|
||
Toggle.displayName = TogglePrimitive.Root.displayName; | ||
|
||
export { Toggle, toggleVariants }; |
Oops, something went wrong.