|
1 | | -import { html, nothing, type TemplateResult } from "lit"; |
| 1 | +import { nothing, type TemplateResult } from "lit"; |
2 | 2 | import { t } from "../i18n/index.ts"; |
3 | 3 | import { formatUiError } from "../lib/format-error.ts"; |
| 4 | +import { renderPanelState } from "./panel-state.ts"; |
4 | 5 |
|
5 | 6 | export type PanelRefreshStatus = Readonly<{ |
6 | 7 | error: string | null; |
@@ -46,21 +47,14 @@ export function renderPanelRefreshStatus(params: { |
46 | 47 | if (!error && !status.stale) { |
47 | 48 | return nothing; |
48 | 49 | } |
49 | | - const className = params.className ? ` ${params.className}` : ""; |
50 | 50 | if (!error) { |
51 | | - return html` |
52 | | - <div class="callout warn${className}" role="status"> |
53 | | - <strong>${t("common.staleData")}</strong> |
54 | | - </div> |
55 | | - `; |
| 51 | + return renderPanelState( |
| 52 | + { kind: "notice", message: t("common.staleData") }, |
| 53 | + { className: params.className }, |
| 54 | + ); |
56 | 55 | } |
57 | | - return html` |
58 | | - <div class="callout danger callout--dismissible${className}" role="alert"> |
59 | | - <span class="callout__content"> |
60 | | - <span>${error}</span> |
61 | | - ${status.stale ? html`<br /><strong>${t("common.staleData")}</strong>` : nothing} |
62 | | - </span> |
63 | | - <button class="btn btn--sm" @click=${params.onRetry}>${t("common.retry")}</button> |
64 | | - </div> |
65 | | - `; |
| 56 | + return renderPanelState( |
| 57 | + { kind: "error", error, stale: status.stale, onRetry: params.onRetry }, |
| 58 | + { className: params.className, layout: "callout" }, |
| 59 | + ); |
66 | 60 | } |
0 commit comments