Skip to content

Commit 4e77e2f

Browse files
add Search component to @graphiql/react (#2586)
1 parent 022b847 commit 4e77e2f

File tree

19 files changed

+565
-307
lines changed

19 files changed

+565
-307
lines changed

.changeset/five-pillows-fail.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Add new components:
66
- UI components (`Dropdown`, `Spinner`, `UnStyledButton` and lots of icon components)
77
- Editor components (`QueryEditor`, `VariableEditor`, `HeaderEditor` and `ResponseEditor`)
88
- Toolbar components (`ExecuteButton` and `ToolbarButton`)
9-
- Docs components (`Argument`, `DefaultValue`, `Directive`, `FieldLink` and `TypeLink`)
9+
- Docs components (`Argument`, `DefaultValue`, `Directive`, `FieldLink`, `Search` and `TypeLink`)
1010
- `History` component

custom-words.txt

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ browserslist
6666
changesets
6767
codemirror
6868
codesandbox
69+
combobox
6970
commitlint
7071
cosmicconfig
7172
dompurify

packages/graphiql-react/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
},
3939
"dependencies": {
4040
"@graphiql/toolkit": "^1.0.0-next.0",
41+
"@reach/combobox": "^0.17.0",
4142
"codemirror": "^5.65.3",
4243
"codemirror-graphql": "^2.0.0-next.0",
4344
"copy-to-clipboard": "^3.2.0",

packages/graphiql-react/src/explorer/components/__tests__/test-utils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export function mockExplorerContextValue(
1313
push() {},
1414
reset() {},
1515
show() {},
16-
showSearch() {},
1716
};
1817
}
1918

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
@import url('@reach/combobox/styles.css');
2+
3+
[data-reach-combobox] {
4+
color: var(--color-neutral-60);
5+
6+
&:not([data-state='idle']) {
7+
border-radius: var(--border-radius-4);
8+
box-shadow: var(--box-shadow);
9+
color: var(--color-neutral-100);
10+
11+
& .graphiql-doc-explorer-search-input {
12+
background: var(--color-neutral-0);
13+
border-bottom-left-radius: 0;
14+
border-bottom-right-radius: 0;
15+
}
16+
}
17+
}
18+
19+
.graphiql-doc-explorer-search-input {
20+
align-items: center;
21+
background-color: var(--color-neutral-7);
22+
border-radius: var(--border-radius-4);
23+
display: flex;
24+
padding: var(--px-8) var(--px-12);
25+
}
26+
27+
[data-reach-combobox-input] {
28+
border: none;
29+
background-color: transparent;
30+
margin-left: var(--px-4);
31+
width: 100%;
32+
33+
&:focus {
34+
outline: none;
35+
}
36+
}
37+
38+
[data-reach-combobox-popover] {
39+
border: none;
40+
border-bottom-left-radius: var(--border-radius-4);
41+
border-bottom-right-radius: var(--border-radius-4);
42+
border-top: 1px solid var(--color-neutral-15);
43+
max-height: 400px;
44+
overflow-y: auto;
45+
46+
/**
47+
* This makes sure that the logic for auto-scrolling the search results when
48+
* using keyboard navigation works properly (we use `offsetTop` there).
49+
*/
50+
position: relative;
51+
}
52+
53+
[data-reach-combobox-list] {
54+
font-size: var(--font-size-body);
55+
padding: var(--px-4);
56+
}
57+
58+
[data-reach-combobox-option] {
59+
border-radius: var(--border-radius-4);
60+
color: var(--color-neutral-60);
61+
overflow-x: hidden;
62+
padding: var(--px-8) var(--px-12);
63+
text-overflow: ellipsis;
64+
white-space: nowrap;
65+
66+
&[data-highlighted] {
67+
background-color: var(--color-neutral-7);
68+
}
69+
70+
&:hover {
71+
background-color: var(--color-neutral-10);
72+
}
73+
74+
& + & {
75+
margin-top: var(--px-4);
76+
}
77+
}
78+
79+
.graphiql-doc-explorer-search-type {
80+
color: var(--color-blue);
81+
}
82+
83+
.graphiql-doc-explorer-search-field {
84+
color: var(--color-orche);
85+
}
86+
87+
.graphiql-doc-explorer-search-argument {
88+
color: var(--color-purple);
89+
}
90+
91+
.graphiql-doc-explorer-search-divider {
92+
color: var(--color-neutral-60);
93+
font-size: var(--font-size-hint);
94+
font-weight: var(--font-weight-medium);
95+
margin-top: var(--px-8);
96+
padding: var(--px-8) var(--px-12);
97+
}
98+
99+
.graphiql-doc-explorer-search-empty {
100+
color: var(--color-neutral-60);
101+
padding: var(--px-8) var(--px-12);
102+
}

0 commit comments

Comments
 (0)