Skip to content

Commit cdccb99

Browse files
committed
wip: refactoring
1 parent 276baef commit cdccb99

2 files changed

Lines changed: 11 additions & 17 deletions

File tree

src/components/esquery-selector-input.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
import { useId, type FC } from "react";
22
import { Label } from "@/components/ui/label";
33
import { TextField } from "@/components/ui/text-field";
4-
import { useExplorer, type Language } from "@/hooks/use-explorer";
4+
import { useExplorer } from "@/hooks/use-explorer";
55
import { useAST } from "@/hooks/use-ast";
66
import { cn } from "@/lib/utils";
7-
8-
const esquerySelectorPlaceholder = (language: Language) => {
9-
switch (language) {
10-
case "javascript":
11-
return 'e.g. "ImportDeclaration > Literal"';
12-
case "json":
13-
return 'e.g. "Member > String"';
14-
case "markdown":
15-
return 'e.g. "Heading > Text"';
16-
case "css":
17-
return 'e.g. "Block > Declaration"';
18-
case "html":
19-
return 'e.g. "Document > Doctype"';
20-
}
21-
};
7+
import { esquerySelectorPlaceholder } from "@/lib/const";
228

239
export const EsquerySelectorInput: FC = () => {
2410
const { esquerySelector, setEsquerySelector, language } = useExplorer();
@@ -36,7 +22,7 @@ export const EsquerySelectorInput: FC = () => {
3622
</Label>
3723
<TextField
3824
id={htmlId}
39-
placeholder={esquerySelectorPlaceholder(language)}
25+
placeholder={esquerySelectorPlaceholder[language]}
4026
className={cn(
4127
"flex-1",
4228
!astParseResult.ok ||

src/lib/const.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@ export const pathViewOptions = [
256256
},
257257
];
258258

259+
export const esquerySelectorPlaceholder = {
260+
javascript: 'e.g. "ImportDeclaration > Literal"',
261+
json: 'e.g. "Member > String"',
262+
markdown: 'e.g. "Heading > Text"',
263+
css: 'e.g. "Block > Declaration"',
264+
html: 'e.g. "Document > Doctype"',
265+
};
266+
259267
export const defaultJsCode = `
260268
/**
261269
* Type or paste some JavaScript here to learn more about

0 commit comments

Comments
 (0)