UI tweaks

This commit is contained in:
Dallin Romney 2025-03-24 18:51:12 -07:00
parent 3bf2d301d9
commit 050424424e
7 changed files with 74 additions and 60 deletions

View file

@ -36,7 +36,7 @@ export default function AddFileButton({ onClick }: AddFileButtonProps) {
<div className="relative">
<ListboxButton
ref={buttonRef}
className="bg-vsc-editor-background border-lightgray/50 flex h-5 cursor-pointer items-center justify-between rounded-md border border-solid px-0 shadow-sm transition-colors"
className="bg-vsc-editor-background m-0 rounded-md p-0"
>
<div
className="flex h-5 w-14 items-center justify-center gap-1 hover:brightness-125"
@ -57,13 +57,8 @@ export default function AddFileButton({ onClick }: AddFileButtonProps) {
<ChevronDownIcon className="text-vsc-foreground h-2.5 w-2.5 cursor-pointer px-1 brightness-75 hover:brightness-125" />
</ListboxButton>
<ListboxOptions className="bg-vsc-editor-background border-lightgray/50 absolute right-0 top-full z-50 mt-1 min-w-fit whitespace-nowrap rounded-md border border-solid px-1 py-0 shadow-lg">
<ListboxOption
value="addAllFiles"
className="text-vsc-foreground block w-full cursor-pointer px-2 py-1 text-left text-[10px] brightness-75 hover:brightness-125"
>
Add all open files
</ListboxOption>
<ListboxOptions className="bg-vsc-editor-background" anchor="top end">
<ListboxOption value="addAllFiles">Add all open files</ListboxOption>
</ListboxOptions>
</div>
</Listbox>

View file

@ -70,7 +70,7 @@ export default function AddFileCombobox({
onFocus={() => {
buttonRef.current?.click();
}}
className="bg-vsc-background border-lightgray text-vsc-foreground box-border w-full rounded border border-solid py-0.5 pl-2 focus:outline-none"
className="bg-vsc-background border-lightgray text-vsc-foreground box-border w-full rounded border border-solid py-0.5 pl-2 text-xs focus:outline-none"
onChange={(event) => setQuery(event.target.value)}
placeholder="Type to search files..."
onKeyDown={(e) => {

View file

@ -75,6 +75,9 @@ function TipTapEditor(props: TipTapEditorProps) {
}, [editor, props.placeholder, historyLength]);
useEffect(() => {
if (isInEditMode) {
setShouldHideToolbar(false);
}
if (props.isMainInput) {
editor?.commands.clearContent(true);
}
@ -155,14 +158,19 @@ function TipTapEditor(props: TipTapEditorProps) {
const handleBlur = (e: React.FocusEvent) => {
// Check if the new focus target is within our InputBoxDiv
const currentTarget = e.currentTarget;
const relatedTarget = e.relatedTarget as Node | null;
queueMicrotask(() => {
if (isInEditMode) {
return;
}
const currentTarget = e.currentTarget;
const relatedTarget = e.relatedTarget as Node | null;
if (relatedTarget && currentTarget.contains(relatedTarget)) {
return;
}
if (relatedTarget && currentTarget.contains(relatedTarget)) {
return;
}
setShouldHideToolbar(true);
setShouldHideToolbar(true);
});
};
return (

View file

@ -18,6 +18,11 @@ import {
selectCurrentMode,
setMode,
} from "../../redux/slices/sessionSlice";
import { exitEditMode } from "../../redux/thunks";
import {
loadLastSession,
saveCurrentSession,
} from "../../redux/thunks/session";
import { getFontSize, getMetaKeyLabel, isJetBrains } from "../../util";
import {
Listbox,
@ -78,8 +83,26 @@ function ModeSelect() {
return (
<Listbox
value={mode}
onChange={(newMode) => {
onChange={async (newMode) => {
if (newMode === mode) {
return;
}
dispatch(setMode(newMode));
if (newMode === "edit") {
await dispatch(
saveCurrentSession({
generateTitle: false,
openNewSession: true,
}),
);
} else if (mode === "edit") {
await dispatch(
loadLastSession({
saveCurrentSession: false,
}),
);
dispatch(exitEditMode());
}
}}
>
<div className="relative">
@ -91,7 +114,9 @@ function ModeSelect() {
}}
>
{getModeIcon(mode)}
<span>{mode.charAt(0).toUpperCase() + mode.slice(1)}</span>
<span className="hidden sm:block">
{mode.charAt(0).toUpperCase() + mode.slice(1)}
</span>
<ChevronDownIcon
className="h-2 w-2 flex-shrink-0"
aria-hidden="true"

View file

@ -21,7 +21,7 @@ const ListboxButton = React.forwardRef<HTMLButtonElement, ListboxButtonProps>(
ref={ref}
{...props}
className={cn(
"border-vsc-input-border bg-vsc-background text-vsc-foreground m-0 flex flex-1 cursor-pointer flex-row items-center gap-1 rounded-sm border border-solid px-1 py-0.5 text-left",
"border-vsc-input-border bg-vsc-input-background text-vsc-foreground m-0 flex flex-1 cursor-pointer flex-row items-center gap-1 rounded-sm border border-solid px-1 py-0.5 text-left",
props.className,
)}
style={{

View file

@ -26,7 +26,7 @@ export function AccountButton() {
</PopoverButton>
<Transition>
<PopoverPanel className="bg-vsc-input-background absolute right-0 z-10 mt-1 w-[250px] rounded-md border border-zinc-700 p-4 shadow-lg">
<PopoverPanel className="bg-vsc-input-background xs:p-4 absolute right-0 mt-1 rounded-md border border-zinc-700 p-2 shadow-lg">
<div className="flex flex-col gap-3">
<div className="flex flex-col">
<span className="font-medium">{session.account.label}</span>
@ -42,7 +42,7 @@ export function AccountButton() {
<ScopeSelect />
</div>
)}
<SecondaryButton onClick={logout} className="w-full justify-center">
<SecondaryButton onClick={logout} className="">
Sign out
</SecondaryButton>
</div>

View file

@ -41,53 +41,39 @@ export function ScopeSelect() {
return (
<Listbox value={selectedOrgId} onChange={handleChange}>
<div className="relative">
<ListboxButton className="border-vsc-input-border hover:bg-vsc-input-background text-vsc-foreground bg-vsc-background flex w-full max-w-[400px] cursor-pointer items-center gap-0.5 rounded border border-solid p-2 hover:opacity-90">
<div className="flex w-full items-center justify-between">
<div className="flex items-center gap-2">
{selectedDisplay?.iconUrl ? (
<img src={selectedDisplay.iconUrl} alt="" className="h-5 w-5" />
) : (
<CurScopeEntityFallBackIcon className="h-5 w-5" />
)}
<span className="truncate">
{selectedDisplay?.name || "Select Organization"}
</span>
</div>
<ChevronUpDownIcon className="h-5 w-5" aria-hidden="true" />
<ListboxButton className="min-w-[140px] justify-between px-4 py-2 sm:min-w-[200px]">
<div className="flex items-center gap-2">
{selectedDisplay?.iconUrl ? (
<img src={selectedDisplay.iconUrl} alt="" className="h-5 w-5" />
) : (
<CurScopeEntityFallBackIcon className="h-5 w-5" />
)}
<span className="truncate">
{selectedDisplay?.name || "Select Organization"}
</span>
</div>
<ChevronUpDownIcon className="h-5 w-5" aria-hidden="true" />
</ListboxButton>
<ListboxOptions className="bg-vsc-input-background absolute z-50 mt-1 w-full max-w-[400px] list-none overflow-auto rounded p-0 shadow-lg">
{organizations.length > 0 && (
<>
<div className="text-vsc-foreground p-2 font-semibold">
Organizations
<ListboxOptions className="z-[1000] min-w-[140px] pt-0.5 sm:min-w-[200px]">
{organizations.map((org) => (
<ListboxOption key={org.id} value={org.id} className="py-2">
<div className="flex items-center gap-2">
{org.iconUrl ? (
<img src={org.iconUrl} alt="" className="h-5 w-5" />
) : (
<BuildingOfficeIcon className="h-5 w-5" />
)}
<span>{org.name}</span>
</div>
{organizations.map((org) => (
<ListboxOption
key={org.id}
value={org.id}
className="text-vsc-foreground hover:bg-list-active cursor-pointer rounded p-2 text-sm hover:opacity-90"
>
<div className="flex items-center gap-2">
{org.iconUrl ? (
<img src={org.iconUrl} alt="" className="h-5 w-5" />
) : (
<BuildingOfficeIcon className="h-5 w-5" />
)}
<span>{org.name}</span>
</div>
</ListboxOption>
))}
</ListboxOption>
))}
<div className="bg-lightgray mx-1 my-1 h-px" />
</>
{!!organizations.length && (
<div className="bg-lightgray mx-1 my-1 h-px" />
)}
<ListboxOption
value={null}
className="text-vsc-foreground hover:bg-list-active cursor-pointer rounded p-2 hover:opacity-90"
>
<ListboxOption value={null}>
<div className="flex items-center gap-2">
<UserCircleIcon className="h-5 w-5" />
<span>Personal</span>