Repository navigation
feat(workspaces): add search, faster polling, and startup fixes to the panel #1205
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/ui/src/components/TreeFindWidget/TreeFindWidget.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* Native .monaco-tree-type-filter (VS Code 1.143); Modern UI leaves it as is. | ||
| Content-box like native: 200px plus padding and border. */ | ||
| .ui-tree-find-widget { | ||
| position: absolute; | ||
| top: 0; | ||
| right: 0; | ||
| /* Above the tree's pinned rows (13), below overlays */ | ||
| z-index: 20; | ||
| display: flex; | ||
| width: 200px; | ||
| max-width: calc(100% - 24px); | ||
| margin: 0 10px 0 6px; | ||
| padding: 3px; | ||
| background: var(--ui-list-filter-widget-background); | ||
| border: 1px solid var(--ui-widget-border); | ||
| border-bottom-left-radius: 4px; | ||
| border-bottom-right-radius: 4px; | ||
| box-shadow: 0 0 8px 2px var(--ui-list-filter-widget-shadow); | ||
| } | ||
|
|
||
| /* Native slides in from above when motion is enabled */ | ||
| @media (prefers-reduced-motion: no-preference) { | ||
| .ui-tree-find-widget { | ||
| transition: top 0.3s; | ||
| } | ||
|
|
||
| @starting-style { | ||
| .ui-tree-find-widget { | ||
| top: -40px; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .ui-tree-find-widget .ui-tree-find-widget__input { | ||
| flex: 1; | ||
| min-width: 0; | ||
| height: 23px; | ||
| } | ||
|
|
||
| .ui-tree-find-widget .ui-input__control { | ||
| padding: 0 4px; | ||
| } | ||
|
|
||
| .ui-tree-find-widget .ui-input__control::-webkit-search-cancel-button { | ||
| display: none; | ||
| } | ||
|
|
||
| /* The action bar's 16px codicon with 2px padding */ | ||
| .ui-tree-find-widget .ui-tree-find-widget__close { | ||
| flex: none; | ||
| width: 20px; | ||
| height: 20px; | ||
| margin-left: 4px; | ||
| align-self: center; | ||
| } |
53 changes: 53 additions & 0 deletions
53
packages/ui/src/components/TreeFindWidget/TreeFindWidget.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { useState } from "react"; | ||
| import { userEvent, within } from "storybook/test"; | ||
|
|
||
| import { PIXEL_ALL_THEMES } from "#storybook"; | ||
|
|
||
| import { Tree } from "../Tree/Tree"; | ||
|
|
||
| import { TreeFindWidget } from "./TreeFindWidget"; | ||
|
|
||
| import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
|
|
||
| const NODES = ["alpha", "beta", "gamma", "delta"].map((name) => ({ | ||
| id: name, | ||
| label: name, | ||
| icon: "folder" as const, | ||
| })); | ||
|
|
||
| const FindInTree = (): React.JSX.Element => { | ||
| const [value, setValue] = useState(""); | ||
| return ( | ||
| <div style={{ position: "relative", width: "300px", height: "160px" }}> | ||
| <TreeFindWidget | ||
| value={value} | ||
| onChange={setValue} | ||
| onClose={() => undefined} | ||
| /> | ||
| <Tree | ||
| aria-label="Folders" | ||
| nodes={NODES.filter(({ label }) => label.includes(value))} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const meta: Meta<typeof FindInTree> = { | ||
| title: "UI/TreeFindWidget", | ||
| component: FindInTree, | ||
| parameters: { pixel: PIXEL_ALL_THEMES }, | ||
| }; | ||
| export default meta; | ||
| type Story = StoryObj<typeof FindInTree>; | ||
|
|
||
| export const Empty: Story = {}; | ||
|
|
||
| export const Filtering: Story = { | ||
| play: async ({ canvasElement }) => { | ||
| const canvas = within(canvasElement); | ||
| await userEvent.type( | ||
| await canvas.findByRole("searchbox", { name: "Type to search" }), | ||
| "a", | ||
| ); | ||
| }, | ||
| }; | ||
71 changes: 71 additions & 0 deletions
71
packages/ui/src/components/TreeFindWidget/TreeFindWidget.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { type ComponentProps, type Ref } from "react"; | ||
|
|
||
| import { cx } from "#cx"; | ||
|
|
||
| import { IconButton } from "../IconButton/IconButton"; | ||
| import { Input } from "../Input/Input"; | ||
|
|
||
| import "./TreeFindWidget.css"; | ||
|
|
||
| export interface TreeFindWidgetProps extends Omit< | ||
| ComponentProps<"div">, | ||
| "onChange" | "ref" | ||
| > { | ||
| value: string; | ||
| onChange: (value: string) => void; | ||
| /** Escape and the close button. */ | ||
| onClose: () => void; | ||
| /** Enter and Arrow Down, which hand focus back to the list like native. */ | ||
| onFocusList?: () => void; | ||
| /** The input's accessible name and placeholder, as in native. */ | ||
| label?: string; | ||
| /** The input, like `SearchInput`, so a consumer can refocus it. */ | ||
| ref?: Ref<HTMLInputElement>; | ||
| } | ||
|
|
||
| /** | ||
| * VS Code's tree find widget, floating at the top right of the nearest | ||
| * positioned ancestor. Place it outside the scrolling element, or in a | ||
| * sticky one, so it stays put while the list scrolls. It takes focus when | ||
| * it mounts. | ||
| */ | ||
| export function TreeFindWidget({ | ||
| value, | ||
| onChange, | ||
| onClose, | ||
| onFocusList, | ||
| label = "Type to search", | ||
| ref, | ||
| className, | ||
| ...props | ||
| }: TreeFindWidgetProps): React.JSX.Element { | ||
|
EhabY marked this conversation as resolved.
Resolved
|
||
| return ( | ||
| <div {...props} className={cx("ui-tree-find-widget", className)}> | ||
| <Input | ||
| ref={ref} | ||
| type="search" | ||
| aria-label={label} | ||
| placeholder={label} | ||
| value={value} | ||
| onChange={onChange} | ||
| onKeyDown={(event) => { | ||
| if (event.key === "Escape") { | ||
| event.preventDefault(); | ||
| onClose(); | ||
| } else if (event.key === "Enter" || event.key === "ArrowDown") { | ||
| event.preventDefault(); | ||
| onFocusList?.(); | ||
| } | ||
| }} | ||
| className="ui-tree-find-widget__input" | ||
| autoFocus | ||
| /> | ||
| <IconButton | ||
| icon="close" | ||
| label="Close" | ||
| onClick={onClose} | ||
| className="ui-tree-find-widget__close" | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.