From c13741602c74c2b1575044c3e2f0cb7868309bb2 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 8 Aug 2025 20:59:55 +0200 Subject: [PATCH] UI/select: make z-index adjustable --- .../src/components/Select/Select.module.css | 130 +++++++++--------- .../ui/src/components/Select/Select.tsx | 14 +- 2 files changed, 76 insertions(+), 68 deletions(-) diff --git a/pkgs/clan-app/ui/src/components/Select/Select.module.css b/pkgs/clan-app/ui/src/components/Select/Select.module.css index 986122bd4..2f720449d 100644 --- a/pkgs/clan-app/ui/src/components/Select/Select.module.css +++ b/pkgs/clan-app/ui/src/components/Select/Select.module.css @@ -1,88 +1,88 @@ .trigger { - @apply bg-def-1 flex flex-grow justify-between items-center gap-2 h-7 px-2 py-1; - @apply rounded-[4px]; + @apply bg-def-1 flex flex-grow justify-between items-center gap-2 h-7 px-2 py-1; + @apply rounded-[4px]; - &[data-expanded] { - @apply outline-def-2 outline-1 outline; - z-index: 40; + &[data-expanded] { + @apply outline-def-2 outline-1 outline; + z-index: var(--z-index + 5); + } + + &[data-highlighted] { + @apply outline outline-1 outline-inv-2; + } + + &[data-loading] { + @apply cursor-wait; + } + + &:hover { + @apply bg-def-2; + + & .icon { + @apply bg-def-1 text-fg-def-1; } + } - &[data-highlighted] { - @apply outline outline-1 outline-inv-2 + &:active { + @apply bg-def-4; + + & .icon { + @apply bg-inv-4 text-fg-inv-1; } + } - &[data-loading] { - @apply cursor-wait; - } - - &:hover { - @apply bg-def-2; - - & .icon { - @apply bg-def-1 text-fg-def-1; - } - } - - &:active { - @apply bg-def-4; - - & .icon { - @apply bg-inv-4 text-fg-inv-1; - } - } - - &:focus-visible { - @apply outline-def-2 outline-1 outline; - } + &:focus-visible { + @apply outline-def-2 outline-1 outline; + } } .icon { - @apply bg-def-2 rounded-sm; - @apply flex items-center justify-center h-[14px] w-[14px] p-[2px]; - &[data-disabled] { - @apply cursor-not-allowed; - } - &[data-loading] { - @apply bg-inherit; - } + @apply bg-def-2 rounded-sm; + @apply flex items-center justify-center h-[14px] w-[14px] p-[2px]; + &[data-disabled] { + @apply cursor-not-allowed; + } + &[data-loading] { + @apply bg-inherit; + } } .options_content { - @apply bg-def-1 px-1 py-3 rounded-[4px] -mt-8 pt-10 -mx-1; - @apply outline-def-2 outline-1 outline; + z-index: var(--z-index); - transform-origin: var(--kb-popper-content-transform-origin); - &[data-expanded] { - animation: overlayShow 250ms ease-out; + @apply bg-def-1 px-1 py-3 rounded-[4px] -mt-8 pt-10 -mx-1; + @apply outline-def-2 outline-1 outline; + + transform-origin: var(--kb-popper-content-transform-origin); + &[data-expanded] { + animation: overlayShow 250ms ease-out; + } + + /* Option elements (typically
  • ) */ + & [role="option"] { + @apply px-2 py-4 rounded-sm flex items-center gap-1 flex-shrink-0; + + &[data-highlighted], + &:focus-visible { + @apply outline outline-1 outline-inv-2; } - /* Option elements (typically
  • ) */ - & [role="option"] { - @apply px-1 py-2 rounded-sm flex items-center gap-1 flex-shrink-0 ; - - &[data-highlighted], - &:focus-visible { - @apply outline outline-1 outline-inv-2 - } - - &:hover { - @apply bg-def-2; - } - - &:active { - @apply bg-def-4; - } - + &:hover { + @apply bg-def-2; } - & [role="listbox"] { - &:focus-visible { - @apply outline-none; - } + &:active { + @apply bg-def-4; } + } + + & [role="listbox"] { + &:focus-visible { + @apply outline-none; + } + } } - @keyframes overlayShow { from { opacity: 0; diff --git a/pkgs/clan-app/ui/src/components/Select/Select.tsx b/pkgs/clan-app/ui/src/components/Select/Select.tsx index 2df499f13..325078c1f 100644 --- a/pkgs/clan-app/ui/src/components/Select/Select.tsx +++ b/pkgs/clan-app/ui/src/components/Select/Select.tsx @@ -1,4 +1,4 @@ -import { Select as KSelect } from "@kobalte/core/select"; +import { Select as KSelect, SelectPortalProps } from "@kobalte/core/select"; import Icon from "../Icon/Icon"; import { Orienter } from "../Form/Orienter"; import { Label, LabelProps } from "../Form/Label"; @@ -28,6 +28,8 @@ export type SelectProps = { // Custom props orientation?: "horizontal" | "vertical"; label?: Omit; + portalProps?: Partial; + zIndex?: number; } & ( | { // Sync options @@ -48,6 +50,8 @@ export const Select = (props: SelectProps) => { ["placeholder", "ref", "onInput", "onChange", "onBlur"], ); + const zIndex = () => props.zIndex ?? 40; + const [getValue, setValue] = createSignal