commit d3dc4dced3d5343d6c48482aa51da79c295a286e
parent 509e48434f47d7150309c3f538949cc7339f5194
Author: finwo <finwo@pm.me>
Date: Tue, 3 Nov 2026 19:41:37 +0100
Added custom dropdown controls
Diffstat:
14 files changed, 755 insertions(+), 228 deletions(-)
diff --git a/app/admin/src/assets/admin.css b/app/admin/src/assets/admin.css
@@ -11,21 +11,6 @@
line-height: 1.15;
}
-.realm-select select {
- width: 100%;
- min-width: 0;
- max-width: 100%;
- padding: 0.5rem 0.75rem;
- border: 0;
- border-bottom: 1pt solid var(--field-line);
- border-radius: 0;
- background: var(--surface);
- color: inherit;
- font: inherit;
- font-size: 0.875rem;
- line-height: 1.5;
-}
-
.realm-current {
color: var(--muted);
font-size: 0.875rem;
@@ -337,8 +322,7 @@
@media (pointer: coarse) {
.field-control,
- .field-textarea,
- .realm-select select {
+ .field-textarea {
font-size: 1rem;
}
}
@@ -354,15 +338,6 @@
opacity: 1;
}
-select.field-control,
-.realm-select select {
- appearance: none;
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='0.75em' height='0.75em' viewBox='0 0 24 24' fill='none' stroke='%238a8f95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
- background-repeat: no-repeat;
- background-position: right 0.75rem center;
- padding-right: 2.25rem;
-}
-
.role-field {
margin: 0;
padding: 0;
@@ -430,10 +405,6 @@ select.field-control,
}
@media (min-width: 40em) {
- .realm-select select {
- width: auto;
- }
-
.field-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
diff --git a/app/admin/src/component/client-form.tsx b/app/admin/src/component/client-form.tsx
@@ -1,4 +1,5 @@
import m from 'mithril';
+import { SelectMenu } from '@component/select-menu';
import type { AdminClient, AdminClientInput, AdminRole } from '../util/api';
export interface ClientFormValue {
@@ -123,51 +124,54 @@ export const ClientForm: m.Component<ClientFormAttrs> = {
</div>
<div class="form-field">
- <span class="field-label">Access mode</span>
- <select
- class="field-control"
+ <span class="field-label" id="client-access-mode-label">Access mode</span>
+ <SelectMenu
+ labelledBy="client-access-mode-label"
value={value.access_mode}
- onchange={(event: Event) => {
- value.access_mode = (event.target as HTMLSelectElement)
- .value as ClientFormValue['access_mode'];
+ disabled={attrs.pending}
+ options={[
+ { value: 'internal', label: 'Internal: home-realm members' },
+ { value: 'members', label: 'Members: active realm members' },
+ { value: 'public', label: 'Public: any authenticated user' },
+ ]}
+ onchange={(option) => {
+ value.access_mode = option as ClientFormValue['access_mode'];
}}
- >
- <option value="internal">Internal: home-realm members</option>
- <option value="members">Members: active realm members</option>
- <option value="public">Public: any authenticated user</option>
- </select>
+ />
</div>
<div class="form-field">
- <span class="field-label">Consent</span>
- <select
- class="field-control"
+ <span class="field-label" id="client-consent-mode-label">Consent</span>
+ <SelectMenu
+ labelledBy="client-consent-mode-label"
value={value.consent_mode}
- onchange={(event: Event) => {
- value.consent_mode = (event.target as HTMLSelectElement)
- .value as ClientFormValue['consent_mode'];
+ disabled={attrs.pending}
+ options={[
+ { value: 'remembered', label: 'Remembered: prompt once' },
+ { value: 'trusted', label: 'Trusted: skip for home realm' },
+ ]}
+ onchange={(option) => {
+ value.consent_mode = option as ClientFormValue['consent_mode'];
}}
- >
- <option value="remembered">Remembered: prompt once</option>
- <option value="trusted">Trusted: skip for home realm</option>
- </select>
+ />
</div>
<div class="form-field">
- <span class="field-label">Token authentication</span>
- <select
- class="field-control"
+ <span class="field-label" id="client-token-auth-label">Token authentication</span>
+ <SelectMenu
+ labelledBy="client-token-auth-label"
value={value.token_endpoint_auth_method}
- onchange={(event: Event) => {
- const method = (event.target as HTMLSelectElement)
- .value as ClientFormValue['token_endpoint_auth_method'];
+ disabled={attrs.pending}
+ options={[
+ { value: 'none', label: 'Public client: PKCE' },
+ { value: 'client_secret_basic', label: 'Confidential: client secret' },
+ ]}
+ onchange={(option) => {
+ const method = option as ClientFormValue['token_endpoint_auth_method'];
value.token_endpoint_auth_method = method;
if (method === 'none') value.require_pkce = true;
}}
- >
- <option value="none">Public client: PKCE</option>
- <option value="client_secret_basic">Confidential: client secret</option>
- </select>
+ />
</div>
<label class="checkbox-row">
diff --git a/app/admin/src/component/realm-selector.tsx b/app/admin/src/component/realm-selector.tsx
@@ -1,4 +1,5 @@
import m from 'mithril';
+import { SelectMenu, type SelectMenuOption } from '@component/select-menu';
import type { AdminRealm } from '../util/api';
interface RealmSelectorAttrs {
@@ -14,21 +15,22 @@ export const RealmSelector: m.Component<RealmSelectorAttrs> = {
const { realms, selected, allRealms = false, selectedAll = false } = attrs;
if ((realms && realms.length > 1) || allRealms) {
+ const options: SelectMenuOption[] = [
+ ...(allRealms ? [{ value: 'global', label: 'All realms' }] : []),
+ ...(realms || []).map((realm) => ({ value: realm.slug, label: realm.display_name })),
+ ];
+
return (
- <label class="realm-select">
+ <div class="realm-select">
<span>Realm</span>
- <select
+ <SelectMenu
+ autoWidth
+ ariaLabel="Realm"
value={selectedAll ? 'global' : selected?.slug || ''}
- onchange={(event: Event) => {
- attrs.onchange((event.target as HTMLSelectElement).value);
- }}
- >
- {allRealms ? <option value="global">All realms</option> : null}
- {(realms || []).map((realm) => (
- <option value={realm.slug}>{realm.display_name}</option>
- ))}
- </select>
- </label>
+ options={options}
+ onchange={attrs.onchange}
+ />
+ </div>
);
}
diff --git a/app/admin/src/screen/user.tsx b/app/admin/src/screen/user.tsx
@@ -1,6 +1,7 @@
import m from 'mithril';
import { Modal } from '@component/modal';
import { PageHeader } from '@component/page-header';
+import { SelectMenu } from '@component/select-menu';
import { RealmSelector } from '../component/realm-selector';
import {
createAdminUserBan,
@@ -614,6 +615,7 @@ export const UserPage: m.Component<UserAttrs> = {
</div>
<button
class="button-danger"
+ id="open-ban-dialog"
type="button"
onclick={() => {
this.banClientId = '*';
@@ -725,20 +727,22 @@ export const UserPage: m.Component<UserAttrs> = {
{this.banOpen && detail ? (
<Modal title="Ban from app" onClose={() => this.cancelAction()}>
<div class="form-field">
- <span class="field-label">Application</span>
- <select
- class="field-control"
+ <span class="field-label" id="ban-application-label">Application</span>
+ <SelectMenu
+ labelledBy="ban-application-label"
value={this.banClientId}
- onchange={(event: Event) => {
- this.banClientId = (event.target as HTMLSelectElement).value;
- m.redraw();
+ disabled={this.banPending}
+ options={[
+ { value: '*', label: 'All apps' },
+ ...this.clients.map((client: AdminClient) => ({
+ value: client.client_id,
+ label: client.name,
+ })),
+ ]}
+ onchange={(clientId) => {
+ this.banClientId = clientId;
}}
- >
- <option value="*">All apps</option>
- {this.clients.map((client: AdminClient) => (
- <option value={client.client_id}>{client.name}</option>
- ))}
- </select>
+ />
</div>
<p class="modal-note">
Banning {displayName} revokes matching consents and refresh tokens. The ban remains
diff --git a/app/shared/component/select-menu.tsx b/app/shared/component/select-menu.tsx
@@ -0,0 +1,384 @@
+import { Check, ChevronDown } from 'lucide';
+import m from 'mithril';
+import { Icon } from '@component/icon';
+import '@style/select-menu.css';
+
+let nextSelectId = 0;
+
+export interface SelectMenuOption {
+ value: string;
+ label: string;
+}
+
+export interface SelectMenuAttrs {
+ id?: string;
+ label?: string;
+ ariaLabel?: string;
+ labelledBy?: string;
+ describedBy?: string;
+ value: string;
+ options: SelectMenuOption[];
+ onchange: (value: string) => void;
+ disabled?: boolean;
+ placeholder?: string;
+ className?: string;
+ autoWidth?: boolean;
+}
+
+export class SelectMenu implements m.ClassComponent<SelectMenuAttrs> {
+ private instanceId = `select-${++nextSelectId}`;
+ private attrs!: SelectMenuAttrs;
+ private root?: HTMLElement;
+ private trigger?: HTMLButtonElement;
+ private list?: HTMLElement;
+ private open = false;
+ private activeIndex = -1;
+ private typeahead = '';
+ private typeaheadTimer = 0;
+ private fitSignature = '';
+ private handleDocumentClick?: (event: MouseEvent) => void;
+ private handleViewportChange?: () => void;
+ private handleScroll?: () => void;
+
+ oncreate(vnode: m.VnodeDOM<SelectMenuAttrs>) {
+ this.attrs = vnode.attrs;
+ this.root = vnode.dom as HTMLElement;
+ this.trigger = this.root.querySelector('.select-trigger') as HTMLButtonElement;
+ this.list = this.root.querySelector('.select-list') as HTMLElement;
+
+ this.handleDocumentClick = (event: MouseEvent) => {
+ if (this.open && event.target instanceof Node && !this.root?.contains(event.target)) {
+ this.closePopup(false);
+ }
+ };
+ this.handleViewportChange = () => {
+ this.updateFitWidth();
+ if (this.open) this.positionPopup();
+ };
+ this.handleScroll = () => {
+ if (this.open) this.positionPopup();
+ };
+
+ document.addEventListener('click', this.handleDocumentClick);
+ window.addEventListener('resize', this.handleViewportChange, { passive: true });
+ window.addEventListener('scroll', this.handleScroll, { capture: true, passive: true });
+
+ this.updateFitWidth();
+ }
+
+ onupdate(vnode: m.VnodeDOM<SelectMenuAttrs>) {
+ this.attrs = vnode.attrs;
+
+ if (this.attrs.disabled && this.open) this.closePopup(false);
+
+ this.updateFitWidth();
+ if (this.open) this.positionPopup();
+ }
+
+ onremove() {
+ if (this.handleDocumentClick) document.removeEventListener('click', this.handleDocumentClick);
+ if (this.handleViewportChange) window.removeEventListener('resize', this.handleViewportChange);
+ if (this.handleScroll) window.removeEventListener('scroll', this.handleScroll, true);
+ window.clearTimeout(this.typeaheadTimer);
+ }
+
+ view({ attrs }) {
+ const triggerId = attrs.id || this.instanceId;
+ const listId = `${triggerId}-listbox`;
+ const labelId = `${triggerId}-label`;
+ const labelIdUsed = !attrs.labelledBy && attrs.label ? labelId : undefined;
+ const selected = attrs.options.find((option) => option.value === attrs.value);
+ const selectedLabel = selected?.label || attrs.placeholder || '';
+ const classNames = ['select', attrs.autoWidth ? 'select-auto' : '', attrs.className || '']
+ .filter(Boolean)
+ .join(' ');
+ const activeId = this.open && this.activeIndex >= 0 ? `${triggerId}-option-${this.activeIndex}` : undefined;
+
+ return (
+ <div class={classNames}>
+ {labelIdUsed ? <span id={labelId} class="sr-only">{attrs.label}</span> : null}
+ <button
+ class="select-trigger"
+ type="button"
+ id={triggerId}
+ role="combobox"
+ aria-haspopup="listbox"
+ aria-expanded={String(this.open)}
+ aria-controls={listId}
+ aria-labelledby={attrs.labelledBy || labelIdUsed || undefined}
+ aria-label={attrs.labelledBy || attrs.label || attrs.ariaLabel ? attrs.ariaLabel : undefined}
+ aria-describedby={attrs.describedBy}
+ aria-activedescendant={activeId}
+ disabled={attrs.disabled}
+ onclick={() => {
+ if (attrs.disabled) return;
+ if (this.open) this.closePopup(true);
+ else this.openPopup(this.selectedIndex());
+ }}
+ onkeydown={(event: KeyboardEvent) => this.handleKeydown(event)}
+ >
+ <span class="select-value">{selectedLabel}</span>
+ {Icon(ChevronDown)}
+ </button>
+ <div
+ class="select-list"
+ id={listId}
+ role="listbox"
+ hidden={!this.open}
+ aria-labelledby={attrs.labelledBy || labelIdUsed || undefined}
+ aria-label={attrs.labelledBy || attrs.label ? undefined : attrs.ariaLabel}
+ >
+ {attrs.options.map((option, index) => {
+ const isSelected = option.value === attrs.value;
+ const isActive = this.open && index === this.activeIndex;
+ const optionClass = [
+ 'select-option',
+ isSelected ? 'is-selected' : '',
+ isActive ? 'is-active' : '',
+ ].filter(Boolean).join(' ');
+
+ return (
+ <div
+ class={optionClass}
+ id={`${triggerId}-option-${index}`}
+ role="option"
+ aria-selected={String(isSelected)}
+ onclick={(event: MouseEvent) => {
+ event.preventDefault();
+ this.selectOption(index);
+ }}
+ >
+ <span class="select-option-label">{option.label}</span>
+ <span class="select-option-mark" aria-hidden="true">
+ {Icon(Check)}
+ </span>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+ }
+
+ private selectedIndex() {
+ const index = this.attrs.options.findIndex((option) => option.value === this.attrs.value);
+
+ return index >= 0 ? index : 0;
+ }
+
+ private boundedIndex(index: number) {
+ const options = this.attrs.options;
+ if (!options.length) return -1;
+
+ return Math.max(0, Math.min(index, options.length - 1));
+ }
+
+ private openPopup(index: number) {
+ if (this.attrs.disabled || !this.attrs.options.length) return;
+
+ this.open = true;
+ this.activeIndex = this.boundedIndex(index);
+ m.redraw.sync();
+ this.positionPopup();
+ this.scrollActiveOption();
+ }
+
+ private closePopup(focusTrigger: boolean) {
+ if (!this.open) return;
+
+ this.open = false;
+ this.activeIndex = -1;
+ this.typeahead = '';
+ window.clearTimeout(this.typeaheadTimer);
+ m.redraw.sync();
+
+ if (focusTrigger) this.trigger?.focus();
+ }
+
+ private selectOption(index: number) {
+ const option = this.attrs.options[index];
+ if (!option) return;
+
+ const attrs = this.attrs;
+ this.open = false;
+ this.activeIndex = -1;
+ this.typeahead = '';
+ window.clearTimeout(this.typeaheadTimer);
+ m.redraw.sync();
+ attrs.onchange(option.value);
+
+ if (this.root?.isConnected && document.activeElement !== this.trigger) this.trigger?.focus();
+ }
+
+ private activateOption(index: number) {
+ if (!this.open) return;
+
+ this.activeIndex = this.boundedIndex(index);
+ m.redraw.sync();
+ this.scrollActiveOption();
+ }
+
+ private findMatch(query: string) {
+ const options = this.attrs.options;
+ if (!options.length) return -1;
+
+ const start = (this.activeIndex + 1) % options.length;
+
+ for (let offset = 0; offset < options.length; offset += 1) {
+ const index = (start + offset) % options.length;
+ if (options[index].label.toLowerCase().startsWith(query.toLowerCase())) return index;
+ }
+
+ return -1;
+ }
+
+ private handleKeydown(event: KeyboardEvent) {
+ const attrs = this.attrs;
+ if (!attrs || attrs.disabled || event.altKey || event.ctrlKey || event.metaKey) return;
+
+ if (event.key === 'Escape') {
+ if (!this.open) return;
+ event.preventDefault();
+ event.stopPropagation();
+ this.closePopup(true);
+ return;
+ }
+
+ if (event.key === 'Tab') {
+ if (this.open) this.closePopup(false);
+ return;
+ }
+
+ if (event.key === 'ArrowDown') {
+ event.preventDefault();
+ if (!this.open) this.openPopup(0);
+ else this.activateOption(this.activeIndex + 1);
+ return;
+ }
+
+ if (event.key === 'ArrowUp') {
+ event.preventDefault();
+ if (!this.open) this.openPopup(attrs.options.length - 1);
+ else this.activateOption(this.activeIndex - 1);
+ return;
+ }
+
+ if (event.key === 'Home') {
+ event.preventDefault();
+ if (!this.open) this.openPopup(0);
+ else this.activateOption(0);
+ return;
+ }
+
+ if (event.key === 'End') {
+ event.preventDefault();
+ if (!this.open) this.openPopup(attrs.options.length - 1);
+ else this.activateOption(attrs.options.length - 1);
+ return;
+ }
+
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.preventDefault();
+ if (!this.open) this.openPopup(this.selectedIndex());
+ else this.selectOption(this.activeIndex);
+ return;
+ }
+
+ if (event.key.length === 1) {
+ event.preventDefault();
+ if (!this.open) this.openPopup(0);
+
+ this.typeahead += event.key;
+ window.clearTimeout(this.typeaheadTimer);
+ this.typeaheadTimer = window.setTimeout(() => {
+ this.typeahead = '';
+ }, 500);
+
+ const match = this.findMatch(this.typeahead);
+ if (match >= 0) this.activateOption(match);
+ }
+ }
+
+ private scrollActiveOption() {
+ const list = this.list;
+ if (!list || this.activeIndex < 0) return;
+
+ const option = list.children[this.activeIndex] as HTMLElement | undefined;
+ if (!option) return;
+
+ const optionTop = option.offsetTop;
+ const optionBottom = optionTop + option.offsetHeight;
+
+ if (optionTop < list.scrollTop) {
+ list.scrollTop = optionTop;
+ return;
+ }
+
+ if (optionBottom > list.scrollTop + list.clientHeight) {
+ list.scrollTop = optionBottom - list.clientHeight;
+ }
+ }
+
+ private rootFontSize() {
+ const size = Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);
+
+ return Number.isFinite(size) && size > 0 ? size : 16;
+ }
+
+ private updateFitWidth() {
+ const signature = `${this.attrs.options.length}:${this.attrs.options.map((option) => option.label).join('\u0000')}`;
+ if (signature === this.fitSignature || this.open) return;
+
+ this.fitSignature = signature;
+ this.fitWidth();
+ }
+
+ private fitWidth() {
+ const root = this.root;
+ const list = this.list;
+ if (!root || !list || !root.classList.contains('select-auto') || this.open) return;
+
+ const wasHidden = list.hasAttribute('hidden');
+ list.removeAttribute('hidden');
+ list.classList.add('is-measuring');
+
+ const font = this.rootFontSize();
+ const containerWidth = root.getBoundingClientRect().width;
+ const measuredWidth = Math.max(containerWidth, list.getBoundingClientRect().width);
+ const allowedWidth = Math.min(measuredWidth, window.innerWidth - font);
+
+ root.style.minWidth = `${allowedWidth / font}rem`;
+
+ list.classList.remove('is-measuring');
+ if (wasHidden) list.setAttribute('hidden', '');
+ }
+
+ private positionPopup() {
+ const list = this.list;
+ const trigger = this.trigger;
+ if (!this.open || !list || !trigger) return;
+
+ const font = this.rootFontSize();
+ const rect = trigger.getBoundingClientRect();
+ const viewportWidth = window.innerWidth / font;
+ const listWidth = Math.min(rect.width / font, viewportWidth - 1);
+ const spaceBelow = (window.innerHeight - rect.bottom) / font - 0.5;
+ const spaceAbove = rect.top / font - 0.5;
+ const openBelow = spaceBelow >= spaceAbove;
+ const availableHeight = openBelow ? spaceBelow : spaceAbove;
+ const listHeight = Math.max(5, Math.min(18, availableHeight));
+
+ list.style.width = `${listWidth}rem`;
+ list.style.maxHeight = `${listHeight}rem`;
+ list.style.right = 'auto';
+ list.style.left = `${Math.max(0, Math.min(rect.left / font, viewportWidth - listWidth))}rem`;
+
+ if (openBelow) {
+ list.style.top = `${rect.bottom / font}rem`;
+ list.style.bottom = 'auto';
+ } else {
+ list.style.top = 'auto';
+ list.style.bottom = `${(window.innerHeight - rect.top) / font}rem`;
+ }
+ }
+}
diff --git a/app/shared/style/global.css b/app/shared/style/global.css
@@ -1294,7 +1294,6 @@ select:focus-visible {
.table-search input,
.field-control,
.field-textarea,
- .realm-select select,
.checkbox-row,
.auth-choice {
min-height: 2.75rem;
diff --git a/app/shared/style/select-menu.css b/app/shared/style/select-menu.css
@@ -0,0 +1,150 @@
+.select {
+ min-width: 0;
+ max-width: 100%;
+ display: block;
+}
+
+.select-trigger {
+ width: 100%;
+ min-width: 0;
+ max-width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.75rem;
+ padding: 0.5rem 0.75rem;
+ border: 0;
+ border-bottom: 1pt solid var(--field-line);
+ border-radius: 0;
+ background: var(--surface);
+ color: inherit;
+ font: inherit;
+ font-size: 0.875rem;
+ line-height: 1.5;
+ text-align: left;
+ cursor: pointer;
+}
+
+.select-trigger:focus,
+.select-trigger:focus-visible,
+.select-trigger[aria-expanded="true"],
+.select-trigger[aria-expanded="true"]:focus-visible {
+ outline: 0;
+ border-bottom-color: var(--accent);
+}
+
+.select-trigger:disabled {
+ color: var(--muted);
+ cursor: default;
+ opacity: 1;
+}
+
+.select-trigger svg {
+ flex: none;
+ width: 1.125rem;
+ height: 1.125rem;
+}
+
+.select-value {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.select-list {
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 120;
+ width: 10rem;
+ max-width: calc(100vw - 1rem);
+ max-height: min(18rem, 45vh);
+ padding: 0.25rem 0;
+ overflow-y: auto;
+ overscroll-behavior: contain;
+ background: var(--surface);
+ box-shadow: var(--shadow);
+ color: var(--text);
+}
+
+.select-list.is-measuring {
+ visibility: hidden;
+ top: 0;
+ right: auto;
+ bottom: auto;
+ left: 0;
+ width: auto;
+ max-height: none;
+}
+
+.select-option {
+ width: 100%;
+ min-height: 2.25rem;
+ display: flex;
+ align-items: center;
+ gap: 0;
+ padding: 0.5rem 0.75rem;
+ color: inherit;
+ font-size: 0.875rem;
+ line-height: 1.5;
+ cursor: pointer;
+}
+
+.select-option-mark {
+ width: 1.25rem;
+ height: 1.25rem;
+ flex: none;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ order: 2;
+}
+
+.select-option svg {
+ width: 1.125rem;
+ height: 1.125rem;
+}
+
+.select-option:not(.is-selected) .select-option-mark svg {
+ visibility: hidden;
+}
+
+.select-option-label {
+ min-width: 0;
+ flex: 1;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.select-option:hover {
+ background: var(--row-hover);
+}
+
+.select-option.is-active {
+ background: var(--row-hover);
+}
+
+.select-option.is-selected {
+ color: var(--accent-text);
+}
+
+@media (pointer: coarse) {
+ .select-trigger,
+ .select-option {
+ min-height: 2.75rem;
+ padding-block: 0.5rem;
+ touch-action: manipulation;
+ }
+
+ .select-trigger {
+ font-size: 1rem;
+ }
+}
+
+@media (min-width: 40em) {
+ .select.select-auto {
+ width: auto;
+ }
+}
diff --git a/mockup/plain/admin-clients.html b/mockup/plain/admin-clients.html
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Admin clients mockup</title>
<link rel="stylesheet" href="./global.css" />
+ <link rel="stylesheet" href="./select-menu.css" />
</head>
<body>
<header class="topbar">
diff --git a/mockup/plain/admin-settings.html b/mockup/plain/admin-settings.html
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Admin realm settings mockup</title>
<link rel="stylesheet" href="./global.css" />
+ <link rel="stylesheet" href="./select-menu.css" />
<style>
.settings-form {
min-width: 0;
diff --git a/mockup/plain/admin-user-detail.html b/mockup/plain/admin-user-detail.html
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Admin user detail mockup</title>
<link rel="stylesheet" href="./global.css" />
+ <link rel="stylesheet" href="./select-menu.css" />
</head>
<body>
<header class="topbar">
diff --git a/mockup/plain/admin-users.html b/mockup/plain/admin-users.html
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Admin users mockup</title>
<link rel="stylesheet" href="./global.css" />
+ <link rel="stylesheet" href="./select-menu.css" />
</head>
<body>
<header class="topbar">
diff --git a/mockup/plain/dropdown-menu.html b/mockup/plain/dropdown-menu.html
@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Custom dropdown mockup</title>
<link rel="stylesheet" href="./global.css" />
+ <link rel="stylesheet" href="./select-menu.css" />
<style>
.dropdown-stack {
display: grid;
diff --git a/mockup/plain/global.css b/mockup/plain/global.css
@@ -702,138 +702,6 @@ html.mobile-nav-open .mobile-nav .nav-item {
line-height: 1.15;
}
-.select {
- min-width: 0;
- max-width: 100%;
- display: block;
-}
-
-.select-trigger {
- width: 100%;
- min-width: 0;
- max-width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 0.75rem;
- padding: 0.5rem 0.75rem;
- border: 0;
- border-bottom: 1pt solid var(--field-line);
- border-radius: 0;
- background: var(--surface);
- color: inherit;
- font: inherit;
- font-size: 0.875rem;
- line-height: 1.5;
- text-align: left;
- cursor: pointer;
-}
-
-.select-trigger:focus,
-.select-trigger:focus-visible,
-.select-trigger[aria-expanded="true"],
-.select-trigger[aria-expanded="true"]:focus-visible {
- outline: 0;
- border-bottom-color: var(--accent);
-}
-
-.select-trigger:disabled {
- color: var(--muted);
- cursor: default;
- opacity: 1;
-}
-
-.select-trigger svg {
- flex: none;
- width: 1.125rem;
- height: 1.125rem;
-}
-
-.select-value {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.select-list {
- position: fixed;
- top: 0;
- left: 0;
- z-index: 120;
- width: 10rem;
- max-width: calc(100vw - 1rem);
- max-height: min(18rem, 45vh);
- padding: 0.25rem 0;
- overflow-y: auto;
- overscroll-behavior: contain;
- background: var(--surface);
- box-shadow: var(--shadow);
- color: var(--text);
-}
-
-.select-list.is-measuring {
- visibility: hidden;
- top: 0;
- right: auto;
- bottom: auto;
- left: 0;
- width: auto;
- max-height: none;
-}
-
-.select-option {
- width: 100%;
- min-height: 2.25rem;
- display: flex;
- align-items: center;
- gap: 0;
- padding: 0.5rem 0.75rem;
- color: inherit;
- font-size: 0.875rem;
- line-height: 1.5;
- cursor: pointer;
-}
-
-.select-option-mark {
- width: 1.25rem;
- height: 1.25rem;
- flex: none;
- display: flex;
- align-items: center;
- justify-content: center;
- order: 2;
-}
-
-.select-option svg {
- width: 1.125rem;
- height: 1.125rem;
-}
-
-.select-option:not(.is-selected) .select-option-mark svg {
- visibility: hidden;
-}
-
-.select-option-label {
- min-width: 0;
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.select-option:hover {
- background: var(--row-hover);
-}
-
-.select-option.is-active {
- background: var(--row-hover);
-}
-
-.select-option.is-selected {
- color: var(--accent-text);
-}
-
.sr-only {
position: absolute;
width: 1pt;
@@ -1311,8 +1179,6 @@ summary:focus-visible {
.table-search input,
.field-control,
.field-textarea,
- .select-trigger,
- .select-option,
.checkbox-row,
.auth-choice {
min-height: 2.75rem;
@@ -1320,10 +1186,6 @@ summary:focus-visible {
touch-action: manipulation;
}
- .select-trigger {
- font-size: 1rem;
- }
-
.user-menu summary:hover,
.user-menu summary:active,
.user-menu-item:hover,
@@ -1448,10 +1310,6 @@ summary:focus-visible {
width: 1%;
}
- .realm-select .select {
- width: auto;
- }
-
.details > div {
grid-template-columns: 8.5rem minmax(0, 1fr);
}
diff --git a/mockup/plain/select-menu.css b/mockup/plain/select-menu.css
@@ -0,0 +1,150 @@
+.select {
+ min-width: 0;
+ max-width: 100%;
+ display: block;
+}
+
+.select-trigger {
+ width: 100%;
+ min-width: 0;
+ max-width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.75rem;
+ padding: 0.5rem 0.75rem;
+ border: 0;
+ border-bottom: 1pt solid var(--field-line);
+ border-radius: 0;
+ background: var(--surface);
+ color: inherit;
+ font: inherit;
+ font-size: 0.875rem;
+ line-height: 1.5;
+ text-align: left;
+ cursor: pointer;
+}
+
+.select-trigger:focus,
+.select-trigger:focus-visible,
+.select-trigger[aria-expanded="true"],
+.select-trigger[aria-expanded="true"]:focus-visible {
+ outline: 0;
+ border-bottom-color: var(--accent);
+}
+
+.select-trigger:disabled {
+ color: var(--muted);
+ cursor: default;
+ opacity: 1;
+}
+
+.select-trigger svg {
+ flex: none;
+ width: 1.125rem;
+ height: 1.125rem;
+}
+
+.select-value {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.select-list {
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 120;
+ width: 10rem;
+ max-width: calc(100vw - 1rem);
+ max-height: min(18rem, 45vh);
+ padding: 0.25rem 0;
+ overflow-y: auto;
+ overscroll-behavior: contain;
+ background: var(--surface);
+ box-shadow: var(--shadow);
+ color: var(--text);
+}
+
+.select-list.is-measuring {
+ visibility: hidden;
+ top: 0;
+ right: auto;
+ bottom: auto;
+ left: 0;
+ width: auto;
+ max-height: none;
+}
+
+.select-option {
+ width: 100%;
+ min-height: 2.25rem;
+ display: flex;
+ align-items: center;
+ gap: 0;
+ padding: 0.5rem 0.75rem;
+ color: inherit;
+ font-size: 0.875rem;
+ line-height: 1.5;
+ cursor: pointer;
+}
+
+.select-option-mark {
+ width: 1.25rem;
+ height: 1.25rem;
+ flex: none;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ order: 2;
+}
+
+.select-option svg {
+ width: 1.125rem;
+ height: 1.125rem;
+}
+
+.select-option:not(.is-selected) .select-option-mark svg {
+ visibility: hidden;
+}
+
+.select-option-label {
+ min-width: 0;
+ flex: 1;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.select-option:hover {
+ background: var(--row-hover);
+}
+
+.select-option.is-active {
+ background: var(--row-hover);
+}
+
+.select-option.is-selected {
+ color: var(--accent-text);
+}
+
+@media (pointer: coarse) {
+ .select-trigger,
+ .select-option {
+ min-height: 2.75rem;
+ padding-block: 0.5rem;
+ touch-action: manipulation;
+ }
+
+ .select-trigger {
+ font-size: 1rem;
+ }
+}
+
+@media (min-width: 40em) {
+ .realm-select .select {
+ width: auto;
+ }
+}