Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

feat(search): Add inline file search to Svelte app#62961

Merged
fkling merged 5 commits intomainfrom
fkling/srch-6-svelte-addresolve-file-search-bar
May 31, 2024
Merged

feat(search): Add inline file search to Svelte app#62961
fkling merged 5 commits intomainfrom
fkling/srch-6-svelte-addresolve-file-search-bar

Conversation

@fkling
Copy link
Contributor

@fkling fkling commented May 29, 2024

This PR adds the inline file search to the file view.

Changelog

  • Refactored the existing CodeMirror extension to allow UI customization
  • Moved utility functions around to avoid loading all of wildcard into the prototype (which lead to build errors)
  • Tweaked the new icon component to better align within buttons (I missed that in svelte: Add lucide icons and new icon API #62908 because I didn't test it within buttons)
  • Noticed that button group styles didn't apply correctly and the reason seemed to be that we were mixing sveltekit and react styles. So I copied the button styles into the sveltekit app.
  • Added a switch component, following https://web.dev/articles/building/a-switch-component .

2024-05-29_12-58

Test plan

Manually tested the SvelteKit and React versions of the search panel.

@fkling fkling added the team/code-search Issues owned by the code search team label May 29, 2024
@fkling fkling requested review from camdencheek and vovakulikov May 29, 2024 11:57
@fkling fkling self-assigned this May 29, 2024
@cla-bot cla-bot bot added the cla-signed label May 29, 2024
@fkling fkling force-pushed the fkling/srch-6-svelte-addresolve-file-search-bar branch from d2c49fa to bc3310e Compare May 29, 2024 12:00
Comment on lines 210 to 249
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to remove transitive dependencies on React.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new switch component.

Comment on lines +25 to +27
label {
margin-bottom: 0;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why we set a margin by default, but it's rather annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual UI was moved into a separate file/component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI that was previously in search.tsx.

Comment on lines -103 to -113
export function createElement<K extends keyof HTMLElementTagNameMap>(
tagName: K,
properties: Partial<HTMLElementTagNameMap[K]> | null = null,
...children: (Node | string)[]
): HTMLElementTagNameMap[K] {
const element = Object.assign(document.createElement(tagName), properties)
for (const child of children) {
element.append(typeof child === 'string' ? document.createTextNode(child) : child)
}
return element
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to remove the transitive dependency on wildcard which causes build issues.

@camdencheek
Copy link
Member

I can't seem to run this locally. Do I need to do anything special to generate the icons?

@fkling
Copy link
Contributor Author

fkling commented May 29, 2024

@camdencheek

I can't seem to run this locally. Do I need to do anything special to generate the icons?

pnpm install and pnpm dev should work. What did you try?

@camdencheek
Copy link
Member

What did you try?

I tried that 😄

@fkling
Copy link
Contributor Author

fkling commented May 29, 2024

Which error/problem do you get? You can also message me in Slack and I'll take a look when I have time.

@camdencheek
Copy link
Member

camdencheek commented May 29, 2024

Which error/problem do you get?

Not sure what changed, but running it locally is fixed now.

Seems this broke the layout of search results headers:

screenshot-2024-05-29_10-10-40@2x

@camdencheek
Copy link
Member

Should the keybind be scoped more tightly? Seems a little weird that Cmd+F opens the panel when, e.g., I have the top-level search input focused

@camdencheek
Copy link
Member

camdencheek commented May 30, 2024

nit: I don't love the lucide icons for case sensitivity and regex 😕 They seem imbalanced (specifically, the case sensitive icon looks too small), and the regex icon doesn't really look like a regex icon to me.

screenshot-2024-05-29_21-14-55@2x

(Also, should the text input be taller than the buttons?)

@taiyab
Copy link
Contributor

taiyab commented May 30, 2024

(Also, should the text input be taller than the buttons?)

No. They should all be a standard size (probably resolving to 32px height in this case).

@fkling fkling enabled auto-merge (squash) May 31, 2024 10:33
@fkling fkling merged commit a6c1c87 into main May 31, 2024
@fkling fkling deleted the fkling/srch-6-svelte-addresolve-file-search-bar branch May 31, 2024 11:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/code-search Issues owned by the code search team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants