mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 16:21:25 +02:00
Focus states
This commit is contained in:
@@ -2,13 +2,11 @@ import { useState } from 'react';
|
|||||||
import { invoke } from '@tauri-apps/api/tauri';
|
import { invoke } from '@tauri-apps/api/tauri';
|
||||||
import Editor from './components/Editor/Editor';
|
import Editor from './components/Editor/Editor';
|
||||||
import { HStack, VStack } from './components/Stacks';
|
import { HStack, VStack } from './components/Stacks';
|
||||||
import { Dropdown, DropdownMenuRadio } from './components/Dropdown';
|
import { Dropdown } from './components/Dropdown';
|
||||||
import { WindowDragRegion } from './components/WindowDragRegion';
|
import { WindowDragRegion } from './components/WindowDragRegion';
|
||||||
import { IconButton } from './components/IconButton';
|
import { IconButton } from './components/IconButton';
|
||||||
import { Sidebar } from './components/Sidebar';
|
import { Sidebar } from './components/Sidebar';
|
||||||
import { UrlBar } from './components/UrlBar';
|
import { UrlBar } from './components/UrlBar';
|
||||||
import { Input } from './components/Input';
|
|
||||||
import { Button } from './components/Button';
|
|
||||||
import { Grid } from './components/Grid';
|
import { Grid } from './components/Grid';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
@@ -53,7 +51,8 @@ function App() {
|
|||||||
<Sidebar />
|
<Sidebar />
|
||||||
<Grid cols={2}>
|
<Grid cols={2}>
|
||||||
<VStack className="w-full">
|
<VStack className="w-full">
|
||||||
<HStack as={WindowDragRegion} items="center" className="pl-3 pr-1.5">
|
<HStack as={WindowDragRegion} items="center" className="pl-3 pr-1.5"></HStack>
|
||||||
|
<VStack className="pl-3 px-1.5 py-3" space={3}>
|
||||||
<UrlBar
|
<UrlBar
|
||||||
method={method}
|
method={method}
|
||||||
url={url}
|
url={url}
|
||||||
@@ -61,23 +60,11 @@ function App() {
|
|||||||
onUrlChange={setUrl}
|
onUrlChange={setUrl}
|
||||||
sendRequest={sendRequest}
|
sendRequest={sendRequest}
|
||||||
/>
|
/>
|
||||||
</HStack>
|
|
||||||
<VStack className="pl-3 px-1.5 py-3" space={3}>
|
|
||||||
<Editor value="" contentType={contentType} />
|
<Editor value="" contentType={contentType} />
|
||||||
</VStack>
|
</VStack>
|
||||||
</VStack>
|
</VStack>
|
||||||
<VStack className="w-full">
|
<VStack className="w-full">
|
||||||
<HStack as={WindowDragRegion} items="center" className="pl-1.5 pr-1">
|
<HStack as={WindowDragRegion} items="center" className="pl-1.5 pr-1">
|
||||||
{response && (
|
|
||||||
<div className="my-1 italic text-gray-500 text-sm w-full pointer-events-none">
|
|
||||||
{response.method.toUpperCase()}
|
|
||||||
•
|
|
||||||
{response.status}
|
|
||||||
•
|
|
||||||
{response.elapsed}ms •
|
|
||||||
{response.elapsed2}ms
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<Dropdown
|
<Dropdown
|
||||||
items={[
|
items={[
|
||||||
{
|
{
|
||||||
@@ -97,6 +84,15 @@ function App() {
|
|||||||
{error && <div className="text-white bg-red-500 px-3 py-1 rounded">{error}</div>}
|
{error && <div className="text-white bg-red-500 px-3 py-1 rounded">{error}</div>}
|
||||||
{response !== null && (
|
{response !== null && (
|
||||||
<>
|
<>
|
||||||
|
<HStack
|
||||||
|
items="center"
|
||||||
|
className="italic text-gray-500 text-sm w-full pointer-events-none h-10 mb-3 flex-shrink-0"
|
||||||
|
>
|
||||||
|
{response.status}
|
||||||
|
•
|
||||||
|
{response.elapsed}ms •
|
||||||
|
{response.elapsed2}ms
|
||||||
|
</HStack>
|
||||||
{contentType.includes('html') ? (
|
{contentType.includes('html') ? (
|
||||||
<iframe
|
<iframe
|
||||||
title="Response preview"
|
title="Response preview"
|
||||||
|
|||||||
@@ -10,19 +10,21 @@
|
|||||||
right: 0;
|
right: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
border-radius: var(--border-radius-lg);
|
|
||||||
border: 1px solid hsl(var(--color-gray-50));
|
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cm-editor .cm-scroller {
|
||||||
|
border: 1px solid hsl(var(--color-gray-50));
|
||||||
|
border-radius: var(--border-radius-lg);
|
||||||
|
background-color: hsl(var(--color-gray-50));
|
||||||
|
}
|
||||||
|
|
||||||
.cm-editor.cm-focused {
|
.cm-editor.cm-focused {
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
border-color: hsl(var(--color-gray-100));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-editor .cm-scroller {
|
.cm-editor.cm-focused .cm-scroller {
|
||||||
border-radius: var(--border-radius-lg);
|
border-color: hsl(var(--color-blue-400)/0.4);
|
||||||
background-color: hsl(var(--color-gray-50));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-editor .cm-line {
|
.cm-editor .cm-line {
|
||||||
|
|||||||
@@ -29,10 +29,16 @@ export function Input({
|
|||||||
return (
|
return (
|
||||||
<HStack
|
<HStack
|
||||||
items="center"
|
items="center"
|
||||||
className={classnames(containerClassName, 'w-full bg-gray-50 rounded-md text-sm')}
|
className={classnames(
|
||||||
|
containerClassName,
|
||||||
|
'w-full bg-gray-50 rounded-md text-sm overflow-hidden text-gray-900',
|
||||||
|
'border border-transparent focus-within:border-blue-400/40',
|
||||||
|
size === 'md' && 'h-10',
|
||||||
|
size === 'sm' && 'h-8',
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{leftSlot}
|
{leftSlot}
|
||||||
<VStack className={classnames('w-full border-gray-100/50')}>
|
<VStack className="w-full">
|
||||||
<label
|
<label
|
||||||
htmlFor={name}
|
htmlFor={name}
|
||||||
className={classnames(
|
className={classnames(
|
||||||
@@ -47,11 +53,9 @@ export function Input({
|
|||||||
id={id}
|
id={id}
|
||||||
className={classnames(
|
className={classnames(
|
||||||
className,
|
className,
|
||||||
'bg-transparent min-w-0 pl-3 pr-2 w-full focus:outline-none text-gray-900',
|
'bg-transparent min-w-0 pl-3 pr-2 h-full w-full focus:outline-none',
|
||||||
leftSlot && 'pl-1',
|
leftSlot && 'pl-1',
|
||||||
rightSlot && 'pr-1',
|
rightSlot && 'pr-1',
|
||||||
size === 'md' && 'h-10',
|
|
||||||
size === 'sm' && 'h-8',
|
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const spaceClassesY = {
|
|||||||
|
|
||||||
interface HStackProps extends BaseStackProps {
|
interface HStackProps extends BaseStackProps {
|
||||||
space?: keyof typeof spaceClassesX;
|
space?: keyof typeof spaceClassesX;
|
||||||
children: ReactNode;
|
children?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HStack({ className, space, children, ...props }: HStackProps) {
|
export function HStack({ className, space, children, ...props }: HStackProps) {
|
||||||
|
|||||||
@@ -28,10 +28,9 @@ export function UrlBar({ sendRequest, onMethodChange, method, onUrlChange, url }
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSendRequest} className="w-full flex items-center overflow-hidden">
|
<form onSubmit={handleSendRequest} className="w-full flex items-center">
|
||||||
<Input
|
<Input
|
||||||
hideLabel
|
hideLabel
|
||||||
size="sm"
|
|
||||||
name="url"
|
name="url"
|
||||||
label="Enter URL"
|
label="Enter URL"
|
||||||
className="font-mono"
|
className="font-mono"
|
||||||
@@ -48,7 +47,7 @@ export function UrlBar({ sendRequest, onMethodChange, method, onUrlChange, url }
|
|||||||
{ label: 'POST', value: 'POST' },
|
{ label: 'POST', value: 'POST' },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Button disabled={loading} size="xs" className="ml-1" justify="start">
|
<Button disabled={loading} size="sm" className="ml-1" justify="start">
|
||||||
{method.label}
|
{method.label}
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuRadio>
|
</DropdownMenuRadio>
|
||||||
@@ -58,7 +57,7 @@ export function UrlBar({ sendRequest, onMethodChange, method, onUrlChange, url }
|
|||||||
icon={loading ? 'update' : 'paper-plane'}
|
icon={loading ? 'update' : 'paper-plane'}
|
||||||
spin={loading}
|
spin={loading}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
size="xs"
|
size="sm"
|
||||||
className="mr-1"
|
className="mr-1"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user