mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:38:29 +02:00
Minor theme updates again
This commit is contained in:
@@ -28,14 +28,14 @@ export function Dialog({
|
|||||||
<D.Root open={open} onOpenChange={onOpenChange}>
|
<D.Root open={open} onOpenChange={onOpenChange}>
|
||||||
<D.Portal container={document.querySelector<HTMLElement>('#radix-portal')}>
|
<D.Portal container={document.querySelector<HTMLElement>('#radix-portal')}>
|
||||||
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
|
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
|
||||||
<D.Overlay className="fixed inset-0 bg-gray-900/60 dark:bg-black/50" />
|
<D.Overlay className="fixed inset-0 bg-gray-600/60 dark:bg-black/50" />
|
||||||
<D.Content>
|
<D.Content>
|
||||||
<div
|
<div
|
||||||
className={classnames(
|
className={classnames(
|
||||||
className,
|
className,
|
||||||
'absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] bg-gray-100',
|
'absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] bg-gray-100',
|
||||||
'w-[20rem] max-h-[80vh] p-5 rounded-lg overflow-auto',
|
'w-[20rem] max-h-[80vh] p-5 rounded-lg overflow-auto',
|
||||||
'border border-gray-200 shadow-lg',
|
'dark:border border-gray-200 shadow-md shadow-black/10',
|
||||||
wide && 'w-[80vw] max-w-[50rem]',
|
wide && 'w-[80vw] max-w-[50rem]',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -54,17 +54,20 @@ export default function Editor({
|
|||||||
if (ref.current === null) return;
|
if (ref.current === null) return;
|
||||||
if (singleLine) return;
|
if (singleLine) return;
|
||||||
const gutterEl = ref.current.querySelector<HTMLDivElement>('.cm-gutters');
|
const gutterEl = ref.current.querySelector<HTMLDivElement>('.cm-gutters');
|
||||||
const bgClass = className
|
const classList = className?.split(/\s+/) ?? [];
|
||||||
?.split(/\s+/)
|
const bgClasses = classList
|
||||||
.find((c) => c.startsWith('!bg-') || c.startsWith('bg-'));
|
.filter((c) => c.match(/(^|:)?bg-.+/)) // Find bg-* classes
|
||||||
if (bgClass && gutterEl) {
|
.map((c) => c.replace(/^bg-/, '!bg-')) // !important
|
||||||
gutterEl?.classList.add(`${bgClass}`);
|
.map((c) => c.replace(/^dark:bg-/, 'dark:!bg-')); // !important
|
||||||
|
if (gutterEl) {
|
||||||
|
gutterEl?.classList.add(...bgClasses);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create codemirror instance when ref initializes
|
// Create codemirror instance when ref initializes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ref.current === null) return;
|
if (ref.current === null) return;
|
||||||
|
console.log('INIT EDITOR');
|
||||||
let view: EditorView | null = null;
|
let view: EditorView | null = null;
|
||||||
try {
|
try {
|
||||||
const langHolder = new Compartment();
|
const langHolder = new Compartment();
|
||||||
@@ -86,10 +89,6 @@ export default function Editor({
|
|||||||
return () => view?.destroy();
|
return () => view?.destroy();
|
||||||
}, [ref.current, valueKey]);
|
}, [ref.current, valueKey]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
syncGutterBg();
|
|
||||||
}, [ref.current, className]);
|
|
||||||
|
|
||||||
// Update value when valueKey changes
|
// Update value when valueKey changes
|
||||||
// TODO: This would be more efficient but the onChange handler gets fired on update
|
// TODO: This would be more efficient but the onChange handler gets fired on update
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
@@ -103,6 +102,7 @@ export default function Editor({
|
|||||||
// Update language extension when contentType changes
|
// Update language extension when contentType changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (cm === null) return;
|
if (cm === null) return;
|
||||||
|
console.log('UPDATE LANG');
|
||||||
const ext = getLanguageExtension({ contentType, useTemplating });
|
const ext = getLanguageExtension({ contentType, useTemplating });
|
||||||
cm.view.dispatch({ effects: cm.langHolder.reconfigure(ext) });
|
cm.view.dispatch({ effects: cm.langHolder.reconfigure(ext) });
|
||||||
}, [contentType]);
|
}, [contentType]);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export function HeaderEditor() {
|
|||||||
headers.map((h, i) => {
|
headers.map((h, i) => {
|
||||||
if (i === index) return h;
|
if (i === index) return h;
|
||||||
const newHeader: HttpHeader = { ...h, ...header };
|
const newHeader: HttpHeader = { ...h, ...header };
|
||||||
console.log('NEW HEADER', newHeader);
|
|
||||||
return newHeader;
|
return newHeader;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -37,8 +36,6 @@ export function HeaderEditor() {
|
|||||||
setHeaders((headers) => headers.filter((_, i) => i !== index));
|
setHeaders((headers) => headers.filter((_, i) => i !== index));
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('HEADERS', headers);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<VStack space={2}>
|
<VStack space={2}>
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ export function Input({
|
|||||||
const inputClassName = classnames(
|
const inputClassName = classnames(
|
||||||
className,
|
className,
|
||||||
'!bg-transparent pl-3 pr-2 min-w-0 h-full w-full focus:outline-none placeholder:text-placeholder',
|
'!bg-transparent pl-3 pr-2 min-w-0 h-full w-full focus:outline-none placeholder:text-placeholder',
|
||||||
leftSlot && '!pl-1',
|
leftSlot && '!pl-0.5',
|
||||||
rightSlot && '!pr-1',
|
rightSlot && '!pr-0.5',
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function RequestPane({ fullHeight, request, className }: Props) {
|
|||||||
>
|
>
|
||||||
<div className="pl-2">
|
<div className="pl-2">
|
||||||
<UrlBar
|
<UrlBar
|
||||||
className="bg-transparent"
|
className="bg-transparent shadow dark:shadow-none shadow-gray-200"
|
||||||
key={request.id}
|
key={request.id}
|
||||||
method={request.method}
|
method={request.method}
|
||||||
url={request.url}
|
url={request.url}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ interface Props {
|
|||||||
|
|
||||||
export function ResponsePane({ requestId, className }: Props) {
|
export function ResponsePane({ requestId, className }: Props) {
|
||||||
const [activeResponseId, setActiveResponseId] = useState<string | null>(null);
|
const [activeResponseId, setActiveResponseId] = useState<string | null>(null);
|
||||||
const [viewMode, setViewMode] = useState<'pretty' | 'raw'>('pretty');
|
const [viewMode, setViewMode] = useState<'pretty' | 'raw'>('raw');
|
||||||
const responses = useResponses(requestId);
|
const responses = useResponses(requestId);
|
||||||
const response = activeResponseId
|
const response = activeResponseId
|
||||||
? responses.data.find((r) => r.id === activeResponseId)
|
? responses.data.find((r) => r.id === activeResponseId)
|
||||||
@@ -42,12 +42,18 @@ export function ResponsePane({ requestId, className }: Props) {
|
|||||||
return response.body;
|
return response.body;
|
||||||
}, [response?.body, contentType]);
|
}, [response?.body, contentType]);
|
||||||
|
|
||||||
|
if (!response) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-2">
|
<div className="p-2">
|
||||||
<div
|
<div
|
||||||
className={classnames(
|
className={classnames(
|
||||||
className,
|
className,
|
||||||
'max-h-full h-full grid grid-rows-[auto_minmax(0,1fr)] grid-cols-1 bg-gray-100 rounded-md overflow-hidden border border-gray-200',
|
'max-h-full h-full grid grid-rows-[auto_minmax(0,1fr)] grid-cols-1 ',
|
||||||
|
'dark:bg-gray-100 rounded-md overflow-hidden border border-gray-200',
|
||||||
|
'shadow dark:shadow-none shadow-gray-200',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{/*<HStack as={WindowDragRegion} items="center" className="pl-1.5 pr-1">*/}
|
{/*<HStack as={WindowDragRegion} items="center" className="pl-1.5 pr-1">*/}
|
||||||
@@ -58,15 +64,17 @@ export function ResponsePane({ requestId, className }: Props) {
|
|||||||
items="center"
|
items="center"
|
||||||
className="italic text-gray-600 text-sm w-full mb-1 flex-shrink-0 pl-2"
|
className="italic text-gray-600 text-sm w-full mb-1 flex-shrink-0 pl-2"
|
||||||
>
|
>
|
||||||
<div className="whitespace-nowrap">
|
{response.status > 0 && (
|
||||||
<StatusColor statusCode={response.status}>
|
<div className="whitespace-nowrap">
|
||||||
{response.status}
|
<StatusColor statusCode={response.status}>
|
||||||
{response.statusReason && ` ${response.statusReason}`}
|
{response.status}
|
||||||
</StatusColor>
|
{response.statusReason && ` ${response.statusReason}`}
|
||||||
•
|
</StatusColor>
|
||||||
{response.elapsed}ms •
|
•
|
||||||
{Math.round(response.body.length / 1000)} KB
|
{response.elapsed}ms •
|
||||||
</div>
|
{Math.round(response.body.length / 1000)} KB
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<HStack items="center" className="ml-auto h-8">
|
<HStack items="center" className="ml-auto h-8">
|
||||||
{contentType.includes('html') && (
|
{contentType.includes('html') && (
|
||||||
@@ -122,7 +130,7 @@ export function ResponsePane({ requestId, className }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
) : response?.body ? (
|
) : response?.body ? (
|
||||||
<Editor
|
<Editor
|
||||||
className="!bg-gray-100"
|
className="bg-gray-50 dark:!bg-gray-100"
|
||||||
valueKey={`${contentType}:${response.body}`}
|
valueKey={`${contentType}:${response.body}`}
|
||||||
defaultValue={response?.body}
|
defaultValue={response?.body}
|
||||||
contentType={contentType}
|
contentType={contentType}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link, useRouteError } from 'react-router-dom';
|
import { useRouteError } from 'react-router-dom';
|
||||||
import { Button } from './Button';
|
|
||||||
import { ButtonLink } from './ButtonLink';
|
import { ButtonLink } from './ButtonLink';
|
||||||
import { Heading } from './Heading';
|
import { Heading } from './Heading';
|
||||||
import { VStack } from './Stacks';
|
import { VStack } from './Stacks';
|
||||||
|
|
||||||
export function RouterError() {
|
export function RouterError() {
|
||||||
const error = useRouteError();
|
const error = useRouteError();
|
||||||
console.log('Router Error', error);
|
const stringified = JSON.stringify(error);
|
||||||
|
const message = (error as any).message ?? stringified;
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center h-full">
|
<div className="flex items-center justify-center h-full">
|
||||||
<VStack space={5} className="w-auto h-auto">
|
<VStack space={5} className="max-w-[30rem] !h-auto">
|
||||||
<Heading>Route Error 🔥</Heading>
|
<Heading>Route Error 🔥</Heading>
|
||||||
<pre className="text-sm select-auto cursor-text bg-gray-50 p-3 rounded">
|
<pre className="text-sm select-auto cursor-text bg-gray-100 p-3 rounded whitespace-normal">
|
||||||
{JSON.stringify(error, null, 2)}
|
{message}
|
||||||
</pre>
|
</pre>
|
||||||
<ButtonLink to="/" color="primary">
|
<ButtonLink to="/" color="primary">
|
||||||
Go Home
|
Go Home
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export function Sidebar({ className, activeRequestId, workspaceId, requests, ...
|
|||||||
const createRequest = useRequestCreate({ workspaceId, navigateAfter: true });
|
const createRequest = useRequestCreate({ workspaceId, navigateAfter: true });
|
||||||
const { appearance, toggleAppearance } = useTheme();
|
const { appearance, toggleAppearance } = useTheme();
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
|
console.log('OPEN', open);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classnames(className, 'w-52 bg-gray-100 h-full border-r border-gray-200')}
|
className={classnames(className, 'w-52 bg-gray-100 h-full border-r border-gray-200')}
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
import { convertDates, HttpRequest } from '../lib/models';
|
|
||||||
import { responsesQueryKey } from './useResponses';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import type { HttpRequest } from '../lib/models';
|
||||||
|
import { convertDates } from '../lib/models';
|
||||||
|
import { responsesQueryKey } from './useResponses';
|
||||||
|
|
||||||
export function requestsQueryKey(workspaceId: string) {
|
export function requestsQueryKey(workspaceId: string) {
|
||||||
return ['requests', { workspaceId }];
|
return ['requests', { workspaceId }];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useRequests(workspaceId: string) {
|
export function useRequests(workspaceId: string) {
|
||||||
return useQuery(requestsQueryKey(workspaceId), async () => {
|
return useQuery({
|
||||||
const requests = (await invoke('requests', { workspaceId })) as HttpRequest[];
|
queryKey: requestsQueryKey(workspaceId),
|
||||||
return requests.map(convertDates);
|
queryFn: async () => {
|
||||||
|
const requests = (await invoke('requests', { workspaceId })) as HttpRequest[];
|
||||||
|
return requests.map(convertDates);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,27 +87,27 @@ export function generateColors(
|
|||||||
|
|
||||||
const lightnessMap: Record<Appearance, Record<AppThemeColorVariant, number>> = {
|
const lightnessMap: Record<Appearance, Record<AppThemeColorVariant, number>> = {
|
||||||
light: {
|
light: {
|
||||||
50: 0.98,
|
50: 1,
|
||||||
100: 0.88,
|
100: 0.9,
|
||||||
200: 0.7,
|
200: 0.7,
|
||||||
300: 0.5,
|
300: 0.4,
|
||||||
400: 0.3,
|
400: 0.2,
|
||||||
500: 0,
|
500: 0,
|
||||||
600: -0.2,
|
600: -0.2,
|
||||||
700: -0.3,
|
700: -0.4,
|
||||||
800: -0.45,
|
800: -0.6,
|
||||||
900: -0.6,
|
900: -0.8,
|
||||||
950: -0.8,
|
950: -0.9,
|
||||||
},
|
},
|
||||||
dark: {
|
dark: {
|
||||||
50: -0.98,
|
50: -0.9,
|
||||||
100: -0.93,
|
100: -0.8,
|
||||||
200: -0.78,
|
200: -0.6,
|
||||||
300: -0.63,
|
300: -0.4,
|
||||||
400: -0.44,
|
400: -0.2,
|
||||||
500: -0.2,
|
500: 0,
|
||||||
600: 0,
|
600: 0.2,
|
||||||
700: 0.3,
|
700: 0.4,
|
||||||
800: 0.6,
|
800: 0.6,
|
||||||
900: 0.8,
|
900: 0.8,
|
||||||
950: 0.9,
|
950: 0.9,
|
||||||
@@ -122,8 +122,8 @@ export function generateColorVariant(
|
|||||||
whitePoint = 1,
|
whitePoint = 1,
|
||||||
): string {
|
): string {
|
||||||
const { hsl } = parseColor(color || '');
|
const { hsl } = parseColor(color || '');
|
||||||
// const lightnessMod = lightnessMap[appearance][variant];
|
const lightnessMod = lightnessMap[appearance][variant];
|
||||||
const lightnessMod = (appearance === 'dark' ? 1 : -1) * ((variant / 1000) * 2 - 1);
|
// const lightnessMod = (appearance === 'dark' ? 1 : -1) * ((variant / 1000) * 2 - 1);
|
||||||
const newL =
|
const newL =
|
||||||
lightnessMod > 0
|
lightnessMod > 0
|
||||||
? hsl[2] + (100 * whitePoint - hsl[2]) * lightnessMod
|
? hsl[2] + (100 * whitePoint - hsl[2]) * lightnessMod
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const darkTheme: AppTheme = {
|
|||||||
gray: '#656196',
|
gray: '#656196',
|
||||||
red: '#ee3b3b',
|
red: '#ee3b3b',
|
||||||
orange: '#ff9411',
|
orange: '#ff9411',
|
||||||
yellow: '#dcdc3b',
|
yellow: '#dcc73b',
|
||||||
green: '#44cb44',
|
green: '#44cb44',
|
||||||
blue: '#2e91ff',
|
blue: '#2e91ff',
|
||||||
pink: '#f670f6',
|
pink: '#f670f6',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module.exports = {
|
|||||||
darkMode: ['class', '[data-appearance="dark"]'],
|
darkMode: ['class', '[data-appearance="dark"]'],
|
||||||
content: [
|
content: [
|
||||||
"./index.html",
|
"./index.html",
|
||||||
"./src-web/**/*.{js,ts,jsx,tsx}",
|
"./src-web/**/*.{html,tsx}",
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {},
|
extend: {},
|
||||||
|
|||||||
Reference in New Issue
Block a user