mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-16 05:31:14 +01:00
Polish the import source list
The URL link and menu item stay enabled and focus the field on repeat clicks, waiting out the menu's focus return. Larger empty-state icon, inline links inherit the text color with a translucent underline, and card rows use a muted trash icon for removal.
This commit is contained in:
1 parent
aa10c44a45
commit
9e51e95f9e
2 files changed
+14
-13
No files matched your search
@@ -55,8 +55,15 @@ export function ImportSourceList({
|
||||
const [isHovering, setIsHovering] = useState(false);
|
||||
const [pathInput, setPathInput] = useState("");
|
||||
const [showPathInput, setShowPathInput] = useState(false);
|
||||
const pathInputRef = useRef<{ focus: () => void }>(null);
|
||||
const trimmedPath = pathInput.trim();
|
||||
|
||||
const openPathInput = () => {
|
||||
setShowPathInput(true);
|
||||
// The add-row menu hands focus back to its trigger as it closes, on a timer, so focus after it
|
||||
setTimeout(() => pathInputRef.current?.focus(), 50);
|
||||
};
|
||||
|
||||
const closePathInput = () => {
|
||||
setPathInput("");
|
||||
setShowPathInput(false);
|
||||
@@ -114,6 +121,7 @@ export function ImportSourceList({
|
||||
|
||||
const pathInputEl = (
|
||||
<PlainInput
|
||||
ref={pathInputRef}
|
||||
label="URL or file path"
|
||||
hideLabel
|
||||
size="sm"
|
||||
@@ -145,7 +153,7 @@ export function ImportSourceList({
|
||||
isHovering ? "border-notice bg-surface-highlight" : "border-dashed border-border",
|
||||
)}
|
||||
>
|
||||
<Icon icon="folder_input" className="text-text-subtlest w-8! h-8!" />
|
||||
<Icon icon="folder_input" className="text-text-subtlest w-10! h-10! mb-1" />
|
||||
{isHovering ? (
|
||||
<span>Drop to add</span>
|
||||
) : (
|
||||
@@ -159,10 +167,7 @@ export function ImportSourceList({
|
||||
folder
|
||||
</InlineButton>
|
||||
, or a{" "}
|
||||
<InlineButton
|
||||
disabled={disabled || showPathInput}
|
||||
onClick={() => setShowPathInput(true)}
|
||||
>
|
||||
<InlineButton disabled={disabled} onClick={openPathInput}>
|
||||
URL
|
||||
</InlineButton>
|
||||
, or drag them here
|
||||
@@ -188,12 +193,7 @@ export function ImportSourceList({
|
||||
addItems={[
|
||||
{ label: "Files", icon: "file", onSelect: () => pick(false) },
|
||||
{ label: "Folder", icon: "folder", onSelect: () => pick(true) },
|
||||
{
|
||||
label: "URL or file path",
|
||||
icon: "globe",
|
||||
disabled: showPathInput,
|
||||
onSelect: () => setShowPathInput(true),
|
||||
},
|
||||
{ label: "URL or file path", icon: "globe", onSelect: openPathInput },
|
||||
]}
|
||||
items={sources.map((source) => {
|
||||
const detection = detections[source.path];
|
||||
@@ -262,7 +262,7 @@ export function InlineButton({
|
||||
<button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className="text-text underline underline-offset-2 hocus:text-primary disabled:opacity-disabled"
|
||||
className="underline decoration-current/40 underline-offset-3 hocus:decoration-current disabled:opacity-disabled"
|
||||
onClick={onClick}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -65,7 +65,8 @@ export const PathList = forwardRef<HTMLDivElement, Props>(function PathList(
|
||||
</div>
|
||||
<IconButton
|
||||
size="xs"
|
||||
icon="x"
|
||||
icon="trash"
|
||||
iconColor="secondary"
|
||||
title={`Remove ${name}`}
|
||||
disabled={disabled}
|
||||
className="shrink-0"
|
||||
|
||||
Reference in new issue
Block a user