This commit is contained in:
tresabhi committed 2026-12-03 23:21:57 -06:00
1 parent acdbfd9ab6
commit 37df4675c0
3 files changed
+139 -88

No files matched your search

@@ -7,7 +7,7 @@
max-height: calc( max-height: calc(
var(--radix-dropdown-menu-content-available-height) - var(--space-6) var(--radix-dropdown-menu-content-available-height) - var(--space-6)
); );
overflow-y: auto; overflow: hidden;
z-index: 1; z-index: 1;
background-color: var(--gray-2); background-color: var(--gray-2);
@@ -21,96 +21,106 @@
border-radius: var(--space-4); border-radius: var(--space-4);
outline: var(--outline-interactive) !important; outline: var(--outline-interactive) !important;
scrollbar-width: none; .viewport {
-ms-overflow-style: none; flex: 1 1 auto;
min-height: 0;
&::-webkit-scrollbar { overflow-y: auto;
display: none;
}
.Separator {
flex-shrink: 0;
height: var(--space-3);
}
.Label {
font-size: var(--font-size-minor);
color: var(--gray-11);
padding: var(--space-3);
padding-left: var(--gutter);
* + & {
margin-top: var(--space-3);
}
}
.Item,
.CheckboxItem,
.RadioItem,
.SubTrigger {
position: relative;
background-color: var(--gray-3);
padding: var(--space-3);
padding-left: var(--gutter);
cursor: pointer;
user-select: none;
display: flex; display: flex;
align-items: center; flex-direction: column;
gap: var(--space-3);
font-size: var(--font-size-minor); scrollbar-width: none;
-ms-overflow-style: none;
&:focus { &::-webkit-scrollbar {
outline: none; display: none;
background-color: var(--gray-5);
} }
&:not(:last-child) { .Separator {
border-bottom: var(--space-1) solid var(--gray-2); flex-shrink: 0;
height: var(--space-3);
} }
&[data-accent] { .Label {
color: var(--accent-11); font-size: var(--font-size-minor);
}
/** color: var(--gray-11);
* This is actually .ItemText, but its class name isn't being passed to the
* html, so I am selecting the span instead.
*/
span {
display: contents;
}
img, padding: var(--space-3);
svg { padding-left: var(--gutter);
width: 1em;
height: 1em;
&:last-child { * + & {
margin-left: auto; margin-top: var(--space-3);
} }
} }
.discriminator { .Item,
display: inline; .CheckboxItem,
margin-left: auto; .RadioItem,
} .SubTrigger {
position: relative;
.ItemIndicator { background-color: var(--gray-3);
position: absolute;
left: 0; padding: var(--space-3);
top: 50%; padding-left: var(--gutter);
cursor: pointer;
user-select: none;
display: flex; display: flex;
align-items: center;
gap: var(--space-3);
transform: translate(calc(-50% + var(--gutter) / 2), -50%); font-size: var(--font-size-minor);
&:focus {
outline: none;
background-color: var(--gray-5);
}
/* Of type, since the curtains' anchor span trails the items */
&:not(:last-of-type) {
border-bottom: var(--space-1) solid var(--gray-2);
}
&[data-accent] {
color: var(--accent-11);
}
/**
* This is actually .ItemText, but its class name isn't being passed to the
* html, so I am selecting the span instead.
*/
span {
display: contents;
}
img,
svg {
width: 1em;
height: 1em;
&:last-child {
margin-left: auto;
}
}
.discriminator {
display: inline;
margin-left: auto;
}
.ItemIndicator {
position: absolute;
left: 0;
top: 50%;
display: flex;
transform: translate(calc(-50% + var(--gutter) / 2), -50%);
}
} }
} }
} }
@@ -2,8 +2,12 @@ import { DropdownMenu as _ } from "radix-ui";
import type { ComponentProps } from "react"; import type { ComponentProps } from "react";
import { classNames } from "../../ui/classNames"; import { classNames } from "../../ui/classNames";
import { composeRadixComponents } from "../../ui/compose"; import { composeRadixComponents } from "../../ui/compose";
import { ScrollerOrientation } from "../Scroller";
import { ScrollerCurtains } from "../ScrollerCurtains";
import styles from "./index.module.css"; import styles from "./index.module.css";
const composed = composeRadixComponents(_, styles);
// Trailing text pushed to the right of an item, like flags or shortcuts // Trailing text pushed to the right of an item, like flags or shortcuts
export function Discriminator({ className, ...props }: ComponentProps<"span">) { export function Discriminator({ className, ...props }: ComponentProps<"span">) {
return ( return (
@@ -11,7 +15,43 @@ export function Discriminator({ className, ...props }: ComponentProps<"span">) {
); );
} }
// Scrolls the items inside the content's rounded frame so the curtains fade
// them into its background instead of fading the frame itself
function Viewport({ children }: ComponentProps<"div">) {
return (
<div className={styles.viewport}>
{children}
<ScrollerCurtains orientation={ScrollerOrientation.Vertical} />
</div>
);
}
function Content({
children,
...props
}: ComponentProps<typeof composed.Content>) {
return (
<composed.Content {...props}>
<Viewport>{children}</Viewport>
</composed.Content>
);
}
function SubContent({
children,
...props
}: ComponentProps<typeof composed.SubContent>) {
return (
<composed.SubContent {...props}>
<Viewport>{children}</Viewport>
</composed.SubContent>
);
}
export const DropdownMenu = { export const DropdownMenu = {
...composeRadixComponents(_, styles), ...composed,
Content,
SubContent,
Discriminator, Discriminator,
}; };
@@ -9,20 +9,6 @@
gap: var(--space-3); gap: var(--space-3);
.nation {
.flag {
position: absolute;
top: 0;
right: 0;
width: var(--space-7);
height: 100%;
background-size: 200%;
background-position: 0% 50%;
}
}
.plus { .plus {
color: var(--gray-11); color: var(--gray-11);
} }
@@ -44,3 +30,18 @@
} }
} }
} }
/* Portaled into the nations dropdown, so it sits outside the scroller */
.nation {
.flag {
position: absolute;
top: 0;
right: 0;
width: var(--space-7);
height: 100%;
background-size: 200%;
background-position: 0% 50%;
}
}