diff --git a/src/components/repo/RepoReadme.tsx b/src/components/repo/RepoReadme.tsx index 7044ba4..5f7081c 100644 --- a/src/components/repo/RepoReadme.tsx +++ b/src/components/repo/RepoReadme.tsx @@ -1,5 +1,6 @@ import type { $output as RepoTreeResponse } from '@atcute/tangled/types/repo/tree' import { MarkdownContent } from '../shared/MarkdownContent' +import { SurfaceCard } from '../shared/SurfaceCard' type RepoReadmeProps = { readme: NonNullable | undefined @@ -9,13 +10,11 @@ export function RepoReadme({ readme }: RepoReadmeProps) { if (!readme?.contents.trim()) return null return ( -
- - {readme.filename} - - + +

{readme.filename}

+ {readme.contents} -
+ ) } diff --git a/src/components/repo/RepoTabs.tsx b/src/components/repo/RepoTabs.tsx new file mode 100644 index 0000000..ffc3268 --- /dev/null +++ b/src/components/repo/RepoTabs.tsx @@ -0,0 +1,47 @@ +import type { Handle } from '@atcute/lexicons' +import { + IconBook2, + IconCircleDot, + IconGitPullRequest, + IconNotebook, + IconRoute, +} from '@tabler/icons-react' +import { Tabs } from '../shared/Tabs' +import type { RepoSection } from './repoSections' + +type RepoTabsProps = { + activeSection: RepoSection + handle: Handle + hasReadme: boolean + repoKey: string +} + +const REPO_TABS = [ + { label: 'Readme', section: 'readme' as const, Icon: IconBook2 }, + { label: 'Code', section: 'code' as const, Icon: IconNotebook }, + { label: 'Issues', section: 'issues' as const, Icon: IconCircleDot }, + { label: 'Pulls', section: 'pulls' as const, Icon: IconGitPullRequest }, + { label: 'Pipelines', section: 'pipelines' as const, Icon: IconRoute }, +] + +export function RepoTabs({ activeSection, handle, hasReadme, repoKey }: RepoTabsProps) { + const basePath = `/${handle}/${encodeURIComponent(repoKey)}` + const defaultSection = hasReadme ? 'readme' : 'code' + + return ( + hasReadme || tab.section !== 'readme').map((tab) => { + const Icon = tab.Icon + const href = tab.section === defaultSection ? basePath : `${basePath}?view=${tab.section}` + + return { + label: tab.label, + href, + isActive: tab.section === activeSection, + icon: