Skip to content

Commit

Permalink
Style patch tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolfs committed Jan 15, 2025
1 parent 6326863 commit 9d432d4
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 106 deletions.
22 changes: 21 additions & 1 deletion src/components/Border.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
styleHeight?: string;
styleMinHeight?: string;
styleWidth?: string;
styleDisplay?: string;
styleCursor?: "default" | "pointer" | "text";
styleGap?: string;
styleOverflow?: string;
flatTop?: boolean;
flatBottom?: boolean;
styleBackgroundColor?: string;
styleFlexDirection?: string;
styleAlignItems?: string;
Expand All @@ -31,10 +33,12 @@
styleMinHeight,
stylePosition,
styleWidth,
styleDisplay = "flex",
styleCursor = "default",
styleGap = "0.5rem",
styleOverflow,
flatTop = false,
flatBottom = false,
styleBackgroundColor = "var(--color-background-default)",
styleFlexDirection = "row",
styleAlignItems = "center",
Expand Down Expand Up @@ -130,7 +134,6 @@
}
.p3-3 {
grid-area: p3-3;
display: flex;
background-color: var(--local-background-color);
}
.p3-4 {
Expand Down Expand Up @@ -196,6 +199,21 @@
.flat-top > .p2-5 {
background-color: var(--local-button-color-1);
}
.flat-bottom > .p4-2,
.flat-bottom > .p4-4 {
background-color: transparent;
}
.flat-bottom > .p4-1,
.flat-bottom > .p4-5,
.flat-bottom > .p5-3,
.flat-bottom > .p5-1,
.flat-bottom > .p5-2,
.flat-bottom > .p5-4,
.flat-bottom > .p5-5 {
background-color: var(--local-button-color-1);
}
</style>

<!-- svelte-ignore a11y_click_events_have_key_events -->
Expand All @@ -204,6 +222,7 @@
style:cursor={styleCursor}
class="container"
class:flat-top={flatTop}
class:flat-bottom={flatBottom}
{onclick}
role="button"
tabindex={onclick !== undefined ? 0 : -1}
Expand All @@ -226,6 +245,7 @@
<div class="p3-2"></div>
<div
class="p3-3"
style:display={styleDisplay}
style:position={stylePosition}
style:padding={stylePadding}
style:gap={styleGap}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Changeset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
display: flex;
flex-direction: column;
}
.diff:not(:last-of-type) {
margin-bottom: 1rem;
}
</style>

<div class="diff-list">
{#each diff.files as file}
<div style:margin-bottom="1rem">
<div class="diff">
<FileDiff
filePath={"path" in file ? file.path : file.newPath}
oldFilePath={"oldPath" in file ? file.oldPath : undefined}
Expand Down
5 changes: 3 additions & 2 deletions src/components/File.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<style>
.header {
display: flex;
height: 3rem;
align-items: center;
padding: 0 0.5rem 0 1rem;
height: 2.5rem;
padding-left: 1rem;
z-index: 2;
font-size: var(--font-size-small);
}
Expand Down Expand Up @@ -46,6 +46,7 @@
.container {
position: relative;
overflow-x: auto;
z-index: 1;
}
.container::after {
position: absolute;
Expand Down
74 changes: 74 additions & 0 deletions src/components/Tab.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<script lang="ts">
import type { Snippet } from "svelte";
interface Props {
children: Snippet;
onclick?: () => void;
disabled?: boolean;
active?: boolean;
flatLeft?: boolean;
flatRight?: boolean;
}
const {
children,
onclick = undefined,
disabled = false,
active = false,
flatLeft = false,
flatRight = false,
}: Props = $props();
</script>

<style>
.container {
white-space: nowrap;
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;
display: flex;
flex-direction: row;
font-size: var(--font-size-small);
}
.wrapper {
position: relative;
display: flex;
gap: 0.5rem;
padding: 5px 0;
}
.active {
font-weight: var(--font-weight-semibold);
}
.wrapper.active::after {
position: absolute;
z-index: 1;
content: " ";
background-color: var(--color-fill-secondary);
height: 2px;
bottom: -4px;
width: 100%;
}
.container.disabled {
color: var(--color-foreground-disabled);
}
</style>

<!-- svelte-ignore a11y_click_events_have_key_events -->
<div
class="container"
style:cursor={!disabled ? "pointer" : "default"}
class:disabled
class:flat-right={flatRight}
class:flat-left={flatLeft}
onclick={!disabled ? onclick : undefined}
role="button"
tabindex="0">
<div class="wrapper" class:active>
{@render children()}
</div>
</div>
Loading

0 comments on commit 9d432d4

Please sign in to comment.