mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Implement repo home page
- by default open repos on the home view - show a rendered README on the repo home page - show repo metadata: visibility, canonical branch, threshold, delegates and allow list with aliases - make layout responsive on repo home - add copy button to code blocks in markdown
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
<svelte:options customElement="radicle-clipboard" />
|
||||
|
||||
<script lang="ts">
|
||||
import debounce from "lodash/debounce";
|
||||
|
||||
|
||||
+21
-16
@@ -8,8 +8,9 @@
|
||||
|
||||
interface Props {
|
||||
children: Snippet;
|
||||
expanded: boolean;
|
||||
leftHeader: Snippet;
|
||||
expandable?: boolean;
|
||||
expanded?: boolean;
|
||||
leftHeader?: Snippet;
|
||||
rightHeader?: Snippet;
|
||||
sticky?: boolean;
|
||||
}
|
||||
@@ -17,10 +18,11 @@
|
||||
/* eslint-disable prefer-const */
|
||||
let {
|
||||
children,
|
||||
expanded,
|
||||
expanded = true,
|
||||
leftHeader,
|
||||
rightHeader,
|
||||
sticky = true,
|
||||
expandable = true,
|
||||
}: Props = $props();
|
||||
/* eslint-enable prefer-const */
|
||||
|
||||
@@ -36,6 +38,7 @@
|
||||
z-index: 2;
|
||||
font-size: var(--font-size-small);
|
||||
background-color: var(--color-background-default);
|
||||
position: relative;
|
||||
}
|
||||
.header::after {
|
||||
position: absolute;
|
||||
@@ -84,19 +87,21 @@
|
||||
|
||||
<div class="header" class:sticky class:collapsed={!expanded} bind:this={header}>
|
||||
<div class="left">
|
||||
<NakedButton
|
||||
stylePadding="0 4px"
|
||||
variant="ghost"
|
||||
onclick={async () => {
|
||||
expanded = !expanded;
|
||||
if (!expanded && header) {
|
||||
await tick();
|
||||
header.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
||||
}
|
||||
}}>
|
||||
<Icon name={expanded ? "chevron-down" : "chevron-right"} />
|
||||
</NakedButton>
|
||||
{@render leftHeader()}
|
||||
{#if expandable}
|
||||
<NakedButton
|
||||
stylePadding="0 4px"
|
||||
variant="ghost"
|
||||
onclick={async () => {
|
||||
expanded = !expanded;
|
||||
if (!expanded && header) {
|
||||
await tick();
|
||||
header.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
||||
}
|
||||
}}>
|
||||
<Icon name={expanded ? "chevron-down" : "chevron-right"} />
|
||||
</NakedButton>
|
||||
{/if}
|
||||
{@render leftHeader?.()}
|
||||
</div>
|
||||
{#if rightHeader}
|
||||
<div
|
||||
|
||||
@@ -58,8 +58,19 @@
|
||||
|
||||
<div class="container">
|
||||
<div>
|
||||
<div style:margin-bottom="1rem" style:padding-left="0.75rem">
|
||||
<RepoTeaser name={project.data.name} seeding={repo.seeding} />
|
||||
<div style:margin-bottom="0.75rem">
|
||||
<Link
|
||||
styleWidth="100%"
|
||||
underline={false}
|
||||
route={{ resource: "repo.home", rid: repo.rid }}>
|
||||
<div
|
||||
class="tab"
|
||||
style:color="var(--color-foreground-contrast)"
|
||||
style:padding-right="0.5rem"
|
||||
style:padding-left="0.75rem">
|
||||
<RepoTeaser name={project.data.name} seeding={repo.seeding} />
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<Border
|
||||
|
||||
@@ -141,6 +141,15 @@
|
||||
const treeChanges: Promise<void>[] = [];
|
||||
|
||||
for (const node of nodes) {
|
||||
const preElement = node.parentElement as HTMLElement;
|
||||
const copyButton = document.createElement("radicle-clipboard");
|
||||
copyButton.setAttribute("text", node.textContent || "");
|
||||
const preWrapper = document.createElement("div");
|
||||
preWrapper.classList.add("pre-wrapper");
|
||||
preElement.parentNode?.insertBefore(preWrapper, preElement);
|
||||
preWrapper.appendChild(preElement);
|
||||
preWrapper.appendChild(copyButton);
|
||||
|
||||
const className = Array.from(node.classList).find(name =>
|
||||
name.startsWith(prefix),
|
||||
);
|
||||
@@ -217,8 +226,8 @@
|
||||
.markdown :global(radicle-clipboard) {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 0.5rem;
|
||||
top: 0.5rem;
|
||||
right: 0.75rem;
|
||||
top: 0.75rem;
|
||||
}
|
||||
|
||||
.markdown :global(radicle-clipboard) {
|
||||
|
||||
@@ -63,8 +63,19 @@
|
||||
|
||||
<div class="container">
|
||||
<div>
|
||||
<div style:margin-bottom="1rem" style:padding-left="0.75rem">
|
||||
<RepoTeaser name={project.data.name} seeding={repo.seeding} />
|
||||
<div style:margin-bottom="0.75rem">
|
||||
<Link
|
||||
styleWidth="100%"
|
||||
underline={false}
|
||||
route={{ resource: "repo.home", rid: repo.rid }}>
|
||||
<div
|
||||
class="tab"
|
||||
style:color="var(--color-foreground-contrast)"
|
||||
style:padding-right="0.5rem"
|
||||
style:padding-left="0.75rem">
|
||||
<RepoTeaser name={project.data.name} seeding={repo.seeding} />
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div style:margin-bottom="0.5rem">
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<script lang="ts">
|
||||
import type { RepoInfo } from "@bindings/repo/RepoInfo";
|
||||
|
||||
import Border from "./Border.svelte";
|
||||
import Icon from "./Icon.svelte";
|
||||
import Link from "./Link.svelte";
|
||||
import RepoTeaser from "./RepoTeaser.svelte";
|
||||
import Settings from "./Settings.svelte";
|
||||
|
||||
interface Props {
|
||||
repo: RepoInfo;
|
||||
}
|
||||
|
||||
const { repo }: Props = $props();
|
||||
|
||||
const project = $derived(repo.payloads["xyz.radicle.project"]!);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.tab {
|
||||
align-items: center;
|
||||
background-color: var(--color-background-float);
|
||||
clip-path: var(--1px-corner-fill);
|
||||
display: flex;
|
||||
font-size: var(--font-size-small);
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 0.25rem 0.5rem 0.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
.tab:not(.active) {
|
||||
color: var(--color-foreground-dim);
|
||||
}
|
||||
.tab:not(.active):hover {
|
||||
background-color: var(--color-fill-float-hover);
|
||||
}
|
||||
.active {
|
||||
background-color: var(--color-background-default);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
padding: 0.25rem 0.25rem 0.25rem 0.5rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<div>
|
||||
<div style:margin-bottom="0.75rem">
|
||||
<Border
|
||||
variant="ghost"
|
||||
styleBackgroundColor="var(--color-background-default)">
|
||||
<div class="tab active" style:color="var(--color-foreground-contrast)">
|
||||
<RepoTeaser name={project.data.name} seeding={repo.seeding} />
|
||||
</div>
|
||||
</Border>
|
||||
</div>
|
||||
|
||||
<div style:margin-bottom="0.5rem">
|
||||
<Link
|
||||
styleWidth="100%"
|
||||
underline={false}
|
||||
route={{ resource: "repo.issues", rid: repo.rid, status: "open" }}>
|
||||
<div
|
||||
class="tab"
|
||||
style:color="var(--color-foreground-contrast)"
|
||||
style:padding-left="0.75rem">
|
||||
<div class="global-flex"><Icon name="issue" />Issues</div>
|
||||
<div class="global-counter">
|
||||
{project.meta.issues.open + project.meta.issues.closed}
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div style:margin-top="0.5rem">
|
||||
<Link
|
||||
styleWidth="100%"
|
||||
underline={false}
|
||||
route={{ resource: "repo.patches", rid: repo.rid, status: "open" }}>
|
||||
<div
|
||||
class="tab"
|
||||
style:color="var(--color-foreground-contrast)"
|
||||
style:padding-left="0.75rem">
|
||||
<div class="global-flex"><Icon name="patch" />Patches</div>
|
||||
<div class="global-counter">
|
||||
{project.meta.patches.draft +
|
||||
project.meta.patches.open +
|
||||
project.meta.patches.archived +
|
||||
project.meta.patches.merged}
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Settings
|
||||
compact={false}
|
||||
popoverProps={{
|
||||
popoverPositionBottom: "3rem",
|
||||
popoverPositionLeft: "0",
|
||||
}} />
|
||||
</div>
|
||||
@@ -0,0 +1,128 @@
|
||||
<script lang="ts">
|
||||
import type { RepoInfo } from "@bindings/repo/RepoInfo";
|
||||
|
||||
import sortBy from "lodash/sortBy.js";
|
||||
|
||||
import { authorForNodeId } from "@app/lib/utils";
|
||||
|
||||
import Border from "@app/components/Border.svelte";
|
||||
import Id from "@app/components/Id.svelte";
|
||||
import NodeId from "@app/components/NodeId.svelte";
|
||||
import VisibilityBadge from "@app/components/VisibilityBadge.svelte";
|
||||
import Icon from "./Icon.svelte";
|
||||
|
||||
interface Props {
|
||||
horizontal?: boolean;
|
||||
repo: RepoInfo;
|
||||
}
|
||||
|
||||
const { horizontal = false, repo }: Props = $props();
|
||||
|
||||
const project = $derived(repo.payloads["xyz.radicle.project"]!);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.list {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.horizontal {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.metadata-divider {
|
||||
width: 2px;
|
||||
background-color: var(--color-fill-ghost);
|
||||
height: calc(100% + 4px);
|
||||
top: 0;
|
||||
position: relative;
|
||||
}
|
||||
.metadata-divider-horizontal {
|
||||
height: 2px;
|
||||
background-color: var(--color-fill-ghost);
|
||||
width: calc(100% + 4px);
|
||||
top: 0;
|
||||
left: -2px;
|
||||
position: relative;
|
||||
}
|
||||
.metadata-section {
|
||||
padding: 0.5rem;
|
||||
font-size: var(--font-size-small);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
flex: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.metadata-section-title {
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--color-foreground-dim);
|
||||
}
|
||||
</style>
|
||||
|
||||
<Border
|
||||
variant="ghost"
|
||||
styleGap="0"
|
||||
styleFlexDirection="column"
|
||||
styleAlignItems="flex-start">
|
||||
<div class="metadata-section" style:flex="1" style:width="100%">
|
||||
<div class="metadata-section-title">Visibility</div>
|
||||
<VisibilityBadge type={repo.visibility.type} />
|
||||
</div>
|
||||
|
||||
{#if repo.visibility.type === "private"}
|
||||
<div class="metadata-divider-horizontal"></div>
|
||||
|
||||
<div class="metadata-section" style:flex="1" style:width="100%">
|
||||
<div class="metadata-section-title">Allow</div>
|
||||
{#if repo.visibility.allow}
|
||||
<div class="global-flex list" class:horizontal>
|
||||
{#each repo.visibility.allow as node}
|
||||
<NodeId {...authorForNodeId(node)} />
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="global-flex txt-missing" style:gap="0.25rem">
|
||||
<Icon name="none" /> None
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="metadata-divider-horizontal"></div>
|
||||
|
||||
<div class="metadata-section" style:flex="1" style:width="100%">
|
||||
<div class="metadata-section-title">Delegates</div>
|
||||
<div class="global-flex list" class:horizontal>
|
||||
{#each sortBy(repo.delegates, d => {
|
||||
return d.alias?.toLowerCase();
|
||||
}) as delegate}
|
||||
<NodeId {...authorForNodeId(delegate)} />
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="metadata-divider-horizontal"></div>
|
||||
|
||||
<div
|
||||
class="global-flex"
|
||||
style:gap="0"
|
||||
style:flex-direction="row"
|
||||
style:width="100%">
|
||||
<div class="metadata-section">
|
||||
<div class="metadata-section-title">Default branch</div>
|
||||
<span>
|
||||
<span class="txt-selectable">{project.data.defaultBranch}</span>
|
||||
->
|
||||
<Id id={project.meta.head} variant="commit" />
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="metadata-divider"></div>
|
||||
|
||||
<div class="metadata-section">
|
||||
<div class="metadata-section-title">Threshold</div>
|
||||
{repo.threshold}
|
||||
</div>
|
||||
</div>
|
||||
</Border>
|
||||
@@ -12,7 +12,7 @@
|
||||
<style>
|
||||
.teaser {
|
||||
align-items: center;
|
||||
min-height: 2.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.seeding {
|
||||
|
||||
@@ -39,7 +39,16 @@
|
||||
|
||||
<div class="global-flex" style:flex-direction="column" style:gap="0.5rem">
|
||||
<div class="global-flex" style:height="2.5rem">
|
||||
<Icon name="repo" />
|
||||
<button
|
||||
class="sidebar-button"
|
||||
onclick={() => {
|
||||
void router.push({
|
||||
resource: "repo.home",
|
||||
rid,
|
||||
});
|
||||
}}>
|
||||
<Icon name="repo" />
|
||||
</button>
|
||||
</div>
|
||||
{#if activeTab === "issues"}
|
||||
<Border
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<script lang="ts">
|
||||
import type { Visibility } from "@bindings/repo/Visibility";
|
||||
|
||||
import capitalize from "lodash/capitalize.js";
|
||||
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
|
||||
interface Props {
|
||||
type: Visibility["type"];
|
||||
}
|
||||
|
||||
const { type }: Props = $props();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.badge {
|
||||
gap: 0.375rem;
|
||||
padding-right: 0.625rem;
|
||||
}
|
||||
|
||||
.public {
|
||||
background-color: var(--color-fill-diff-green-light);
|
||||
color: var(--color-foreground-success);
|
||||
}
|
||||
.private {
|
||||
background-color: var(--color-fill-private);
|
||||
color: var(--color-foreground-yellow);
|
||||
}
|
||||
</style>
|
||||
|
||||
<span
|
||||
class="global-counter badge"
|
||||
class:public={type === "public"}
|
||||
class:private={type === "private"}>
|
||||
<Icon name={type === "public" ? "seedling" : "lock"} />
|
||||
{capitalize(type)}
|
||||
</span>
|
||||
Reference in New Issue
Block a user