mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-04 23:32:54 +01:00
add curtains to select
This commit is contained in:
1 file changed
+27
-4
@@ -4,8 +4,14 @@ import { classNames } from "../../ui/classNames";
|
||||
import { composeRadixComponents } from "../../ui/compose";
|
||||
import { Button } from "../Button";
|
||||
import { Discriminator } from "../DropdownMenu";
|
||||
import { ScrollerOrientation } from "../Scroller";
|
||||
import { ScrollerCurtains } from "../ScrollerCurtains";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
const composed = composeRadixComponents(_, styles, {
|
||||
Content: { position: "popper", align: "center" },
|
||||
});
|
||||
|
||||
type SelectTriggerProps = ComponentProps<typeof _.Trigger>;
|
||||
|
||||
function Trigger({ className, children, ...props }: SelectTriggerProps) {
|
||||
@@ -22,12 +28,29 @@ function Trigger({ className, children, ...props }: SelectTriggerProps) {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: for select, context menu, and dropdown menus, use scroller curtains
|
||||
// Radix's viewport is the scroller here, so the curtains go straight inside it
|
||||
// and it takes the dropdown's viewport styles
|
||||
function Viewport({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: ComponentProps<typeof composed.Viewport>) {
|
||||
return (
|
||||
<composed.Viewport
|
||||
className={classNames(styles.viewport, className)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ScrollerCurtains orientation={ScrollerOrientation.Vertical} />
|
||||
</composed.Viewport>
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: use scroller curtains in context menus too
|
||||
export const Select = {
|
||||
...composeRadixComponents(_, styles, {
|
||||
Content: { position: "popper", align: "center" },
|
||||
}),
|
||||
...composed,
|
||||
|
||||
Discriminator,
|
||||
Trigger,
|
||||
Viewport,
|
||||
};
|
||||
Reference in new issue
Block a user