Frontend Style Guide¶
A design system page at /styleguide renders every shared primitive, colour role and layout pattern in the browser. Check it for an existing primitive before building a new one.
flowchart LR
tokens["Foundations<br/>colour roles, type, spacing"] --> elements["Elements<br/>icons, badges, banners"]
elements --> components["Components<br/>buttons, fields, tables"]
components --> patterns["Patterns<br/>page shell, row lists, settings"]
The Page¶
- Lazy-loaded at
/styleguide, deliberately linked from nowhere, without an auth guard. No production data on the page. - Source:
frontend/src/app/features/styleguide/, one component per section page.
| Section | Contents |
|---|---|
| Overview | The rules below |
| Foundations | Colour roles, type scale, spacing, border radius |
| Elements | Icons, logo, badges, copy fields, read-only rows, message banners, tables, feedback, evaluation status, star button, status icon, charts, toasts |
| Components | Buttons, form field, name with availability check, selection, panel switcher, table, overlays |
| Patterns | Page shell, row list, index cards, card grid, settings, sections with an action, settings destinations, danger zone |
Rules¶
- Surround store paths, hashes, keys, IDs, and URLs with
gr-copy-field. A plain code span won't do. The multilinegr-copy-fieldcan grow to fit the content. - Take all colours from semantic roles. Hex values belong only in the palette, and components read roles rather than palette tokens.
- Put new shared classes in the design system. Component stylesheets take none.
- Build content layouts from
gr-row-listorgr-card-grid. Avoid entity-specific names. - Keep every element readable in both themes. Never hard-code black or white in a component.
- Color text on tinted status backgrounds with the matching
--gr-status-*-textrole. Never use plain status roles. Fix contrast violations intokens.ts, not on the page side.contrast.spec.tsmust keep all text roles at 4.5:1 on the base, raised, hover, and sunken surfaces in both themes. Underline links in body text. - Never write color literals (hex,
rgb(),hsl(), or color names) or palette variables outsidetokens.ts. Both makepnpm colors:checkfail. The chart can take role names such as--gr-chart-cyanor--gr-graph-successin[colors]and SVG drawn in code can setstyle.fillorstyle.stroketovar(--role), so both follow the theme. - Use
buildPhase,evaluationPhase, orexecJobPhase. Then usegr-status-badge,gr-status-iconandPHASE_SEVERITYforgr-badgeandPHASE_COLORfor graphics.PHASE_COLORis the only map from phase to color:gr-status-iconand the tint ofgr-status-badgeread it through the--phase-colorcustom property. Don't add per-phase color rules to component styles; read--phase-colorinstead to give each phase its own status color. Queued, running, waiting, failed and canceled jobs show the same color on every page. - Pass the waiting_reason of an evaluation to evaluationPhase and gr-eval-status-badge. Only queued or running evaluations with a waiting reason show the waiting phase and the "Waiting" label. Building evaluations with a wait for exec jobs show the same waiting phase and label. Without a waiting reason, evaluations keep their own phase. Give the queued badge a dashed outline and a hollow center. Give the aborted badge a solid fill. Both badges never look the same.
- Use severity colors on
gr-badgeonly for a status or state. Badges for category names, such as trigger type or action type, stay neutral. Green, amber and red then always mean status. Neutral badges keep the case of their text, because they often show user values such as label, role or worker names. Status badges with a severity show their text in uppercase. - Render every page inside the single
<main id="main-content">of the app shell, never add a second<main>. Give each page exactly oneh1, hidden with.sr-onlywhen the layout shows no title, and never skip a heading level. Card, chart and empty-state titles areh2. - Give every icon-only button or link a name through
labeloraria-label, and name the target ("Remove bob", not "Remove").pnpm button-names:checkfails on an unnamed icon-only button. Agr-copy-fieldorgr-selectinside agr-form-fieldtakes the field label. The outer one can passlabelto the copy field andariaLabelto the select. - Use
@shared/ui'sentityKindToIconNamefor project, task, cache, and team icons in every place with the entity on screen (rows, cards, empty states, invite lists). Don't enter Material icon names for those entities in templates. - Use
gr-entity-namefrom@shared/uiin lists, rows, cards, and requests to show a project, task, cache, or team. Render the display name. Render the slug in muted monospace text when the slug and display name differ. Two items with the same display name stay distinct. Usegr-nav-cardto project the entity withslot="title". Set[title]toformatEntityLabel(item)for the tooltip. UseformatEntityLabel()for plain text such as confirmation targets, aria labels, and toasts (for example, "Web Shop (shop)"). Pickers build options withentityToPickerOption()and filter withdoesSearchQueryMatchEntityNameOrSlug(). Users can find an item by either name. Detail pages show the slug for the CLI (project,project/task,cache,team) as inlinegr-copy-fieldin the header. Breadcrumbs and page titles keep the display name. - Pass the display name of the starred item to
gr-star-button(starredItemDisplayName). Use that name as the button label ("Star Web Shop"). Restore the button to its original state after a failed star or unstar action. Then show a failure toast with that name. - User menu commands close the header drawer on narrow screens before they open a dialog or navigate. Dialogs never show behind the drawer.
- Add
grScrollRegionto every element that scrolls on its own, so keyboard users can focus and scroll it while its content overflows.gr-tableand the log viewer already do this. - Table rows that open a page on click need a real link (
routerLink) in the main cell too. Keyboard users can press Tab to reach the link and open the link in a new tab. Stop the click on that link from reaching the row handler. Use a button for rows that open a dialog. Don't rely on a click handler ontrordivalone. - Sidebar rows with their own menu button (build rows in the evaluation log, the Log row of the exec job page) select the row with a transparent
.sidebar-row-linkbutton stretched over the row, fromshared/log/log-sidebar.scss. The.sidebar-kebabmenu button sits beside it, so both can be reached with Tab and no control is nested inside another. Open the same menu on right-click of the row. - Make the full page fit at 375px and 768px widths without horizontal scroll. Set
min-width: 0on flex and grid children. Allow the header row and action row to wrap. Wide tables scroll insidegr-table. Bind[grDrawer]and(grDrawerClose)on all side panels that slide over the page and overlap content on narrow screens. Escape can close the panel from anywhere. Move focus into the panel on open. Return focus to the button that opened the panel on close. A menu inside the panel can already handle Escape (the event hasdefaultPreventedset). That Escape can close only the menu and leave the panel open. The panel of the header menu is a modal dialog while open on narrow screens (role="dialog",aria-modal). - Keep text sizes within one step of body size: 16px for interactive text, 14px for secondary text, 12px for badges only.
- Report the result of every write through
NotifyService(success,failure), which shows agr-toast. New results replace the previous toast. Later successes leave no old failure toast beside them. A failed write submitted from an opengr-dialogkeeps the dialog open and shows the reason through its[error]input. Take the reason fromapiErrorMessage(error, fallback), never from themessageof an arbitrary error. Toasts appear at the top right. They sit directly below the header with the page title while that header is visible. Otherwise they sit directly below the app header. Toasts don't cover header actions. They span the full width on smartphones, so they don't cover the save row, the dialog footer, or the fixed footer. - Use
ApiService.getBlobandsaveResponsefrom@shared/downloadto download small files such as logs and SBOM files through the API. Report failures throughNotifyService.failure. Failed requests show raw JSON outside the app. Don't link these API URLs for download in[href]. Artifacts from a build can reach several gigabytes. Link the artifacts directly. Add anaria-labelwith the file name and thedownloadattribute. The download manager of the browser can then show progress and resume the download. Keep direct links for HTML artifacts that open in a new tab. - Bind
[busy]togr-dialogwhile a request is active. Bind[loading]to the button that sent the request. The dialog can't close and a second request can't start. Set[closable]="false"on a dialog that can display a secret once, and show the secret ingr-copy-fieldso it has a copy button. gr-dialogputs focus on the first form field when it opens. A dialog without fields focuses the first footer button, which is the safe action such as Cancel, never the close button. Mark a different start element withcdkFocusInitial.gr-dialogand[grDrawer]keep Tab inside while open and return focus to the opening element on every close.- After each client navigation except the first page load, the app moves focus to
#main-content, unless focus already sits inside it (page tabs, a field the page focused). Pages don't need their own focus code for this. - Remove the row from the list after deletion without a reload. Move focus to the first button in the replacement row. Move focus to the page heading with no next row. Code can focus the
h1ingr-page-layoutbecause of thetabindex="-1"on that element. - Set
confirmDiscardtogr-dialogwhile unsaved edits exist in the form. Escape, the backdrop and the close button ask "Discard changes?" inside the dialog rather than close the dialog. Connect the Cancel button to the dialog'sclose()through a template reference. Cancel can ask too. Leave the input off for dialogs without edits. Track edits indialogFormChangesSinceOpenof@shared/forms. Callmark()at dialog open, and bind[confirmDiscard]tochanged(). - Use
HtmlOverflowHiddenScrollStrategyinpackages/ui/src/ui/overlayto lock page scroll ingr-dialog, not the block strategy in@angular/cdk/overlay. Use the same strategy for any new overlay with a scroll lock. The block strategy can scroll back to the original position on close. That strategy can also cancel the scroll back to top after dialog actions open another page. Focus can move to#main-contenton close when the original element that opened the dialog is gone. - Option groups such as
gr-select-buttonandgr-tab-switchkeep only the selected option in the tab order. The arrow keys, Home, and End move between options throughgetNextOptionIndexForKey()frompackages/ui/src/ui/next-option-index-for-key.ts. Use that helper for new option groups. - Place
app-settings-access-state-badgeof@shared/accessin theafter-titleslot ofgr-page-layouton all project, cache, task, and team pages with the server configuration settings. Badges for settings that come from the server configuration show 'Managed' with a lock icon to every visitor. The badge tooltip gives the reason. The cache badge can also tell users with edit permission that the Deactivate button can still operate. SetshowReadOnlyNoteon the badge on settings pages (project, task, cache, team) as well. Read-only users then see a 'Read-only' badge. Pass the permission of the form to thepermissioninput of the badge. The tooltip can then show the lowest built-in role that can edit. Don't disable actions that are not available. Hide them instead. Use*appWritableto render Create, Add, Delete, Unsubscribe and Edit buttons only for viewers with permission on unmanaged settings. Use@if (!row.managed)to control buttons on a single managed row. Form fields stay visible but disabled so users can read the value. Use[appManagedDisable]to set the reason as their tooltip. A single managed row on a page without the 'Managed' badge showsapp-server-configuration-managed-lock-button. Never show a visible reason text on the row. Put the reason only in the tooltip for a control disabled for another reason. UsedisabledReasononbutton[grButton]and on greyed-outgr-menuitems. Actions that the backend can perform on managed entities stay visible and enabled. UsecanEditalone to control them. Examples include Activate/Deactivate of caches and upstreams and Test of upstreams. These pages show the save row and Danger Zone only withAccessService.isWritable(access)set to true. Setgr-form-fieldto hide the required asterisk on disabled or read-only controls. - Confirm beforehand through
ConfirmServicefrom@shared/confirmon every deletion, removal, cancellation, rejection, abort, drain, and secret rotation. State the exact target and say the outcome. The dialog can run the action itself, remain locked during the action, and show failures inside. Never use the native browserconfirm(). SetisIrreversibleon irreversible actions instead of writing a custom "cannot be undone" sentence. The dialog can then close with a single fixed message. Callers get the result fromConfirmServiceonly on dialog close, so move it intosubscribeafter deletion. - Pass all metric series to
gr-metric-chart, also an empty one. A chart whose series hold no points says "No data" over the plot, so an empty chart never looks like a broken one.ApiServicerejects a response without a body (except 204 No Content) as anApiError, so a page shows its error state instead of crashing onundefined. - A failed source is not an empty source. On a page with several requests, a part whose request failed shows "Couldn't load" (stat card value, table empty row,
gr-metric-chart [error]). Empty texts such as "No data" or "No connected workers." appear only for data that loaded and is empty. Start such signals atnulland keep themnullon failure. - Pass missing values to
gr-metric-chartasnull, never as 0. Never let a zero bar mean "not reported". Default series colors don't include--gr-graph-danger. Show red only when[colors]can set red for failures. - Set all time-based charts on the Job Board to one shared axis. Use
metricPointsTo24HourChartSeries()fromfeatures/board/hourly-metric-points-to-24-hour-slots.tsfor that axis. Choose 24 hourly buckets. The last bucket is the current hour that is still in progress. This shows activity immediately. Show 0 for counts and a gap (null) for gauges in an hour with no rows. Lines never connect two timestamps across an empty time bucket. - Include the
hide-cell-below-small-breakpointmixin fromfeatures/board/_phone-width-hide-cells.scssin tables on the Job Board that don't fit in 375px. Add the classjob-board-table-cell-hidden-on-phoneto the secondary columns (rank, worker, method) in boththandtd. The project, name and main value columns stay visible at all times. A 375px phone can display this table without horizontal scroll. - Set
--gr-graph-successfor completed builds and connected workers. Set--gr-graph-warningfor draining workers in Job Board charts. Use--gr-chart-cyan,--gr-chart-purpleor--gr-chart-tealfor a series without status (jobs per worker or build time per project, for example). Never use green or orange. Green and amber then always mean status. Usegr-live-statusfor one status badge (LIVE or RECONNECTING). Show connection state througharia-label. - Two line series in
gr-metric-chartcan take the same values (for example, build closure size and runtime closure size). SetisLineDashedon the second series in that case. Otherwise, the second line can hide the first line, and the chart shows only one series. - Build all ECharts options from
resolveChartTheme(). It setsreducedMotionon its own from the system setting (prefers-reduced-motion) and charts then skip animation.gr-metric-chartdraws within 300 ms and can pin the first and last time labels of a line chart to the plot edges, so labels never get cut off. Charts withyAxisMaxshow evenly spaced ticks up to that maximum. - Control access to all write controls through the permissions that the endpoint can check, not through role names. Project, task, and cache responses list the caller's own
permissions. Build the gate withaccessTo(resource, ...permissions)(orinjectTaskAccessTo/injectCacheAccessTo). Pass the gate to*appWritablefor buttons and to[appManagedDisable]for form fields.[appManagedDisable]can also receive a busy flag as[disabled]in the same field. Combine both. Use[disabledReason]to bind a reason for the block on a single button (the last administrator). A button can remain focusable and show the reason as a tooltip. - Mark
gr-menuitems that can't run withdisabledReason, notdisabled. Menus always show the reason below items, so layout doesn't change between pointerdown and click. Arrow keys and initial focus skip that item. Test pointer events in the actual event order (pointerdown, mousedown, focus change, mouseup, click). - A role can grant only permissions available to the granting user (for example, API key permissions). In that case, pass the permissions available to that user to the
selectablePermissionIdsinput ofapp-permission-picker. The picker can keep the other permissions visible and disable them. Don't filter the list on the page or check boxes again. The picker shows three groups labelled "Read", "Write" and "Admin", sorted by the lowest built-in role that grants each permission. Custom role forms setviewPermissionIsRequired, so the view permission stays ticked and locked; the server adds it to every custom role. - Show a refused load through gr-load-state: pass the 403 or 404 error as it is, and the component shows one "No access" or "Not found or access denied" state with a lock icon and no Try Again button. A page that knows the role can't read a list passes
createMissingPermissionLoadStateError(owner, isViewerMember)from@shared/accessand sends no request. PassisViewerProjectMember(project)orisViewerCacheMember(cache)as the second argument. Pass the permission for the page as the third argument. This text can display the name of the lowest built-in role with that permission. An example is "Only the members with Write or Admin on this project can view this." Members see the admin text if that permission is absent. Visitors outside the project or outside the cache see the member-only text. Texts for denied access show the role name, not the permission. Pages where all sections need membership show one "No access" state for the whole page, not for each section. Never add a separate retryable flag or a page-specific no-access title. - Only read requests during router navigation can replace the page with the error page or show the throttle notice (
PageRenderTrackerincore/interceptors). Read requests before the first render after navigation can do the same. Later read requests, such as polling, retries, load more and search, show the failure inline on the page. - Mark reads that fill one section of a page with its own inline error state through
asSectionRequest()of@core/interceptors/request-context. A busy server (429, 502, 503, 504) then leaves the page in place and the section shows the error, as the dashboard does. Reads that render the whole page stay unmarked and open the error page. - Build a page from sections that each load their own data. Show one page-level
gr-message-bannerand one Retry on any section failure. Hide the failed sections. Make Retry reload only the failed sections. Don't show one error banner per section. - Route guards and resolvers load the entity named in the URL (project, task, cache, team, evaluation, build, job, worker). They pass a refusal from
@core/routing/access-deniedthroughdenyOnRefusal. It treats 400 (a malformed id), 403 and 404 the same way. Signed-in users see the shared "Not Found or Access Denied" page instead. Anonymous visitors go to the sign-in page with the requested address set innext. Sign-in can grant access. Give the denied target anameonly for entities with a readable name; leave it out for ids, so the page says "Exec job not found." instead of showing a UUID. Pass the owning project todenyOnRefusalornotFoundPageRedirect, so the back link leads to that project when the user can read it and to the fallback list otherwise. denyOnRefusalcan check with the server that the session is still valid before the access denied page can appear for a signed-in user. Expired sessions go to the sign-in page with the reason visible and the address innext. The router can never send that session to the access denied page. The 403 page can show "Admin Only" only for addresses under/admin. That page can show "No Access" for every other address. Superusers don't see the Switch Account button.- Place the gr-load-state for the page inside the gr-page-layout, never outside that layout. The breadcrumb trail and title remain visible during page load and after a failure.
- Teams have roles instead of permission lists. Team routes resolve the team once with
teamAccessResolver, and pages read it withinjectTeam()instead of fetching it again. Gate admin-only team controls and requests withcanManageTeam(team, user), which also lets superusers in. A page whose content only members or admins may read showscreateNoAccessLoadStateError(owner, group)and sends no request. - Endpoints for project members only cover roles, workers, SSH keys, cache subscriptions, SOPS recipients and task triggers. These endpoints cover actions, flake input overrides, task repositories, Git host connections and cache teams too. These endpoints all return 404 to everyone outside the project or cache, including superusers. Use
requestIfProjectMember(projectOrTask, request)to wrap these requests andisViewerProjectMember(projectOrTask)to hide links to these pages. UserequestIfCacheMember(cache, request, permission?)to wrap cache requests. UseisViewerCacheMember(cache)to hide links to these cache pages. Requests from outside the project or cache fail immediately with the matching access denied error and send nothing. Requests without the given cache permission follow the same rule. - Signed-in users who change their own role or remove themselves from a project, cache, or team reload the resolved resource into the page's linkedSignal. Access gates then recompute. Send users without access to the project, cache, or team list page. Show pending invitations only to users who can manage members.
- Bind a save-on-change select to the pending value during the request. At all other times bind it to the saved value. Clear the pending value after a failed request. The select can show the saved value again. Write the new value into the list after a successful request. Don't reload the list.
- Show the role select in a member row only to users who can manage members (
*appWritable). Other users see the role name as a neutralgr-badge, same as on the page for Team Members. They don't see an empty select or a disabled select. Team roles arrive in lowercase (admin,member). Pass them through theteamRoleDisplayLabelsmap from@shared/accessto display them. - Use
@shared/accessfrombuildMemberSoleAdminDisabledReasonTextForUsername(kind, adminUsernames)to block removal or demotion of the only Admin of a project, cache or team. Attach the reason to the role select ([disabled]+[grTooltip]) and the Remove button ([disabledReason]). - Sort roles with
compareRoleNamesByBuiltInAccessThenName. from@shared/access. Built-in View, Write and Admin come first, from lowest to highest access. Custom roles follow by name. The role selector and dialog preselect the first role. New member and team grants start at the lowest access. Team member options list Member before Admin. Role rows display the member count fromcountMembersByRoleName(members). Keep delete disabled for a member with that role. Use tooltip[grTooltip]for the reason. Server-side checks reject that delete. - The Remove member and Revoke invitation dialogs show the person's name at
formatMemberNameForConfirmDialog(displayName, username)from@shared/access. One example is "Carol Outsider (carol)". The "Revoke invitation" dialog can read the sentence that states what happens if the user confirms and the failure text from@shared/access/pending-invitation-revoke-dialog-texts. - Save member role changes on project, cache, and team pages from
@shared/accessthroughinjectSaveMemberRoleChangeWithOwnRoleConfirmation(). Ask for confirmation when a signed-in user lowers their own role (withnewRoleLacksCurrentRolePermission(roles, current, next)for project and cache roles). Save all other changes at once. The member deletion dialog gets text fromgetMemberRemovalConsequenceSentence(place, username, signedInUser), Use the second person for signed-in users. - Save project and cache settings from
@shared/accessthroughinjectSaveSettingsWithPrivateToPublicConfirmation(). Saves from private to public open a dialog. The dialog fields are target name, Save access details. Other saves run right away. - Show the
gr-project-readiness-cardofshared/ui/project-readinesson the project page, the empty project state, and step 1 of the repository connection wizard. The card can list rows for Workers, Cache, and Git access fromGET /projects/{p}/readiness. Each row can offer only the fixes that viewer permissions allow. Viewers see rows without buttons. The row for Git access can link each failed task to the Repository page of that task (links.taskPage(project, task, 'repository')). Tasks select a connection to a Git host on that page. The waiting banner can reuse the same rows for waiting reasonsno_cache,workers, andeval_workers. - Show a count from
PendingUserDecisionsService("N requests need a decision") in a requests banner on the dashboard and link the banner to the Requests page. Invitations fromGET /user/requests, subscription requests for the cache and grant requests for teams make up the count. Show the same count in the header badge. Renderapp-pending-invitations-bannerfrom@shared/accessat the top of the/projects,/teamsand/cacheslists. List pages can passkind(project,team,cache) to count only invitations for that list. A list can show a dedicated empty state when empty, even when public items sit next to the list. - Show the Settings button only for roles that can change settings or for roles that can open the Members page. Use
canOpenProjectSettings(project)withcanOpenProjectMembersPage(project, user),canOpenCacheMembersPage(cache, user)andcanOpenTaskSettings(task)of@shared/accessin every header that links to the settings page. Hide links to pages that show only 'No access' for that role. Keep links to pages that the role can view. - Show scheduler internals only to superusers. Those internals include the score, score breakdown, workers, job and instance context, and the Scheduler tab. The server can leave those fields out of the response for other users. The template must branch on that response field, not on role. Workers whose name the server does not return get the label "Not shared with this account" and no link. The viewer cannot view the project in that case. Never show the worker as a raw UUID.
- Board rows display the project name and task name from
features/board/project-task-links.component.tsthroughapp-board-project-task-links. Show the display name. Link both names. Show a dash if the server doesn't return a project name. Long names truncate to 2 lines. Tooltips show the full name. Use this row in the Assigned, Pending and High Cost rankings. Board lists with more than 50 rows usegr-load-moreto show 50 rows at a time. - Print every scheduler score with one decimal through
schedulerScoreDecimalPipeDigitsFormatfromfeatures/board/scoring-rule-label.tsand call the bar of a rule's part of the score "Share" on every page. - Validate input on the client with
fieldChecksin@shared/forms. Usegr-form-fieldto show messages below the field before the request can leave the client. Track changes on the settings page withunsavedChanges()from@shared/forms. Keep Save disabled when there are no changes. RegisterunsavedChangesGuardon the route and ask for confirmation before leaving with edits. The guard lets the page go without asking once the session has ended, because the edits can't be saved anymore. - Use
warninginput ofgr-form-fieldto display checks that don't block saving, such as a flake URL without a commit. Warnings and errors show below the field. Errors replace warnings. - Field hint:
gr-form-fieldcan showhintas a help icon after the label and can show the hint as a tooltip. Content projected into[slot=hint]can remain visible below the field. Use[slot=hint]only for live values like “Instance limit: 30”. - One help icon per label. A label can have a documentation link too. Put the hint in
gr-label-helpasexplanationText. Hover or focus can show the hint. A click can open the documentation. - Section descriptions appear as a help icon after the heading. Remove descriptions that only repeat the title.
- Page subtitle: keep only subtitles that carry state, such as counts or slug. Remove subtitles that repeat the title or describe the page.
- Empty state: title and action button. Keep the message only for an empty state without an action button. State the conditions for item display in the message.
- Always show validation errors, warnings, results in danger zones and a status row that has one line in an empty log pane.
gr-dialogcan display[error]above the footer and outside the scrolling content. A failed write can leave the result next to the button that the user pressed.- When the server refuses a form field (for example a 422 about the URL), show its message under that field through
gr-form-field, not in the dialog[error]. Keep the message only while the field holds the refused value, so editing the field clears it. Other refusals stay in[error]. - List rows show up to three common actions as buttons. Webhook rows label these buttons "Test", "Deliveries", and "Edit". Rare destructive actions move to a single
gr-menubehind an icon-onlymore_vertbutton with name "Actions for". Examples include secret rotation, disabling, and deletion. Bind [loading]to that button while a menu action is active. - Bind
(grSubmit)instead of(click)on the submit button of everygr-dialogandgr-settings-sectionform. It blocks the submit while agr-form-fieldin the same section shows an error. Scroll the first field with an error and its error message into view on each click. Put focus on that field. Errors that show only after submit follow the same rule. An error can stay visible and the button can still look enabled. Clicks then lead to the next problem, not to a greyed-out button for no reason. CallinjectRevealFirstInvalid()from@shared/formsonly on submit paths without that button, such as Enter in a field. Place the save result directly aboveSaveon long settings pages. Scroll the result into view. - Show rejections from the server under the field, not in a toast or banner. Keep the error code from the server in
ApiError.code. UseapiErrorCodeToFormFieldNamefromcore/services/account-form-api-checksto mapusername_already_in_useandemail_address_already_in_useto form fields. A dialog can mapalready_existsto the name field. CallinjectRevealFirstInvalid()on a rejection to scroll to that field. Keep the message visible until the first edit of that field. UsecheckUsernameAvailability()from the same file to check a username at sign-up and during input on the profile page. - A stored value can differ from the display text (for example, a team name behind a display name). Pass
{ label, value }suggestions togr-autocompletein that case. The field can show a label and write the value. Users open the list by typing, clicking, or pressing ArrowDown. They select with the arrow keys and Enter. Escape can close the list and leave the surrounding dialog open. Set agr-form-fieldlabel or placeholder on the field. That text can name the list. - Build every link in the app with
linksfrom@shared/routing. Don't write paths as arrays or strings. The builder output is aUrlTreewith query params. Bind that torouterLinkonly, withoutqueryParams. Navigate throughrouter.navigateByUrl. Pages that tasks or evaluations reach keep that context in the link. Back paths then return to the same evaluation and build. All pages show agr-breadcrumbtrail back to the parent, either throughgr-page-layoutor alone. Sibling pages such as user settings usegr-link-tabsfor links and show tabs instead of a breadcrumb. - Sign-in links and sign-up links put the current page into the
nextquery parameter. Links between the sign-in page and sign-up page keep that parameter. Links from registration to sign-in do the same. The page can read the parameter withreadInAppNextPathFromRouteSnapshot()from@shared/routing. This function can return null for addresses outside the app. Sign-in doesn't redirect to another site. - Link each breadcrumb only to pages that the user can open. Leave the breadcrumb as plain text when the user cannot open a page (task settings when the user cannot access settings).
- Pages of an evaluation share one breadcrumb (Project > Task > Evaluation). The pages are log, summary, dependency graph of the build, artifacts, and closures. Mark the evaluation as the current page on the log page. Build pages without
taskorevalin the URL fill both from the build loaded throughBreadcrumbsService.buildPage. - Pages save a new display name for a project, task, cache, or team. They then call the corresponding
remember*method onBreadcrumbsService. The breadcrumbs and the title of the browser tab both read that name, so neither can show the old name. - Link to the evaluation log with
links.evaluationLog.buildonly selects a build and never narrows the build list, so a reload or a link from the summary, graph or board shows every build. Passpackageonly to open one package with its dependencies (the task page package rows do this). While the list is narrowed, the sidebar names the package above the list and offers a button that lists every build again. Never narrow a list without saying so on the page. - gr-log-viewer reads the #L
line link from the URL itself and jumps to that line each time it changes, also on a page that is already open. Pages don't parse the fragment. A page that rewrites its query parameters before its first log shows sets preserveFragment, so the line link survives. - Render the header row of the log itself in the log viewer (
gr-log-viewer). Pass the title from the page as an element with thelogTitleattribute. Add a line count and a search button to the viewer. Search must stay reachable without Ctrl+F and on touch screens. - Show a waiting or stuck state through gr-waiting-notice, never as bare text. Its mapping, explainWaiting in @shared/evaluation, gives each reason a title, a detail and either an action (a link or Run) or a hint whom to ask, chosen by the viewer's permission. Add a new reason there, not on a page.
- When several items wait at once, render one gr-waiting-notice per item and pass its name and link through subjectLabel and subjectLink, never one notice for the first item.
- Use
buildDurationTextForEvaluation()for package build time andbuildStatusToShowInEvaluation()of@shared/evaluationfor build status. Both values take an evaluation as an argument. Label a build that an earlier evaluation ran "reused". A build that a newer evaluation continued can show the label Aborted at the end of this evaluation, with the timer stopped. UseabortedWithoutBuildsTitle()as the title for an Aborted evaluation without a build. Show a short reason for the wait on the same line withwaitingReasonText(). Logs, the task page, and the list of exec jobs all use the same wording. - Count builds in
buildTally(). Write the count line togetBuildCountTextPieces()in@shared/evaluationas “N of M built · F failed · D skipped · A aborted”. Show one total only. Don't show a second total. Pass the evaluation status so completed evaluations render unfinished builds as aborted. Task pages, logs and summaries use these terms. UsebuildOutcomeLabel()to name DependencyFailed “Skipped: Dependency failure” everywhere. - Use
gr-live-statuson every page that receives socket updates to show connection state. On task pages, show the badge only during socket reconnect. A connected badge there can look like task status. Build theonLiveSocketConnectedChangecallback ofLiveService.connectwithcreateResyncOnLiveSocketReconnectCallback(resync, onConnectedChange)from@core/services/live.service. The callback can reload page data on each reconnect and feed data to the badge throughonConnectedChange. These reloads leave no stale counters or missing evaluations from events that were missed while the socket was down. Don't write separate reconnect checks on the page. - Use
buildStatusLabel()from@shared/evaluationto display build status. Never show raw API values such asFailedPermanent. - Strip terminal's color codes with
removeAnsiEscapeSequences(), imported from@shared/log, before evaluator or build output can appear in tooltips or error lines outside the log viewer. - Event names via
eventNameToReadableText()of@core/models, never dotted likebuild.failed_transient. Server error chains in table cells viagetLastErrorCause()of@shared/text. Put full text intitle. - Link sibling pages of one area, such as the user settings, with gr-link-tabs in the page banner slot, so every page reaches its siblings in one click.
- Show repository fetch failures in
app-repository-fetch-bannerof@shared/git. Members who can edit the task see the git error and how to fix the failure. Everyone else sees who to ask. - Use
app-incoming-deliveriesfrom@shared/gitto show the webhooks that the Git host sent on the connection to the Git host. Rows include the event, result and rejection reason. - Show outgoing deliveries of event notifications and task actions in app-outgoing-webhook-delivery-list-dialog of @shared/outgoing-deliveries. A click on a row shows the error, request body and response body. Rows wrap on narrow screens. Show the short result of a delivery with getDeliveryResultReason(): the HTTP status or the last cause of the error.
- Keep the initial bundle below the 500 kB budget. Load shell parts not needed for first render (dialogs, command palette, menus built on
@angular/cdk/overlay) inside a@defer (on idle)block. Import lazy components from their own file, not from a barrel such as@shared/confirm. Imports from a barrel keep the component in the initial bundle. Triggers inside the shell store clicks that happen before the lazy code has loaded (see the user menu in the header). Those triggers replay the clicks after the block has rendered. - Sections with their own guard, such as the job board, keep their routes in the
<feature>.routes.tsfile. Load them fromapp.routes.tswithloadChildren. The guard and the services that come with it stay out of the initial bundle. - Put the repository URL, the access check, the picker for Git host connection and the switch for Report commit status on the repository page of a task. Edit the triggers for push and pull request only on the triggers page. Two features belong to the connection. The UI labels for the two features are "receives events" and "reports status".
- Use at most one primary button per view or section. A primary button can be the main action in a page header, the submit button in a form or dialog, or an empty-state action. Use
secondaryfor section header actions, row actions, and all other actions. Assign the same severity to equivalent actions. Usedangerfor all destructive actions, namely delete, revoke, remove, abort, deny, disconnect. Keepsecondaryfor disable, enable, deactivate and activate. These actions are reversible. Keepsecondaryfor declining an invitation because it deletes nothing. Use thepauseandplay_arrowicons for deactivate and activate. Only these three severities exist underbutton[grButton]. Disabled buttons keep the fill for their severity at half opacity, so even a disabled primary button can still read as the primary action next to an enabled Cancel. Tests incontrast.spec.tscheck the primary fill on a page at 3:1. - Set
disabledReasononbutton[grButton]for a button that the user can't use yet. One example is "Evaluation is already queued". The button can stay focusable and block clicks. The button can show the reason as a tooltip on hover and focus. The same button can announce the reason to screen readers througharia-describedby.[grTooltip]on the same button can display the reason when set. Use nativedisabledonly for buttons that are temporarily blocked. Common cases are an invalid form or a request in progress. - Set
disabledReasonon agr-menuitem that the user can't use yet, the same way as onbutton[grButton]. The item stays focusable and in the arrow key order, ignores clicks and shows the reason below its label on hover and focus. Screen readers announce the reason througharia-describedby. Usedisabledonly for entries that have no reason. Take the reason for build entries (Closure, Artefacts, SBOM, Download Log, Show job) from theget*MenuItemDisabledReasonfunction in@shared/evaluation. Use the same wording on the evaluation log, the task page and the metrics page. - Empty text and a pointer exit from a disabled host both hide
[grTooltip]. To remove the tooltip, bind an empty string. Don't wrap the directive in another condition. - Wrap the link to the list with
withCreateDialogQueryParam()from@shared/formsfor the create dialog on a list page (projects, teams, caches). List pages callopenCreateDialogFromUrlIfAllowed(canCreate, open)in the constructor. Open the dialog only for users who can create. Remove the parameter from the URL. Back navigation and reload do not open the dialog again. - Show the create action once per view. Put it only in the empty state with an empty list, and in the page header once items appear.
- Row actions have visible labels (Edit, Remove, Revoke, Delete). Keep the
aria-labelfor the target. Use icon-only buttons only in table cells, toolbars, and zoom controls when the label doesn't fit. Buttons in the same row have the same size. - Set the content width of a page with the
widthinput ofgr-page-layout. Don't set a fixed width on sections. Useform(720px) for creation flows,settings(880px) for all settings pages and their sibling pages,detail(1200px) for overviews and lists, andfullfor graphs and logs. Pages withoutgr-page-layoutuse the same$content-width-*variables. Button labels don't wrap. Wrap the button row with.gr-form-actionsinstead. - The header menu can fill the full height below the header on narrow screens and use the font size of body text. A one-line row meta, such as a commit and its elapsed time, can cut off with an ellipsis and not wrap to a second line.
- Fit the graph canvas to the content on load. Small graphs fill the view rather than a small patch in blank space. Set legend text to 14px and color swatches to 12px.
- Mark the active tab of
gr-link-tabsand every other tab row with a--gr-accentunderline. Put badges on the name line of a row and separate the parts of the meta line with " · ". Don't nest agr-row-listinside a card. Each row is already its own card, so set[card]="false"on the section around it. - Use
gr-link-tabsfor every tab row on a page, including the job board. Add the globalgr-scroll-fade-rowclass to every row that scrolls sideways, such as tab rows and card strips. It fades the row only on the side where more items are hidden. Keep the active tab in view. Usegr-rowon narrow screens to move labeled buttons and selects to a separate line below the name, so the name can keep full width. The info bar on the log page can wrap to multiple lines instead of a horizontal scroll. Stat cards align values to the top. Values on the same row line up even with a label on multiple lines. - Treat
durationas runtime. FormatdurationwithformatDuration()from@shared/text. Measure an evaluation from the first fetch (evaluationDuration()). Measure a build from the start of an attempt (buildDuration()). Both are@shared/evaluation. Never count queue time as duration. Table cells display "-" for a job or evaluation that didn't start. Page headers (evaluation log, summary) leave the duration out until the evaluation starts. - Show the build count from
buildTally()inside@shared/evaluationasdone / total builds. Place that label next togr-segmented-bar, which shows the same counts. Count completed, failed and cancelled builds as done. Dependency-failed builds count as cancelled. Count substituted builds only in the overall total. Don't add a second build counter with a different meaning. Running builds take the striped section of the bar, so the solid section and the completed count in the label line up. - Show API timestamps in one format, "Nov 8, 2026, 11:38" in local time on a 24 hour clock, through the
serverDatepipe (ordateTimeText()in code) from@shared/text. The pipe takes no format argument. Show elapsed time ("5m ago") in row meta lines and stat cards with therelativeTimepipe, and put the full date intitle. Chart axes useclockTime(),monthDay()ormonthDayClockTime(). Never use Angular'sdatepipe,toLocaleString()ornew Date()on API timestamps: they arrive as UTC without a zone. Never callDate.now()in a template binding: readCurrentTimeSignal, which ticks once a second, so a relative time or a running duration keeps one value through a change detection pass.
Shared UI Package¶
The package @gradient/ui lives in the pnpm workspace at frontend/packages/ui. Two consumers build on it: Gradient itself and the frontend of gradient-proxy for servers.gradient.ci.
| Entry | Content |
|---|---|
@gradient/ui/ui |
Generic primitives, listed under gr-ui |
@gradient/ui/chrome |
gr-header and gr-footer, configured through brand, nav and footer link inputs plus a [slot=lang] |
@gradient/ui/tokens |
Colour tokens from tokens.ts |
@gradient/ui/styles/* |
SCSS partials variables, themes, grids and the global base styles |
- The package must stay free of imports from
@core,@sharedor@features. Only primitives without such imports belong there. - An ESLint rule blocks these imports in
packages/uicode. pnpm tokens:generateandpnpm tokens:checkdelegate their work to the package.ng testruns the package specs as well.- The
gradient-proxyfrontend can link the package withlink:../../frontend/packages/ui.
gr-ui¶
The generic building blocks live in frontend/packages/ui/src/ui/ and build on @angular/cdk. Gradient-specific components (gr-eval-status-badge, gr-status-icon, gr-waiting-notice, gr-live-status, gr-metric-chart, gr-star-button, gr-label-help, gr-entity-name) live in frontend/src/app/shared/ui/. Imports go through the barrel of each layer.
import { FormFieldComponent, PageLayoutComponent, SettingsSectionComponent } from '@gradient/ui/ui';
import { MetricChartComponent } from '@shared/ui';
| Group | Selectors |
|---|---|
| Actions | button[grButton], a[grButton], gr-star-button, gr-menu |
| Forms | gr-form-field, input[grInput], textarea[grInput], select[grInput], gr-password-input, gr-name-field, gr-select, gr-select-button, gr-checkbox, gr-autocomplete, gr-label-help, gr-label-explanation-button |
| Display | gr-badge, gr-eval-status-badge, gr-status-icon, gr-icon, gr-logo, gr-copy-field, gr-field-row, gr-stat-card, gr-metric-chart, gr-table, gr-divider |
| Feedback | gr-message-banner, gr-toast (with MessageService), gr-loading-spinner, gr-empty-state, gr-load-state, gr-load-more |
| Overlays | gr-dialog, gr-popover, [grTooltip] |
| Layout | gr-page-layout, gr-breadcrumb, gr-link-tabs, gr-settings-section, gr-row-list / gr-row, gr-card-grid, gr-nav-card, gr-tab-switch, [grInView], [grScrollRegion], [grDrawer] |
gr-page-layout: a header with title and subtitle, a breadcrumb, optional[slot=actions]buttons and an optional[slot=banner], then the content. Actions move to a dedicated row below the title on smartphones. Labels stay unchanged. The current breadcrumb item and the title ofgr-nav-cardshorten long names with an ellipsis. A tooltip shows the full name.gr-settings-section: A section with a title. An optional description can appear as a help icon after the heading. The default is a card around the section. Set[card]="false"to remove the card.gr-load-state: a wrapper for any content that can load its own data. The inputsloading,errorandemptypick one of four states (a spinner, an error with a Try Again button, an empty state, or content). Errors always take precedence over the empty state. A failed request can never show the "nothing here yet" text. 403 or 404 responses show the inaccessible state without Retry. Keep the data visible on reload. Skip the spinner with data on screen. Put write errors (save, delete) outsideerror. Those errors belong next to the failed action.- Board tabs load requests through
firstLoad(). Board tabs can show an error state only when no requests in a load round respond. Some requests respond. Board tabs keep the content that did load and show the failure with a toast. Tabs with independent panels (Assigned and Pending in Live Jobs) give each panel its ownfirstLoad(). Keep panel switching outside load state. A failure in one panel can never remove the other panel from view. - Mark
mainwitharia-busyin the app shell if route guards, resolvers, or page code wait longer than 300 ms during navigation. Also show a "Loading page..." spinner on the first page of a visit. Don't add another loading state to a page for a route guard or resolver. - Pickers with an empty list need another item (a cache, a team, a connection to a Git host). Show the next step in the
.gr-form-asiderow below the field. Users who can create that item get the create dialog in place. Reopen the original dialog with the new item selected after creation. Links to the page for that item cover the other case. Don't show the create option to users who can't create.injectCanCreateCache()andinjectCanCreateTeam()hold that check inside@shared/forms. - Server-paginated lists (projects, tasks, caches) use
pagedList()from@shared/pagingand end withgr-load-more. Lists keep items on screen and add the next page. Show a toast on a failed page load. Keep the list. - Keep lists that other users change (tasks, caches, members, subscription requests) current with
runReloadIntervalWhileTabVisible()from@shared/paging. PasspagedList().refreshFirstPageSilently()or a fetch that sets the signal. The helper skips hidden tabs, reloads when the tab shows again and keeps the shown items when a reload fails. Pages with a socket usegr-live-statusinstead. Pages built from sections that each load their own data call the helper once. They merge the silent reload of each rendered section, as on the dashboard.
Grid Utilities¶
frontend/packages/ui/src/styles/_grids.scss, registered globally in src/styles.scss.
| Class | Layout |
|---|---|
.gr-grid-stats |
Auto-fit grid of stat cards, 220px minimum |
.gr-grid-form |
Two-column form, one column below $breakpoint-md. .gr-grid-form__full will span both |
.gr-grid-cards |
Auto-fill grid of cards, 280px minimum |
.gr-grid-rows |
Label, value, actions rows |
.gr-form-aside |
Auxiliary row below form fields. Prompt for the next action (e.g. create a missing item). |
.gr-form-actions |
Row of form buttons. --end will align right |
Related¶
- Contributing covers the rules for dependencies and lockfiles.