tweak language slightly.
This commit is contained in:
parent
c0fc1ba817
commit
b286a4118f
2 changed files with 41 additions and 15 deletions
|
|
@ -10,22 +10,23 @@ interface ShowOverlayProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const overlayOptions = [
|
const overlayOptions = [
|
||||||
{ value: "none", label: "Do not show" },
|
{ value: "none", label: "None" },
|
||||||
{ value: "bottom", label: "On bottom" },
|
{ value: "bottom", label: "Bottom" },
|
||||||
{ value: "top", label: "On top" }
|
{ value: "top", label: "Top" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const ShowOverlay: React.FC<ShowOverlayProps> = ({
|
export const ShowOverlay: React.FC<ShowOverlayProps> = ({
|
||||||
descriptionMode = "tooltip",
|
descriptionMode = "tooltip",
|
||||||
grouped = false
|
grouped = false,
|
||||||
}) => {
|
}) => {
|
||||||
const { getSetting, updateSetting, isUpdating } = useSettings();
|
const { getSetting, updateSetting, isUpdating } = useSettings();
|
||||||
|
|
||||||
const selectedPosition = (getSetting("overlay_position") || "bottom") as OverlayPosition;
|
const selectedPosition = (getSetting("overlay_position") ||
|
||||||
|
"bottom") as OverlayPosition;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingContainer
|
<SettingContainer
|
||||||
title="Show Overlay"
|
title="Overlay Position"
|
||||||
description="Display visual feedback overlay during recording and transcription"
|
description="Display visual feedback overlay during recording and transcription"
|
||||||
descriptionMode={descriptionMode}
|
descriptionMode={descriptionMode}
|
||||||
grouped={grouped}
|
grouped={grouped}
|
||||||
|
|
@ -33,7 +34,9 @@ export const ShowOverlay: React.FC<ShowOverlayProps> = ({
|
||||||
<Dropdown
|
<Dropdown
|
||||||
options={overlayOptions}
|
options={overlayOptions}
|
||||||
selectedValue={selectedPosition}
|
selectedValue={selectedPosition}
|
||||||
onSelect={(value) => updateSetting("overlay_position", value as OverlayPosition)}
|
onSelect={(value) =>
|
||||||
|
updateSetting("overlay_position", value as OverlayPosition)
|
||||||
|
}
|
||||||
disabled={isUpdating("overlay_position")}
|
disabled={isUpdating("overlay_position")}
|
||||||
/>
|
/>
|
||||||
</SettingContainer>
|
</SettingContainer>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ export interface DropdownOption {
|
||||||
|
|
||||||
interface DropdownProps {
|
interface DropdownProps {
|
||||||
options: DropdownOption[];
|
options: DropdownOption[];
|
||||||
|
className?: string;
|
||||||
selectedValue: string | null;
|
selectedValue: string | null;
|
||||||
onSelect: (value: string) => void;
|
onSelect: (value: string) => void;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
|
@ -18,6 +19,7 @@ export const Dropdown: React.FC<DropdownProps> = ({
|
||||||
options,
|
options,
|
||||||
selectedValue,
|
selectedValue,
|
||||||
onSelect,
|
onSelect,
|
||||||
|
className = "",
|
||||||
placeholder = "Select an option...",
|
placeholder = "Select an option...",
|
||||||
disabled = false,
|
disabled = false,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
|
|
@ -27,7 +29,10 @@ export const Dropdown: React.FC<DropdownProps> = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleClickOutside = (event: MouseEvent) => {
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
|
if (
|
||||||
|
dropdownRef.current &&
|
||||||
|
!dropdownRef.current.contains(event.target as Node)
|
||||||
|
) {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -35,7 +40,9 @@ export const Dropdown: React.FC<DropdownProps> = ({
|
||||||
return () => document.removeEventListener("mousedown", handleClickOutside);
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const selectedOption = options.find(option => option.value === selectedValue);
|
const selectedOption = options.find(
|
||||||
|
(option) => option.value === selectedValue,
|
||||||
|
);
|
||||||
|
|
||||||
const handleSelect = (value: string) => {
|
const handleSelect = (value: string) => {
|
||||||
onSelect(value);
|
onSelect(value);
|
||||||
|
|
@ -49,31 +56,47 @@ export const Dropdown: React.FC<DropdownProps> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative" ref={dropdownRef}>
|
<div className={`relative ${className}`} ref={dropdownRef}>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`px-2 py-1 text-sm font-semibold bg-mid-gray/10 border border-mid-gray/80 rounded min-w-[200px] text-left flex items-center justify-between transition-all duration-150 ${
|
className={`px-2 py-1 text-sm font-semibold bg-mid-gray/10 border border-mid-gray/80 rounded min-w-[200px] text-left flex items-center justify-between transition-all duration-150 ${
|
||||||
disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-logo-primary/10 cursor-pointer hover:border-logo-primary"
|
disabled
|
||||||
|
? "opacity-50 cursor-not-allowed"
|
||||||
|
: "hover:bg-logo-primary/10 cursor-pointer hover:border-logo-primary"
|
||||||
}`}
|
}`}
|
||||||
onClick={handleToggle}
|
onClick={handleToggle}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<span className="truncate">{selectedOption?.label || placeholder}</span>
|
<span className="truncate">{selectedOption?.label || placeholder}</span>
|
||||||
<svg className={`w-4 h-4 ml-2 transition-transform duration-200 ${isOpen ? "transform rotate-180" : ""}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 9l-7 7-7-7" />
|
className={`w-4 h-4 ml-2 transition-transform duration-200 ${isOpen ? "transform rotate-180" : ""}`}
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth={2}
|
||||||
|
d="M19 9l-7 7-7-7"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
{isOpen && !disabled && (
|
{isOpen && !disabled && (
|
||||||
<div className="absolute top-full left-0 right-0 mt-1 bg-background border border-mid-gray/80 rounded shadow-lg z-50 max-h-60 overflow-y-auto">
|
<div className="absolute top-full left-0 right-0 mt-1 bg-background border border-mid-gray/80 rounded shadow-lg z-50 max-h-60 overflow-y-auto">
|
||||||
{options.length === 0 ? (
|
{options.length === 0 ? (
|
||||||
<div className="px-2 py-1 text-sm text-mid-gray">No options found</div>
|
<div className="px-2 py-1 text-sm text-mid-gray">
|
||||||
|
No options found
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
options.map((option) => (
|
options.map((option) => (
|
||||||
<button
|
<button
|
||||||
key={option.value}
|
key={option.value}
|
||||||
type="button"
|
type="button"
|
||||||
className={`w-full px-2 py-1 text-sm text-left hover:bg-logo-primary/10 transition-colors duration-150 ${
|
className={`w-full px-2 py-1 text-sm text-left hover:bg-logo-primary/10 transition-colors duration-150 ${
|
||||||
selectedValue === option.value ? "bg-logo-primary/20 text-logo-primary font-semibold" : ""
|
selectedValue === option.value
|
||||||
|
? "bg-logo-primary/20 text-logo-primary font-semibold"
|
||||||
|
: ""
|
||||||
}`}
|
}`}
|
||||||
onClick={() => handleSelect(option.value)}
|
onClick={() => handleSelect(option.value)}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue