Tweak tab visuals

Make selected tabs not change on hover. Change unselected tabs to use regular
font weight and foreground-contrast.
This commit is contained in:
Rūdolfs Ošiņš
2024-01-15 18:28:22 +00:00
parent 87afc6204c
commit 8e580385f0
10 changed files with 54 additions and 30 deletions
+2 -2
View File
@@ -25,14 +25,14 @@
justify-content: space-between;
align-items: center;
margin: 0;
padding: 0.5rem;
padding: 0.5rem 1rem;
height: 3.5rem;
}
.left,
.right {
display: flex;
align-items: center;
gap: 1rem;
gap: 0.5rem;
}
.logo {
+5 -3
View File
@@ -42,14 +42,14 @@
<Button
ariaLabel="Light Mode"
styleBorderRadius="0"
variant={$theme === "light" ? "gray-white" : "dim"}
variant={$theme === "light" ? "selected" : "not-selected"}
on:click={() => storeTheme("light")}>
<Icon name="sun" />
</Button>
<Button
ariaLabel="Dark Mode"
styleBorderRadius="0"
variant={$theme === "dark" ? "gray-white" : "dim"}
variant={$theme === "dark" ? "selected" : "not-selected"}
on:click={() => storeTheme("dark")}>
<Icon name="moon" />
</Button>
@@ -65,7 +65,9 @@
styleBorderRadius="0"
styleFontFamily={font.fontFamily}
on:click={() => storeCodeFont(font.storedName)}
variant={$codeFont === font.storedName ? "gray-white" : "dim"}>
variant={$codeFont === font.storedName
? "selected"
: "not-selected"}>
{font.displayName}
</Button>
{/each}
+23 -8
View File
@@ -3,9 +3,10 @@
export let title: string | undefined = undefined;
export let variant:
| "background"
| "dim"
| "not-selected"
| "gray"
| "gray-white"
| "selected"
| "none"
| "outline"
| "primary-toggle-off"
@@ -75,29 +76,33 @@
}
.background {
color: var(--color-foreground-dim);
color: var(--color-foreground-contrast);
background-color: var(--color-background-default);
font-weight: var(--font-weight-regular);
}
.background[disabled] {
color: var(--color-foreground-disabled);
background-color: var(--color-background-default);
font-weight: var(--font-weight-regular);
}
.background:not([disabled]):hover {
color: var(--color-foreground-contrast);
background-color: var(--color-fill-ghost);
}
.dim {
.not-selected {
background-color: var(--color-fill-float-hover);
color: var(--color-foreground-dim);
color: var(--color-foreground-contrast);
font-weight: var(--font-weight-normal);
}
.dim[disabled] {
.not-selected[disabled] {
background-color: var(--color-fill-float-hover);
color: var(--color-fill-secondary);
font-weight: var(--font-weight-normal);
}
.dim:not([disabled]):hover {
.not-selected:not([disabled]):hover {
background-color: var(--color-fill-ghost-hover);
color: var(--color-foreground-dim);
color: var(--color-foreground-contrast);
}
.gray {
@@ -125,6 +130,15 @@
background-color: var(--color-fill-ghost-hover);
color: var(--color-foreground-contrast);
}
.selected {
background-color: var(--color-fill-ghost);
color: var(--color-foreground-contrast);
cursor: default;
}
.selected[disabled] {
background-color: var(--color-fill-ghost);
color: var(--color-foreground-disabled);
}
.none {
background-color: transparent;
@@ -342,8 +356,9 @@
class:regular={size === "regular"}
class:large={size === "large"}
class:background={variant === "background"}
class:dim={variant === "dim"}
class:not-selected={variant === "not-selected"}
class:gray-white={variant === "gray-white"}
class:selected={variant === "selected"}
class:gray={variant === "gray"}
class:none={variant === "none"}
class:outline={variant === "outline"}
+2 -2
View File
@@ -169,7 +169,7 @@
<Radio>
<Button
styleBorderRadius="0"
variant={!preview ? "gray-white" : "dim"}
variant={!preview ? "selected" : "not-selected"}
on:click={() => {
preview = false;
}}>
@@ -179,7 +179,7 @@
<Button
styleBorderRadius="0"
disabled={validateBody && !body}
variant={preview ? "gray-white" : "dim"}
variant={preview ? "selected" : "not-selected"}
on:click={() => {
preview = true;
}}>
+1 -1
View File
@@ -754,7 +754,7 @@
<Button
styleBorderRadius="0"
size="regular"
variant={name === view.name ? "gray-white" : "dim"}>
variant={name === view.name ? "selected" : "not-selected"}>
<IconSmall name={icon} />
{capitalize(name)}
</Button>
+2 -2
View File
@@ -204,7 +204,7 @@
<Radio ariaLabel="Toggle render method">
<Button
styleBorderRadius="0"
variant={showMarkdown ? "gray-white" : "dim"}
variant={showMarkdown ? "selected" : "not-selected"}
on:click={() => {
window.location.hash = "";
showMarkdown = true;
@@ -213,7 +213,7 @@
</Button>
<Button
styleBorderRadius="0"
variant={!showMarkdown ? "gray-white" : "dim"}
variant={!showMarkdown ? "selected" : "not-selected"}
on:click={() => {
showMarkdown = false;
}}>
@@ -98,7 +98,7 @@
<Button
title="Current HEAD"
variant="dim"
variant="not-selected"
styleBorderRadius={selectedBranch
? "0 var(--border-radius-tiny) var(--border-radius-tiny) 0"
: "var(--border-radius-tiny)"}>
+8 -1
View File
@@ -104,6 +104,7 @@
}}>
<Button
styleBorderRadius="0"
size="large"
variant={filesLinkActive ? "tab-active" : "tab"}>
<IconSmall name="file" />Files
</Button>
@@ -119,6 +120,7 @@
}}>
<Button
styleBorderRadius="0"
size="large"
variant={historyLinkActive ? "tab-active" : "tab"}>
<IconSmall name="commit" />
<div class="title-counter">
@@ -133,7 +135,12 @@
<div class="global-hide-on-mobile">
<HoverPopover stylePopoverPositionLeft="0" stylePopoverPositionTop="0.5rem">
<Button disabled notAllowed={false} variant="tab" slot="toggle">
<Button
disabled
notAllowed={false}
variant="tab"
slot="toggle"
size="large">
<IconSmall name="user" />
<div class="title-counter">
Contributors
+8 -8
View File
@@ -113,7 +113,7 @@ test("navigate line numbers", async ({ page }) => {
// file.
await page.getByRole("link", { name: "footnotes.md" }).click();
await expect(page.getByRole("button", { name: "Markdown" })).toHaveClass(
/gray-white/,
/selected/,
);
});
@@ -239,17 +239,17 @@ test("markdown files", async ({ page }) => {
// Switch between raw and rendered modes.
{
await expect(page.getByRole("button", { name: "Markdown" })).toHaveClass(
/gray-white/,
/selected/,
);
await expect(page.getByRole("button", { name: "Plain" })).not.toHaveClass(
/gray-white/,
await expect(page.getByRole("button", { name: "Plain" })).toHaveClass(
/not-selected/,
);
await page.getByRole("button", { name: "Plain" }).click();
await expect(
page.getByRole("button", { name: "Markdown" }),
).not.toHaveClass(/gray-white/);
await expect(page.getByRole("button", { name: "Markdown" })).toHaveClass(
/not-selected/,
);
await expect(page.getByRole("button", { name: "Plain" })).toHaveClass(
/gray-white/,
/selected/,
);
await expect(page.getByText("##### Table of Contents")).toBeVisible();
await page.getByRole("button", { name: "Markdown" }).click();
+2 -2
View File
@@ -68,11 +68,11 @@ test("change code font", async ({ page }) => {
await page.getByRole("button", { name: "Settings" }).first().click();
await page.getByText("System").click();
await expect(page.getByText("System")).toHaveClass(/gray-white/);
await expect(page.getByText("System")).toHaveClass(/selected/);
await expect(page.locator("html")).toHaveAttribute("data-codefont", "system");
await page.getByText("JetBrains Mono").click();
await expect(page.getByText("JetBrains Mono")).toHaveClass(/gray-white/);
await expect(page.getByText("JetBrains Mono")).toHaveClass(/selected/);
await expect(page.locator("html")).toHaveAttribute(
"data-codefont",
"jetbrains",