Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard shortcuts and accessibility #882

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
8 changes: 7 additions & 1 deletion src/client/CodeEditor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
font-size: 12px;
}

.sidebar-file-item.focused {
background-color: #e0e0e0; /* Light gray background for focused item */
outline: 2px solid blue; /* Blue outline to indicate focus */
box-shadow: 0 0 5px rgba(0, 0, 255, 0.5);
}

.cm-panel.cm-search {
padding: 5px;
position: relative;
Expand Down Expand Up @@ -153,4 +159,4 @@
background-color: var(--vh-color-caution-02);
transform: scale(0.95);
}
}
}
12 changes: 4 additions & 8 deletions src/client/VZSidebar/DirectoryListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ export const DirectoryListing = ({
children,
handleFileClick,
handleFileDoubleClick,
isExpanded = false,
}: {
name: string;
path: string;
children: Array<FileTree | FileTreeFile>;
handleFileClick: (fileId: string) => void;
handleFileDoubleClick: (fileId: string) => void;
isExpanded?: boolean;
}) => {
const {
renameDirectory,
deleteDirectory,
isDirectoryOpen,
toggleDirectory,
sidebarPresenceIndicators,
} = useContext(VZCodeContext);
Expand All @@ -41,11 +42,6 @@ export const DirectoryListing = ({
[renameDirectory, path, name],
);

const isOpen = useMemo(
() => isDirectoryOpen(path),
[isDirectoryOpen, path],
);

return (
<>
<Item
Expand All @@ -59,14 +55,14 @@ export const DirectoryListing = ({
<div
className="arrow-wrapper"
style={{
transform: `rotate(${isOpen ? 90 : 0}deg)`,
transform: `rotate(${isExpanded ? 90 : 0}deg)`,
}}
>
<DirectoryArrowSVG />
</div>
<div className="name">{name}</div>
</Item>
{children && isOpen ? (
{children && isExpanded ? (
<div className="indentation">
{children.map((entity) => {
const { fileId } = entity as FileTreeFile;
Expand Down
67 changes: 46 additions & 21 deletions src/client/VZSidebar/Listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,62 @@ export const Listing = ({
entity,
handleFileClick,
handleFileDoubleClick,
isExpanded = false,
onDragStart,
onDragOver,
onDrop,
}: {
entity: FileTree | FileTreeFile;
handleFileClick: (fileId: FileId) => void;
handleFileDoubleClick: (fileId: FileId) => void;
isExpanded?: boolean;
onDragStart: (itemId: string) => void;
onDragOver: (event: React.DragEvent<Element>, itemId: string) => void;
onDrop: (event: React.DragEvent<Element>, itemId: string) => void;
}) => {
const { activePane, sidebarPresenceIndicators } =
useContext(VZCodeContext);
const { activePane, sidebarPresenceIndicators } = useContext(VZCodeContext);
const { name, file, fileId } = entity as FileTreeFile;
const { path, children } = entity as FileTree;

const presence =
sidebarPresenceIndicators?.filter(
(indicator) => indicator.fileId === fileId,
) || [];
const presence = sidebarPresenceIndicators?.filter(
(indicator) => indicator.fileId === fileId,
) || [];

const itemId = fileId || path;

return file ? (
<FileListing
fileId={fileId}
name={name}
handleFileClick={handleFileClick}
handleFileDoubleClick={handleFileDoubleClick}
isActive={fileId === activePane.activeFileId}
presence={presence}
/>
<div
className="sidebar-file-item"
draggable
onDragStart={() => onDragStart(itemId)}
onDragOver={(event) => onDragOver(event, itemId)}
onDrop={(event) => onDrop(event, itemId)}
>
<FileListing
fileId={fileId}
name={name}
handleFileClick={handleFileClick}
handleFileDoubleClick={handleFileDoubleClick}
isActive={fileId === activePane.activeFileId}
presence={presence}
/>
</div>
) : (
<DirectoryListing
name={name}
path={path}
children={children}
handleFileClick={handleFileClick}
handleFileDoubleClick={handleFileDoubleClick}
/>
<div
className="sidebar-file-item"
draggable
onDragStart={() => onDragStart(itemId)}
onDragOver={(event) => onDragOver(event, itemId)}
onDrop={(event) => onDrop(event, itemId)}
>
<DirectoryListing
name={name}
path={path}
children={children}
handleFileClick={handleFileClick}
handleFileDoubleClick={handleFileDoubleClick}
isExpanded={isExpanded}
/>
</div>
);
};
Loading