mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-04 23:32:54 +01:00
curtains
This commit is contained in:
3 files changed
+139
-88
No files matched your search
@@ -7,7 +7,7 @@
|
||||
max-height: calc(
|
||||
var(--radix-dropdown-menu-content-available-height) - var(--space-6)
|
||||
);
|
||||
overflow-y: auto;
|
||||
overflow: hidden;
|
||||
|
||||
z-index: 1;
|
||||
background-color: var(--gray-2);
|
||||
@@ -21,96 +21,106 @@
|
||||
border-radius: var(--space-4);
|
||||
outline: var(--outline-interactive) !important;
|
||||
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
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;
|
||||
.viewport {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
flex-direction: column;
|
||||
|
||||
font-size: var(--font-size-minor);
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
|
||||
background-color: var(--gray-5);
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:not(:last-child) {
|
||||
border-bottom: var(--space-1) solid var(--gray-2);
|
||||
.Separator {
|
||||
flex-shrink: 0;
|
||||
height: var(--space-3);
|
||||
}
|
||||
|
||||
&[data-accent] {
|
||||
color: var(--accent-11);
|
||||
}
|
||||
.Label {
|
||||
font-size: var(--font-size-minor);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
color: var(--gray-11);
|
||||
|
||||
img,
|
||||
svg {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
padding: var(--space-3);
|
||||
padding-left: var(--gutter);
|
||||
|
||||
&:last-child {
|
||||
margin-left: auto;
|
||||
* + & {
|
||||
margin-top: var(--space-3);
|
||||
}
|
||||
}
|
||||
|
||||
.discriminator {
|
||||
display: inline;
|
||||
margin-left: auto;
|
||||
}
|
||||
.Item,
|
||||
.CheckboxItem,
|
||||
.RadioItem,
|
||||
.SubTrigger {
|
||||
position: relative;
|
||||
|
||||
.ItemIndicator {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
background-color: var(--gray-3);
|
||||
|
||||
padding: var(--space-3);
|
||||
padding-left: var(--gutter);
|
||||
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
|
||||
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 { classNames } from "../../ui/classNames";
|
||||
import { composeRadixComponents } from "../../ui/compose";
|
||||
import { ScrollerOrientation } from "../Scroller";
|
||||
import { ScrollerCurtains } from "../ScrollerCurtains";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
const composed = composeRadixComponents(_, styles);
|
||||
|
||||
// Trailing text pushed to the right of an item, like flags or shortcuts
|
||||
export function Discriminator({ className, ...props }: ComponentProps<"span">) {
|
||||
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 = {
|
||||
...composeRadixComponents(_, styles),
|
||||
...composed,
|
||||
|
||||
Content,
|
||||
SubContent,
|
||||
Discriminator,
|
||||
};
|
||||
@@ -9,20 +9,6 @@
|
||||
|
||||
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 {
|
||||
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%;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user