-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace select with toggle group in popup due to firefox popup not ha…
…ndling select properly
- Loading branch information
Showing
5 changed files
with
105 additions
and
204 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 was deleted.
Oops, something went wrong.
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,62 @@ | ||
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group" | ||
import { type VariantProps } from "class-variance-authority" | ||
import * as React from "react" | ||
|
||
import { toggleVariants } from "@src/components/ui/toggle" | ||
import { cn } from "@src/lib/utils" | ||
|
||
const ToggleGroupContext = React.createContext< | ||
VariantProps<typeof toggleVariants> | ||
>({ | ||
size: "default", | ||
variant: "default", | ||
}) | ||
|
||
const ToggleGroup = React.forwardRef< | ||
React.ElementRef<typeof ToggleGroupPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> & | ||
VariantProps<typeof toggleVariants> | ||
>(({ className, variant, size, children, ...props }, ref) => ( | ||
<ToggleGroupPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"flex items-center justify-center gap-1 rounded-sm bg-background-layer-1", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<ToggleGroupContext.Provider value={{ variant, size }}> | ||
{children} | ||
</ToggleGroupContext.Provider> | ||
</ToggleGroupPrimitive.Root> | ||
)) | ||
|
||
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName | ||
|
||
const ToggleGroupItem = React.forwardRef< | ||
React.ElementRef<typeof ToggleGroupPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> & | ||
VariantProps<typeof toggleVariants> | ||
>(({ className, children, variant, size, ...props }, ref) => { | ||
const context = React.useContext(ToggleGroupContext) | ||
|
||
return ( | ||
<ToggleGroupPrimitive.Item | ||
ref={ref} | ||
className={cn( | ||
toggleVariants({ | ||
variant: context.variant || variant, | ||
size: context.size || size, | ||
}), | ||
className | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
</ToggleGroupPrimitive.Item> | ||
) | ||
}) | ||
|
||
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName | ||
|
||
export { ToggleGroup, ToggleGroupItem } |
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