From 302f0a18603fdcb178feb21cd50cb123dd9bbcbf Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 22 Feb 2023 16:15:25 -0800 Subject: [PATCH] Better URL bar --- src-web/components/Button.tsx | 3 +- src-web/components/Editor/Editor.css | 5 --- src-web/components/Icon.tsx | 7 +++- src-web/components/Input.tsx | 54 +++++++++++++++++----------- src-web/components/Sidebar.tsx | 2 +- src-web/components/UrlBar.tsx | 30 ++++++++-------- src-web/hooks/useCodemirror.ts | 6 ++-- tailwind.config.cjs | 1 + 8 files changed, 60 insertions(+), 48 deletions(-) diff --git a/src-web/components/Button.tsx b/src-web/components/Button.tsx index 115c5668..831d1c65 100644 --- a/src-web/components/Button.tsx +++ b/src-web/components/Button.tsx @@ -31,7 +31,8 @@ export const Button = forwardRef(function Button justify === 'center' && 'justify-center', size === 'md' && 'h-10 px-4', size === 'sm' && 'h-8 px-3 text-sm', - color === undefined && 'hover:bg-gray-500/[0.1] active:bg-gray-500/[0.15] text-gray-700', + color === undefined && + 'hover:bg-gray-500/[0.1] active:bg-gray-500/[0.15] text-gray-800 hover:text-gray-900', color === 'primary' && 'bg-blue-500 hover:bg-blue-500/90 active:bg-blue-500/80 text-white', color === 'secondary' && 'bg-violet-500 hover:bg-violet-500/90 active:bg-violet-500/80 text-white', diff --git a/src-web/components/Editor/Editor.css b/src-web/components/Editor/Editor.css index e4a2bdea..6182457c 100644 --- a/src-web/components/Editor/Editor.css +++ b/src-web/components/Editor/Editor.css @@ -36,11 +36,6 @@ cursor: text; } -.cm-editor.cm-focused { - outline: 0; - box-shadow: 0 0 0 2pt rgba(180, 180, 180, 0.1); -} - .cm-editor .cm-cursor { border-left: 2px solid red; } diff --git a/src-web/components/Icon.tsx b/src-web/components/Icon.tsx index f742bf7f..d1b1c7a4 100644 --- a/src-web/components/Icon.tsx +++ b/src-web/components/Icon.tsx @@ -33,7 +33,12 @@ export function Icon({ icon, spin, size = 'md', className }: IconProps) { const Component = icons[icon]; return ( ); } diff --git a/src-web/components/Input.tsx b/src-web/components/Input.tsx index c82d035f..63c53f7a 100644 --- a/src-web/components/Input.tsx +++ b/src-web/components/Input.tsx @@ -1,45 +1,57 @@ -import { InputHTMLAttributes } from 'react'; +import { InputHTMLAttributes, ReactNode } from 'react'; import classnames from 'classnames'; -import { VStack } from './Stacks'; +import { HStack, VStack } from './Stacks'; interface Props extends InputHTMLAttributes { name: string; label: string; hideLabel?: boolean; labelClassName?: string; - containerClassName?: string; + leftSlot?: ReactNode; + rightSlot?: ReactNode; } export function Input({ label, - containerClassName, labelClassName, hideLabel, className, name, + leftSlot, + rightSlot, ...props }: Props) { const id = `input-${name}`; return ( - - - - + + + + {rightSlot} + ); } diff --git a/src-web/components/Sidebar.tsx b/src-web/components/Sidebar.tsx index f008d45e..dadb15c1 100644 --- a/src-web/components/Sidebar.tsx +++ b/src-web/components/Sidebar.tsx @@ -11,7 +11,7 @@ type Props = HTMLAttributes; export function Sidebar({ className, ...props }: Props) { return (
diff --git a/src-web/components/UrlBar.tsx b/src-web/components/UrlBar.tsx index d21f4c23..640e548a 100644 --- a/src-web/components/UrlBar.tsx +++ b/src-web/components/UrlBar.tsx @@ -29,32 +29,30 @@ export function UrlBar({ sendRequest, onMethodChange, method, onUrlChange, url } return ( -
-
+ onUrlChange(e.currentTarget.value)} + value={url} + placeholder="Enter a URL..." + leftSlot={ -
- onUrlChange(e.currentTarget.value)} - value={url} - placeholder="Enter a URL..." - /> -
+ } + rightSlot={ -
-
+ } + />
); } diff --git a/src-web/hooks/useCodemirror.ts b/src-web/hooks/useCodemirror.ts index f7773724..63e8974f 100644 --- a/src-web/hooks/useCodemirror.ts +++ b/src-web/hooks/useCodemirror.ts @@ -12,11 +12,11 @@ const myHighlightStyle = HighlightStyle.define([ tag: [tags.documentMeta, tags.blockComment, tags.lineComment, tags.docComment, tags.comment], color: '#757b93', }, - { tag: tags.name, color: '#4dafff' }, - { tag: tags.variableName, color: '#4bff4e' }, + { tag: tags.name, color: '#4699de' }, + { tag: tags.variableName, color: '#31c434' }, { tag: tags.attributeName, color: '#b06fff' }, { tag: tags.attributeValue, color: '#ff964b' }, - { tag: [tags.keyword, tags.string], color: '#fc6' }, + { tag: [tags.keyword, tags.string], color: '#e8b045' }, { tag: tags.comment, color: '#f5d', fontStyle: 'italic' }, ]); diff --git a/tailwind.config.cjs b/tailwind.config.cjs index 6fe86059..a87f6d09 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -15,6 +15,7 @@ module.exports = { full: '9999px', }, colors: { + transparent: 'transparent', white: 'hsl(var(--color-white) / )', background: 'hsl(var(--color-background) / )', gray: color('gray'),