Primer¶
The primer pack imitates GitHub Primer — the Primer React components on the current Primer
Primitives, with the light default and dark default themes. Its tokens carry the Primer
functional variables (bgColor-default #ffffff / #0d1117, bgColor-muted #f6f8fa /
#151b23, fgColor-muted #59636e / #9198a1, borderColor-default #d1d9e0 / #3d444d,
fgColor-accent #0969da / #4493f8, the success / attention / severe / danger / done scales,
the green primary button #1f883d / #238636 and the coral UnderlineNav marker), the system
font stack at 14 px / 20 px, ui-monospace for code, 32 px medium controls (28 small, 40 large),
6 px control radius and 12 px overlay radius. Select it with import Primer (or import
PrimerReact, import GitHub).
Elements use the Primer React component names, with sub-components spelled without the dot
(ActionList.Item → ActionListItem): Button (variant: .default | .primary | .danger |
.invisible | .link, size: .small | .medium | .large, leadingVisual:, trailingAction:,
count:), IconButton, ButtonGroup, Counter, Label (.accent, .success, .attention,
.severe, .danger, .done, .sponsors …), StateLabel (status: .issueOpened | .issueClosed |
.pullOpened | .pullMerged | .pullClosed | .draft), IssueLabel, Token / AvatarToken,
Avatar / AvatarStack, Header, PageHeader (PageHeaderTitleArea, PageHeaderTitle,
PageHeaderActions, PageHeaderDescription, PageHeaderNavigation), UnderlineNav /
UnderlineNavItem, TabNav, SubNav, SegmentedControl / SegmentedControlButton, NavList
(NavListItem, NavListGroup), ActionList (ActionListItem, ActionListGroup,
ActionListDivider), ActionMenu / ActionMenuItem, SelectPanel, TreeView /
TreeViewItem, Timeline / TimelineItem, Flash, Banner, InlineMessage, Blankslate,
BorderBox / BoxRow, Dialog, ConfirmationDialog, Tooltip, BranchName, RelativeTime,
TextInput, Textarea, Select, Autocomplete, TextInputWithTokens, FormControl,
Checkbox, Radio, ToggleSwitch, Pagination, Breadcrumbs, SplitPageLayout,
PageLayout, DataTable, ProgressBar, Spinner, Heading, Text, Octicon and Kbd. Code
and diff views reuse the code role (CodeView, Snippet) plus diff rows (DiffFile,
DiffHunk, DiffLine, DiffNumber, DiffCode). Octicon names (git-branch, issue-opened,
git-pull-request, kebab-horizontal, file-directory-fill, repo …) map onto the built-in
icon set.
The custom components (RepoHeader, IssueRow, FileRow, Line, Hunk, CommentBlock,
SettingsSection) live in mockups/primer/github.mockitdown and are imported with
import "primer/github". All repositories and people are invented; the header mark is a neutral
glyph.
Sign in¶
A narrow centred form: the mark, a heading, a muted box with two TextInputs, a full-width
primary Button, and a second box with a link.
Source
import Primer
VStack(spacing: 16) {
Octicon("cube", size: 48)
Heading("Sign in to Forgehub", variant: .medium).fontWeight(.light)
VStack(alignment: .stretch, spacing: 16) {
TextInput("", label: "Username or email address", value: "mona-lin")
VStack(alignment: .stretch, spacing: 8) {
HStack {
Text("Password").fontWeight(.semibold)
Spacer()
Link("Forgot password?", size: .small)
}
TextInput("Password", type: .password, value: "correct-horse").state(.focused)
}
Button("Sign in", variant: .primary).frame(maxWidth: .infinity)
}
.padding(16)
.background(.secondary.opacity(0.06))
.cornerRadius(6)
.border(.secondary.opacity(0.25))
HStack(spacing: 4) {
Text("New to Forgehub?")
Link("Create an account")
}
.padding(16)
.frame(maxWidth: .infinity)
.cornerRadius(6)
.border(.secondary.opacity(0.25))
}
.frame(width: 308)Repository home¶
The code tab of a repository: the global Header with the repository UnderlineNav (RepoHeader),
the title row with Avatar, Label and Buttons with counters, the branch ActionMenuButton, a
TextInput with a Kbd hint, the file table as a BorderBox of FileRows and the About side
column with topic Tokens.
Issue list¶
The issues tab: a filter TextInput 1 next to Labels / Milestones as a SubNav and the
green New issue button, then a BorderBox whose header carries the open / closed toggle and
the filter ActionMenus 2 — the Sort menu is open. Each row is an IssueRow with
IssueLabels, an AvatarStack of assignees and a comment count 3; Pagination 4 closes
the page.
Source
import Primer
import "primer/github"
VStack(alignment: .stretch, spacing: 0) {
RepoHeader(tab: "Issues")
VStack(alignment: .stretch, spacing: 16) {
HStack(spacing: 8) {
TextInput("Search issues", leadingVisual: "search", value: "is:issue state:open label:bug")
.callout(1, "Filter query", alignment: .trailing, labelSide: .leading)
SubNav {
SubNavLink("Labels", leadingVisual: "tag")
SubNavLink("Milestones", leadingVisual: "milestone")
}
Button("New issue", variant: .primary)
}
BorderBox {
IssueRow(title: "Telemetry graph freezes after stage separation", number: 512, author: "ana-r",
when: "2 hours ago", labels: [("bug", "red"), ("telemetry", "blue")],
assignees: ["Ana Ruiz", "Ben Ito"], comments: 4)
IssueRow(title: "Support custom thrust curves from CSV", number: 509, author: "kai-w",
when: "yesterday", labels: [("enhancement", "teal"), ("good first issue", "purple")], comments: 12)
IssueRow(title: "Abort sequence ignores the second igniter", number: 503, author: "mona-lin",
when: "3 days ago", labels: [("bug", "red"), ("priority: high", "orange")],
assignees: ["Mona Lin"], comments: 7, selected: true)
IssueRow(title: "Docs: explain the staging timeline", number: 497, author: "sol-p",
when: "last week", labels: [("documentation", "blue")], assignees: ["Sol Park", "Ravi Kumar", "Kai West"])
IssueRow(title: "Wind model drifts at high altitude", number: 488, author: "ben-i",
when: "2 weeks ago", labels: [("physics", "yellow"), ("needs triage", "gray")], comments: 2)
IssueRow(title: "Flaky test: parachute deploy timing", number: 476, author: "ravi-k",
when: "3 weeks ago", labels: [("tests", "green")], assignees: ["Ravi Kumar"], comments: 1)
.callout(3, "Assignees and comments", alignment: .bottomTrailing, labelSide: .leading)
} header: {
HStack(spacing: 16) {
Checkbox()
Button("**24 Open**", leadingVisual: "issue-opened", variant: .invisible, size: .small)
Button("163 Closed", leadingVisual: "check", variant: .invisible, size: .small)
.foregroundStyle(.secondary)
Spacer()
HStack(spacing: 0) {
ActionMenu("Author", variant: .invisible, size: .small)
.callout(2, "Filter menus", alignment: .bottom)
ActionMenu("Label", variant: .invisible, size: .small)
ActionMenu("Assignee", variant: .invisible, size: .small)
ActionMenu("Sort", variant: .invisible, size: .small, open: true) {
Text("Sort by")
ActionMenuItem("Newest", checked: true)
ActionMenuItem("Oldest", checked: false)
ActionMenuItem("Most commented", checked: false)
ActionMenuItem("Recently updated", checked: false)
ActionMenuDivider()
ActionMenuItem("Best match", leadingVisual: "sparkle-fill")
}
}
}
}
HStack {
Spacer()
Pagination(pageCount: 5, currentPage: 1).callout(4, "Pages")
Spacer()
}
}
.padding(.horizontal, 32)
.padding(.vertical, 24)
}Pull request conversation¶
A PageHeader with the title, number, StateLabel and BranchNames, UnderlineNav tabs with
counters, then the conversation Timeline: CommentBlocks (an Avatar beside a
TimelineComment), commit and review events, and the merge box. The side column lists
reviewers, assignees and labels.
curve(preset:) helper. The presets are plain data, so the docs can render them.Closes #470.Files changed¶
The diff tab of a pull request: a TreeView of the changed files with the current file marked, a
SegmentedControl for unified / split, and DiffFiles whose rows are the custom Hunk and Line
components built on DiffHunk / DiffLine / DiffNumber / DiffCode. A pending file shows a
SkeletonText while it loads.
Source
import Primer
import "primer/github"
HStack(alignment: .top, spacing: 0) {
VStack(alignment: .stretch, spacing: 12) {
TextInput("Filter files…", leadingVisual: "filter", size: .small)
TreeView {
TreeViewItem("src", folder: true, expanded: true) {
TreeViewItem("engine", folder: true, expanded: true) {
TreeViewItem("presets.ts", leadingVisual: "file", detail: "+42").selected()
TreeViewItem("throttle.ts", leadingVisual: "file", detail: "+9 −3")
}
TreeViewItem("index.ts", leadingVisual: "file", detail: "+1")
}
TreeViewItem("docs", folder: true, expanded: true) {
TreeViewItem("presets.md", leadingVisual: "file", detail: "+28")
}
TreeViewItem("tests", folder: true, hasChildren: true, expanded: false)
}
}
.padding(16)
.frame(width: 280)
Divider()
VStack(alignment: .stretch, spacing: 16) {
HStack(spacing: 8) {
ActionMenuButton("All commits", size: .small)
Text("**5 files** changed · ").foregroundStyle(.secondary)
Text("+80").foregroundStyle(.green).fontWeight(.semibold)
Text("−3").foregroundStyle(.red).fontWeight(.semibold)
Spacer()
SegmentedControl {
SegmentedControlButton("Unified").selected()
SegmentedControlButton("Split")
}
.size(.small)
Button("Review changes", variant: .primary, size: .small, trailingAction: "triangle-down")
}
DiffFile("src/engine/throttle.ts", subtitle: "+9 −3") {
Hunk(text: "@@ -12,9 +12,15 @@ export function throttle(level: number) {")
Line(old: "12", new: "12", code: " const clamped = Math.min(Math.max(level, 0), 1);")
Line(kind: "deletion", old: "13", code: " return curve(clamped);")
Line(kind: "addition", new: "13", code: " const preset = presets[options.preset ?? \"standard\"];")
Line(kind: "addition", new: "14", code: " const capped = Math.min(clamped, preset.maxBurn);")
Line(kind: "addition", new: "15", code: " return curve(capped, preset.shape);")
Line(old: "14", new: "16", code: "}")
Line(old: "15", new: "17", code: "")
Line(kind: "deletion", old: "16", code: "export const DEFAULT_CURVE = \"linear\";")
Line(kind: "addition", new: "18", code: "export const DEFAULT_PRESET = \"standard\";")
} action: {
Checkbox("Viewed")
IconButton("kebab-horizontal", variant: .invisible, size: .small)
}
DiffFile("src/engine/presets.ts", subtitle: "+42") {
Hunk(text: "@@ -0,0 +1,42 @@")
Line(kind: "addition", new: "1", code: "export const presets = {")
Line(kind: "addition", new: "2", code: " gentle: { maxBurn: 0.6, shape: \"ease-in\" },")
Line(kind: "addition", new: "3", code: " standard: { maxBurn: 0.8, shape: \"linear\" },")
Line(kind: "addition", new: "4", code: " sport: { maxBurn: 0.9, shape: \"ease-out\" },")
} action: {
Checkbox("Viewed", checked: true)
IconButton("kebab-horizontal", variant: .invisible, size: .small)
}
DiffFile("docs/presets.md", subtitle: "+28") {
SkeletonText(lines: 3).padding(16)
}
}
.padding(16)
.frame(maxWidth: .infinity)
}File browser¶
A blob view: the repository file TreeView beside the file, Breadcrumbs over the code, the
branch picker SelectPanel open with its filter field and branch list, the latest commit in a
BorderBox and the file itself as a CodeView with a SegmentedControl (Code / Blame) and the
highlighted lines in the attention colour.
Repository settings¶
A SplitPageLayout: a NavList with groups, a leading visual on every item and the current page
marked, beside the General settings — FormControls with captions, a Select, Checkboxes with
descriptions, ToggleSwitches, a RadioGroup, an InlineMessage and the Danger Zone as a
BorderBox with danger Buttons.
Source
import Primer
import "primer/github"
SplitPageLayout {
SplitPageLayoutPane {
NavList {
NavListItem("General", leadingVisual: "gear").selected()
NavListGroup("Access") {
NavListItem("Collaborators and teams", leadingVisual: "people")
NavListItem("Moderation options", leadingVisual: "report")
}
NavListGroup("Code and automation") {
NavListItem("Branches", leadingVisual: "git-branch")
NavListItem("Rules", leadingVisual: "law", trailingVisual: "3")
NavListItem("Actions", leadingVisual: "play") {
NavListItem("General")
NavListItem("Runners")
}
NavListItem("Webhooks", leadingVisual: "webhook")
NavListItem("Pages", leadingVisual: "browser")
}
NavListGroup("Security") {
NavListItem("Secrets and variables", leadingVisual: "key")
NavListItem("Deploy keys", leadingVisual: "key")
}
}
}
SplitPageLayoutContent {
Heading("General", variant: .medium).fontWeight(.regular)
FormControl {
FormControlLabel("Repository name")
HStack(spacing: 8) {
TextInput("", value: "rocket").frame(width: 260)
Button("Rename")
}
}
VStack(alignment: .leading, spacing: 0) {
Checkbox("Template repository", checked: false)
FormControlCaption("Template repositories let users generate new repositories with the same directory structure and files.")
.padding(.leading, 24)
}
FormControl {
FormControlLabel("Default branch")
HStack(spacing: 8) {
BranchName("main")
IconButton("pencil", size: .small)
IconButton("arrow-switch", size: .small)
}
FormControlCaption("The default branch is considered the base branch in your repository.")
}
SettingsSection(title: "Features") {
ToggleSwitch("Wikis", checked: true, description: "Wikis host documentation for your repository.")
ToggleSwitch("Issues", checked: true, description: "Issues integrate lightweight task tracking into your repository.")
ToggleSwitch("Discussions", checked: false, description: "Discussions is the space for your community to have conversations.")
}
SettingsSection(title: "Pull Requests") {
RadioGroup(label: "When merging pull requests", selection: "Allow squash merging") {
Radio("Allow merge commits")
Radio("Allow squash merging")
Radio("Allow rebase merging")
}
Select(label: "Default commit message", selection: "Pull request title and description")
InlineMessage("Squash merging is the only method enabled for 2 protected branches.", variant: .warning)
}
SettingsSection(title: "Danger Zone") {
BorderBox {
BoxRow {
VStack(alignment: .leading, spacing: 0) {
Text("Change repository visibility").fontWeight(.semibold)
Text("This repository is currently public.")
}
Spacer()
Button("Change visibility", variant: .danger, size: .small)
}
BoxRow {
VStack(alignment: .leading, spacing: 0) {
Text("Archive this repository").fontWeight(.semibold)
Text("Mark this repository archived and read-only.")
}
Spacer()
Button("Archive this repository", variant: .danger, size: .small)
}
BoxRow {
VStack(alignment: .leading, spacing: 0) {
Text("Delete this repository").fontWeight(.semibold)
Text("Once you delete a repository, there is no going back.")
}
Spacer()
Button("Delete this repository", variant: .danger, size: .small)
}
}
.variant(.danger)
}
}
}Labels and a dialog¶
The labels page — SubNav with Labels selected, a search field, a BorderBox of label rows
with an open row ActionMenu — and an open Dialog creating a label: TextInputs, a colour
TextInput with a leading swatch, a Tooltip on the refresh button, and the footer buttons. A
ConfirmationDialog would use the same layout with buttons:.
Insights¶
A PageLayout with a NavList pane and the Pulse page: Stat tiles, a bar chart of commits per
week and a line chart of traffic in the Primer data-visualisation colours, Labels, and a
Blankslate with a Banner for a feature that is not set up yet.