Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Updated simple-dropdown styling.
nzbdav-dev139971a3987d
diff --git a/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.module.css b/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.module.cssindex 8ce44262..c444f922 100644--- a/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.module.css+++ b/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.module.css@@ -3,6 +3,31 @@display: inline-block;}+.nativeSelect {+ display: none;+}++@media not (min-width: 900px) {+ .nativeSelect {+ display: block;+ position: absolute;+ min-width: 70px;+ opacity: 0;+ cursor: pointer;+ z-index: 10;+ }++ .dropdown {+ display: none;+ }+}++.bordered {+ border: 1px solid;+ border-radius: 5px;+ padding: 0 5px;+}+.selected {color: hsl(180, 7%, 55%);font-size: 0.9em;@@ -39,8 +64,17 @@background: hsl(196.8 80% 7%);border: 1px solid rgba(255, 255, 255, 0.1);margin-top: 4px;- z-index: 1000;- min-width: 100%;+ z-index: 900;+ min-width: 75px;+ max-height: 300px;+ overflow-y: auto;+}++.dropdown.openAbove {+ top: auto;+ bottom: 100%;+ margin-top: 0;+ margin-bottom: 4px;}.option {diff --git a/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.module.css.d.ts b/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.module.css.d.tsindex 4e6a97a8..6e1ecde9 100644--- a/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.module.css.d.ts+++ b/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.module.css.d.ts@@ -1,8 +1,11 @@declare const styles: {readonly "container": string;+ readonly "bordered": string;+ readonly "nativeSelect": string;readonly "selected": string;readonly "arrow": string;readonly "dropdown": string;+ readonly "openAbove": string;readonly "option": string;};export = styles;diff --git a/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.tsx b/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.tsxindex 4a47cada..ec57c4a7 100644--- a/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.tsx+++ b/frontend/app/routes/queue/components/simple-dropdown/simple-dropdown.tsx@@ -1,25 +1,41 @@-import { useCallback, useEffect, useRef, useState } from "react"+import { memo, useCallback, useEffect, useRef, useState, type ChangeEvent } from "react"import styles from "./simple-dropdown.module.css"+import { classNames } from "~/utils/styling";export type SimpleDropdownProps = {+ type?: "plain" | "bordered"options: string[],value: string,onChange: (value: string) => void,}-export function SimpleDropdown({ options, value, onChange }: SimpleDropdownProps) {+export const SimpleDropdown = memo(({ type, options, value, onChange }: SimpleDropdownProps) => {const [isOpen, setIsOpen] = useState(false);+ const [openAbove, setOpenAbove] = useState(false);const dropdownRef = useRef<HTMLDivElement>(null);+ const containerClassNames = classNames([+ styles.container,+ type === "bordered" && styles.bordered+ ]);const toggleDropdown = useCallback(() => {+ if (!isOpen && dropdownRef.current) {+ const rect = dropdownRef.current.getBoundingClientRect();+ const viewportHeight = window.innerHeight;+ setOpenAbove(rect.top > viewportHeight / 2);+ }setIsOpen(prev => !prev);- }, []);+ }, [isOpen]);const handleOptionClick = useCallback((option: string) => {onChange(option);setIsOpen(false);}, [onChange]);+ const handleNativeChange = useCallback((e: ChangeEvent<HTMLSelectElement>) => {+ onChange(e.target.value);+ }, [onChange]);+// Close dropdown when clicking outsideuseEffect(() => {const handleClickOutside = (event: MouseEvent) => {@@ -38,19 +54,25 @@ export function SimpleDropdown({ options, value, onChange }: SimpleDropdownProps}, [isOpen]);return (- <div className={styles.container} ref={dropdownRef}>+ <div className={containerClassNames} ref={dropdownRef}>+ {/* hidden native select for mobile devices */}+ <select className={styles.nativeSelect} value={value} onChange={handleNativeChange}>+ {options.map(option => (+ <option key={option} value={option}>{option}</option>+ ))}+ </select>++ {/* styled visible dropdown box */}<div className={styles.selected} onClick={toggleDropdown}>{value}<span className={styles.arrow}></span></div>++ {/* styled dropdown selection options for desktop devices */}{isOpen && (- <div className={styles.dropdown}>+ <div className={classNames([styles.dropdown, openAbove && styles.openAbove])}>{options.map(option => (- <div- key={option}- className={styles.option}- onClick={() => handleOptionClick(option)}- >+ <div key={option} className={styles.option} onClick={() => handleOptionClick(option)}>{option}</div>))}@@ -58,4 +80,4 @@ export function SimpleDropdown({ options, value, onChange }: SimpleDropdownProps)}</div>);-}+});