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

add hover styles for buttons #2741

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all 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/cool-zebras-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'graphiql': patch
---

Improved sizing of button for adding tabs
5 changes: 5 additions & 0 deletions .changeset/thin-hairs-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphiql/react': patch
---

Add hover styles for buttons
4 changes: 4 additions & 0 deletions packages/graphiql-react/src/toolbar/execute.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ button.graphiql-execute-button {
padding: 0;
width: var(--toolbar-width);

&:hover {
background-color: hsla(var(--color-primary), 0.9);
}

&:active {
background-color: hsla(var(--color-primary), 0.8);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/graphiql-react/src/ui/button-group.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

& > button.graphiql-button {
background-color: transparent;
&:hover {
background-color: hsla(var(--color-neutral), 0.07);
}
&.active {
background-color: hsl(var(--color-base));
cursor: default;
}
}

Expand Down
7 changes: 6 additions & 1 deletion packages/graphiql-react/src/ui/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ button.graphiql-un-styled {
border-radius: var(--border-radius-4);
cursor: pointer;

&:active {
&:hover {
background-color: hsla(var(--color-neutral), 0.07);
}

&:active {
background-color: hsla(var(--color-neutral), 0.1);
}

&:focus {
outline: hsla(var(--color-neutral), 0.15) auto 1px;
}
Expand All @@ -23,6 +27,7 @@ button.graphiql-button {
font-size: var(--font-size-body);
padding: var(--px-8) var(--px-12);

&:hover,
&:active {
background-color: hsla(var(--color-neutral), 0.1);
}
Expand Down
38 changes: 21 additions & 17 deletions packages/graphiql/src/components/GraphiQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,24 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
/>
</Tab>
))}
<div>
<Tooltip label="Add tab">
<UnStyledButton
type="button"
className="graphiql-tab-add"
onClick={() => editorContext.addTab()}
aria-label="Add tab"
>
<PlusIcon aria-hidden="true" />
</UnStyledButton>
</Tooltip>
</div>
</>
) : null}
</Tabs>
<div className="graphiql-session-header-right">
{editorContext.tabs.length === 1 ? (
<div className="graphiql-add-tab-wrapper">
<Tooltip label="Add tab">
<UnStyledButton
type="button"
Expand All @@ -445,23 +463,9 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
<PlusIcon aria-hidden="true" />
</UnStyledButton>
</Tooltip>
</>
) : null}
</Tabs>
<div className="graphiql-session-header-right">
{editorContext.tabs.length === 1 ? (
<Tooltip label="Add tab">
<UnStyledButton
type="button"
className="graphiql-tab-add"
onClick={() => editorContext.addTab()}
aria-label="Add tab"
>
<PlusIcon aria-hidden="true" />
</UnStyledButton>
</Tooltip>
</div>
) : null}
<div className="graphiql-logo">{logo}</div>
{logo}
</div>
</div>
<div
Expand Down Expand Up @@ -813,7 +817,7 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
// Configure the UI by providing this Component as a child of GraphiQL.
function GraphiQLLogo<TProps>(props: PropsWithChildren<TProps>) {
return (
<div className="title">
<div className="graphiql-logo">
{props.children || (
<a
className="graphiql-logo-link"
Expand Down
6 changes: 3 additions & 3 deletions packages/graphiql/src/components/__tests__/GraphiQL.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ describe('GraphiQL', () => {
expect(
container.querySelector('.graphiql-container'),
).toBeInTheDocument();
expect(container.querySelector('.title')).toBeInTheDocument();
expect(container.querySelector('.graphiql-logo')).toBeInTheDocument();
expect(getByRole('toolbar')).toBeInTheDocument();
});

Expand All @@ -401,7 +401,7 @@ describe('GraphiQL', () => {
expect(
container.querySelector('.graphiql-container'),
).toBeInTheDocument();
expect(container.querySelector('.title')).toBeInTheDocument();
expect(container.querySelector('.graphiql-logo')).toBeInTheDocument();
expect(getByRole('toolbar')).toBeInTheDocument();
});

Expand All @@ -421,7 +421,7 @@ describe('GraphiQL', () => {
expect(
container.querySelector('.graphiql-container'),
).toBeInTheDocument();
expect(container.querySelector('.title')).toBeInTheDocument();
expect(container.querySelector('.graphiql-logo')).toBeInTheDocument();
expect(getByRole('toolbar')).toBeInTheDocument();
});

Expand Down
8 changes: 6 additions & 2 deletions packages/graphiql/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,22 @@

/* The button to add a new tab */
button.graphiql-tab-add {
margin-left: var(--px-12);
height: 100%;
padding: 0 var(--px-4);
}
button.graphiql-tab-add > svg {
color: hsla(var(--color-neutral), 0.6);
display: block;
height: var(--px-16);
width: var(--px-16);
}
.graphiql-add-tab-wrapper {
padding: var(--px-12) 0;
}

/* The right-hand-side of the session header */
.graphiql-container .graphiql-session-header-right {
align-items: center;
align-items: stretch;
display: flex;
}

Expand Down