Skip to content

Commit

Permalink
Extract header from repo card
Browse files Browse the repository at this point in the history
This will be reused in the repo sidebar.
  • Loading branch information
rudolfs committed Sep 13, 2024
1 parent 4f63f9e commit a5601e7
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 35 deletions.
3 changes: 2 additions & 1 deletion src/components/Border.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
export let styleHeight: string | undefined = undefined;
export let styleMinHeight: string | undefined = undefined;
export let styleWidth: string | undefined = undefined;
export let styleCursor: "default" | "pointer" = "default";
$: style =
`--local-button-color-1: var(--color-fill-${variant});` +
Expand Down Expand Up @@ -110,7 +111,6 @@
}
.container {
cursor: pointer;
white-space: nowrap;
-webkit-touch-callout: none;
Expand Down Expand Up @@ -150,6 +150,7 @@
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
style:width={styleWidth}
style:cursor={styleCursor}
class="container"
{onclick}
role="button"
Expand Down
3 changes: 2 additions & 1 deletion src/components/Fill.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export let stylePadding: string | undefined = undefined;
export let styleHeight: string | undefined = undefined;
export let styleWidth: string | undefined = undefined;
export let styleCursor: "inherit" | "pointer" = "inherit";
export let onclick: (() => void) | undefined = undefined;
$: style =
Expand Down Expand Up @@ -61,7 +62,6 @@
}
.container {
cursor: pointer;
white-space: nowrap;
-webkit-touch-callout: none;
Expand All @@ -88,6 +88,7 @@
{onclick}
{style}
style:width={styleWidth}
style:cursor={styleCursor}
style:height={styleHeight}>
<div class="pixel p1-1"></div>
<div class="pixel p1-2"></div>
Expand Down
36 changes: 3 additions & 33 deletions src/components/RepoCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import { formatRepositoryId, formatTimestamp } from "@app/lib/utils";
import Border from "./Border.svelte";
import Fill from "./Fill.svelte";
import Icon from "./Icon.svelte";
import RepoHeader from "./RepoHeader.svelte";
export let repo: RepoInfo;
export let selfDid: string;
Expand All @@ -15,9 +15,6 @@
</script>

<style>
.header {
justify-content: space-between;
}
.footer {
margin-top: 1rem;
justify-content: space-between;
Expand All @@ -34,40 +31,13 @@

<Border
variant="ghost"
styleCursor="pointer"
styleWidth="100%"
stylePadding="8px 12px"
hoverable
{onclick}>
<div class="container txt-small">
<div class="global-flex header">
<div class="global-flex">
<Fill styleWidth="1.5rem" styleHeight="24px" variant="ghost">
{project.data.name[0]}
</Fill>{project.data.name}
</div>
<div class="global-flex">
{#if repo.visibility.type === "private"}
<Fill variant="private" styleWidth="24px" styleHeight="24px">
<div style:color="var(--color-foreground-yellow)">
<Icon name="lock" />
</div>
</Fill>
{/if}
{#if repo.delegates.find(x => x.did === selfDid)}
<Fill variant="delegate" styleWidth="24px" styleHeight="24px">
<div style:color="var(--color-fill-primary)">
<Icon name="delegate" />
</div>
</Fill>
{/if}
<div class="global-flex">
<Fill variant="ghost" styleHeight="24px" stylePadding="0 4px">
<Icon name="seedling" />
{repo.seeding}
</Fill>
</div>
</div>
</div>
<RepoHeader {repo} {selfDid} />

<div class="title">
{#if project.data.description}
Expand Down
54 changes: 54 additions & 0 deletions src/components/RepoHeader.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script lang="ts">
import type { RepoInfo } from "@bindings/RepoInfo";
import Fill from "./Fill.svelte";
import Icon from "./Icon.svelte";
export let repo: RepoInfo;
export let selfDid: string;
export let emphasizedTitle: boolean = true;
$: project = repo.payloads["xyz.radicle.project"]!;
</script>

<style>
.header {
justify-content: space-between;
width: 100%;
}
</style>

<div class="global-flex header txt-small">
<div class="global-flex">
<Fill styleWidth="1.5rem" styleHeight="24px" variant="ghost">
{project.data.name[0]}
</Fill>
{#if emphasizedTitle}
<span class="txt-regular txt-semibold">{project.data.name}</span>
{:else}
<span class="txt-small txt-semibold">{project.data.name}</span>
{/if}
</div>
<div class="global-flex">
{#if repo.visibility.type === "private"}
<Fill variant="private" styleWidth="24px" styleHeight="24px">
<div style:color="var(--color-foreground-yellow)">
<Icon name="lock" />
</div>
</Fill>
{/if}
{#if repo.delegates.find(x => x.did === selfDid)}
<Fill variant="delegate" styleWidth="24px" styleHeight="24px">
<div style:color="var(--color-fill-primary)">
<Icon name="delegate" />
</div>
</Fill>
{/if}
<div class="global-flex">
<Fill variant="ghost" styleHeight="24px" stylePadding="0 4px">
<Icon name="seedling" />
<span style:line-height="16px">{repo.seeding}</span>
</Fill>
</div>
</div>
</div>
2 changes: 2 additions & 0 deletions src/components/ThemeSwitch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<div style="display: flex; gap: 1rem;">
<Border variant="secondary">
<Fill
styleCursor="pointer"
stylePadding="0 0.5rem"
variant={$theme === "dark" ? "secondary" : "transparent"}
onclick={() => {
Expand All @@ -47,6 +48,7 @@
</Fill>

<Fill
styleCursor="pointer"
stylePadding="0 0.5rem"
variant={$theme === "light" ? "secondary" : "transparent"}
onclick={() => {
Expand Down

0 comments on commit a5601e7

Please sign in to comment.