mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-25 10:51:57 +01:00
Run oxfmt across repo, add format script and docs
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
import { open } from '@tauri-apps/plugin-dialog';
|
||||
import classNames from 'classnames';
|
||||
import mime from 'mime';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import type { ButtonProps } from './core/Button';
|
||||
import { Button } from './core/Button';
|
||||
import { IconButton } from './core/IconButton';
|
||||
import { IconTooltip } from './core/IconTooltip';
|
||||
import { Label } from './core/Label';
|
||||
import { HStack } from './core/Stacks';
|
||||
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
import classNames from "classnames";
|
||||
import mime from "mime";
|
||||
import type { ReactNode } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { ButtonProps } from "./core/Button";
|
||||
import { Button } from "./core/Button";
|
||||
import { IconButton } from "./core/IconButton";
|
||||
import { IconTooltip } from "./core/IconTooltip";
|
||||
import { Label } from "./core/Label";
|
||||
import { HStack } from "./core/Stacks";
|
||||
|
||||
type Props = Omit<ButtonProps, 'type'> & {
|
||||
type Props = Omit<ButtonProps, "type"> & {
|
||||
onChange: (value: { filePath: string | null; contentType: string | null }) => void;
|
||||
filePath: string | null;
|
||||
nameOverride?: string | null;
|
||||
@@ -33,14 +33,14 @@ export function SelectFile({
|
||||
directory,
|
||||
noun,
|
||||
nameOverride,
|
||||
size = 'sm',
|
||||
size = "sm",
|
||||
label,
|
||||
help,
|
||||
...props
|
||||
}: Props) {
|
||||
const handleClick = async () => {
|
||||
const filePath = await open({
|
||||
title: directory ? 'Select Folder' : 'Select File',
|
||||
title: directory ? "Select Folder" : "Select File",
|
||||
multiple: false,
|
||||
directory,
|
||||
});
|
||||
@@ -53,8 +53,8 @@ export function SelectFile({
|
||||
onChange({ filePath: null, contentType: null });
|
||||
};
|
||||
|
||||
const itemLabel = noun ?? (directory ? 'Folder' : 'File');
|
||||
const selectOrChange = (filePath ? 'Change ' : 'Select ') + itemLabel;
|
||||
const itemLabel = noun ?? (directory ? "Folder" : "File");
|
||||
const selectOrChange = (filePath ? "Change " : "Select ") + itemLabel;
|
||||
const [isHovering, setIsHovering] = useState(false);
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
@@ -66,20 +66,20 @@ export function SelectFile({
|
||||
const setup = async () => {
|
||||
const webview = getCurrentWebviewWindow();
|
||||
unlisten = await webview.onDragDropEvent((event) => {
|
||||
if (event.payload.type === 'over') {
|
||||
if (event.payload.type === "over") {
|
||||
const p = event.payload.position;
|
||||
const r = ref.current?.getBoundingClientRect();
|
||||
if (r == null) return;
|
||||
const isOver = p.x >= r.left && p.x <= r.right && p.y >= r.top && p.y <= r.bottom;
|
||||
console.log('IS OVER', isOver);
|
||||
console.log("IS OVER", isOver);
|
||||
setIsHovering(isOver);
|
||||
} else if (event.payload.type === 'drop' && isHovering) {
|
||||
console.log('User dropped', event.payload.paths);
|
||||
} else if (event.payload.type === "drop" && isHovering) {
|
||||
console.log("User dropped", event.payload.paths);
|
||||
const p = event.payload.paths[0];
|
||||
if (p) onChange({ filePath: p, contentType: null });
|
||||
setIsHovering(false);
|
||||
} else {
|
||||
console.log('File drop cancelled');
|
||||
console.log("File drop cancelled");
|
||||
setIsHovering(false);
|
||||
}
|
||||
});
|
||||
@@ -103,12 +103,12 @@ export function SelectFile({
|
||||
<Button
|
||||
className={classNames(
|
||||
className,
|
||||
'rtl mr-1.5',
|
||||
inline && 'w-full',
|
||||
filePath && inline && 'font-mono text-xs',
|
||||
isHovering && '!border-notice',
|
||||
"rtl mr-1.5",
|
||||
inline && "w-full",
|
||||
filePath && inline && "font-mono text-xs",
|
||||
isHovering && "!border-notice",
|
||||
)}
|
||||
color={isHovering ? 'primary' : 'secondary'}
|
||||
color={isHovering ? "primary" : "secondary"}
|
||||
onClick={handleClick}
|
||||
size={size}
|
||||
{...props}
|
||||
@@ -121,7 +121,7 @@ export function SelectFile({
|
||||
<>
|
||||
{filePath && (
|
||||
<IconButton
|
||||
size={size === 'auto' ? 'md' : size}
|
||||
size={size === "auto" ? "md" : size}
|
||||
variant="border"
|
||||
icon="x"
|
||||
title={`Unset ${itemLabel}`}
|
||||
@@ -130,10 +130,10 @@ export function SelectFile({
|
||||
)}
|
||||
<div
|
||||
className={classNames(
|
||||
'truncate rtl pl-1.5 pr-3 text-text',
|
||||
filePath && 'font-mono',
|
||||
size === 'xs' && filePath && 'text-xs',
|
||||
size === 'sm' && filePath && 'text-sm',
|
||||
"truncate rtl pl-1.5 pr-3 text-text",
|
||||
filePath && "font-mono",
|
||||
size === "xs" && filePath && "text-xs",
|
||||
size === "sm" && filePath && "text-sm",
|
||||
)}
|
||||
>
|
||||
{rtlEscapeChar}
|
||||
|
||||
Reference in New Issue
Block a user