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

4️⃣ replace @reach/combobox with Combobox from @headlessui/react #3184

Merged
merged 5 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shiny-carpets-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphiql/react': major
---

replace `@reach/combobox` with `Combobox` from `@headlessui/react`
4 changes: 2 additions & 2 deletions packages/graphiql-plugin-code-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"peerDependencies": {
"graphql": "^15.5.0 || ^16.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
"react": "^16.8.0 || ^17 || ^18",
"react-dom": "^16.8.0 || ^17 || ^18"
},
"devDependencies": {
"@graphiql/react": "^0.17.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql-plugin-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"peerDependencies": {
"graphql": "^15.5.0 || ^16.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
"react": "^16.8.0 || ^17 || ^18",
"react-dom": "^16.8.0 || ^17 || ^18"
},
"devDependencies": {
"@vitejs/plugin-react": "^1.3.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/graphiql-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
},
"peerDependencies": {
"graphql": "^15.5.0 || ^16.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
"react": "^16.8.0 || ^17 || ^18",
"react-dom": "^16.8.0 || ^17 || ^18"
},
"dependencies": {
"@headlessui/react": "^1.7.14",
"@radix-ui/react-dialog": "^1.0.3",
"@radix-ui/react-visually-hidden": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.4",
"@graphiql/toolkit": "^0.8.4",
"@reach/combobox": "^0.17.0",
"clsx": "^1.2.1",
"codemirror": "^5.65.3",
"codemirror-graphql": "^2.0.8",
Expand All @@ -58,8 +58,8 @@
"@vitejs/plugin-react": "^1.3.0",
"graphql": "^16.4.0",
"postcss-nesting": "^10.1.7",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.6.3",
"vite": "^2.9.13",
"vite-plugin-react-svg": "^0.2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

/* The search input in the header of the doc explorer */
.graphiql-doc-explorer-search {
height: 100%;
position: absolute;
right: 0;
top: 0;
Expand All @@ -37,12 +36,12 @@
left: 0;
}

& [data-reach-combobox-input] {
& [role='combobox'] {
height: 24px;
width: 4ch;
}

& [data-reach-combobox-input]:focus {
& [role='combobox']:focus {
width: 100%;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ export function DocExplorer() {
)}
<div className="graphiql-doc-explorer-title">{navItem.name}</div>
</div>
<div className="graphiql-doc-explorer-search">
<Search key={navItem.name} />
</div>
<Search key={navItem.name} />
</div>
<div className="graphiql-doc-explorer-content">{content}</div>
</section>
Expand Down
26 changes: 10 additions & 16 deletions packages/graphiql-react/src/explorer/components/search.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@import url('@reach/combobox/styles.css');

[data-reach-combobox] {
.graphiql-doc-explorer-search {
color: hsla(var(--color-neutral), var(--alpha-secondary));

&:not([data-state='idle']) {
Expand All @@ -11,8 +9,6 @@

& .graphiql-doc-explorer-search-input {
background: hsl(var(--color-base));
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}
}
Expand All @@ -25,7 +21,7 @@
padding: var(--px-8) var(--px-12);
}

[data-reach-combobox-input] {
.graphiql-doc-explorer-search [role='combobox'] {
border: none;
background-color: transparent;
margin-left: var(--px-4);
Expand All @@ -36,7 +32,7 @@
}
}

[data-reach-combobox-popover] {
.graphiql-doc-explorer-search [role='listbox'] {
background-color: hsl(var(--color-base));
border: none;
border-bottom-left-radius: var(--border-radius-4);
Expand All @@ -45,28 +41,26 @@
hsla(var(--color-neutral), var(--alpha-background-heavy));
max-height: 400px;
overflow-y: auto;

margin: 0;
font-size: var(--font-size-body);
padding: var(--px-4);
/**
* This makes sure that the logic for auto-scrolling the search results when
* using keyboard navigation works properly (we use `offsetTop` there).
*/
position: relative;
}

[data-reach-combobox-list] {
font-size: var(--font-size-body);
padding: var(--px-4);
}

[data-reach-combobox-option] {
.graphiql-doc-explorer-search [role='option'] {
border-radius: var(--border-radius-4);
color: hsla(var(--color-neutral), var(--alpha-secondary));
overflow-x: hidden;
padding: var(--px-8) var(--px-12);
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;

&[data-highlighted] {
&[data-headlessui-state="active"] {
background-color: hsla(var(--color-neutral), var(--alpha-background-light));
}

Expand All @@ -77,7 +71,7 @@
);
}

&[data-highlighted]:hover {
&[data-headlessui-state="active"]:hover {
background-color: hsla(var(--color-neutral), var(--alpha-background-heavy));
}

Expand Down
Loading