@reviewflow/ui 6.25.0 → 6.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reviewflow/ui",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.26.0",
|
|
4
4
|
"description": "react-native pull request screen components. Consumed as SOURCES (no build): exports resolve `default` to ./src/index.ts, which metro transforms like the app's own files; the consuming app's css must @source this package's src so tailwind keeps its classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alouette",
|
|
@@ -40,7 +40,7 @@ import { ChatCircleDotsRegularIcon } from "alouette-icons/phosphor-icons/ChatCir
|
|
|
40
40
|
import type { ReactNode } from "react";
|
|
41
41
|
import { useState } from "react";
|
|
42
42
|
import { usePullRequestDataSource } from "../dataSource.ts";
|
|
43
|
-
import {
|
|
43
|
+
import { usePrStatusAccent } from "../prStatus.ts";
|
|
44
44
|
import { emojify } from "../services/emojify.ts";
|
|
45
45
|
import { errorToMessage } from "../services/errorToMessage.ts";
|
|
46
46
|
import { formatDataAge } from "../services/formatDataAge.ts";
|
|
@@ -156,6 +156,12 @@ interface MergeLineProps {
|
|
|
156
156
|
children?: ReactNode;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
function StatusBadge({ status }: { status: PrStatus }): ReactNode {
|
|
160
|
+
return (
|
|
161
|
+
<Badge accent={usePrStatusAccent(status)}>{prStatusLabels[status]}</Badge>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
159
165
|
function MergeLine({
|
|
160
166
|
status,
|
|
161
167
|
author,
|
|
@@ -165,9 +171,7 @@ function MergeLine({
|
|
|
165
171
|
}: MergeLineProps): ReactNode {
|
|
166
172
|
return (
|
|
167
173
|
<View className="flex-row flex-wrap items-center gap-xs">
|
|
168
|
-
{status === null ? null :
|
|
169
|
-
<Badge accent={prStatusAccents[status]}>{prStatusLabels[status]}</Badge>
|
|
170
|
-
)}
|
|
174
|
+
{status === null ? null : <StatusBadge status={status} />}
|
|
171
175
|
<Text className="text-sm font-body-bold">
|
|
172
176
|
{author ?? "unknown author"}
|
|
173
177
|
</Text>
|
package/src/prStatus.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PrStatus } from "@reviewflow/sdk";
|
|
2
2
|
import type { Accent } from "alouette";
|
|
3
|
+
import { usePullRequestSlots } from "./slots.tsx";
|
|
3
4
|
|
|
4
|
-
/** A merged pull request takes the brand accent; an app with its own accent for it passes one
|
|
5
|
+
/** A merged pull request takes the brand accent; an app with its own accent for it passes one in the `prStatusAccents` slot. */
|
|
5
6
|
export const prStatusAccents: Record<PrStatus, Accent | undefined> = {
|
|
6
7
|
approved: "success",
|
|
7
8
|
changesRequested: "danger",
|
|
@@ -11,3 +12,9 @@ export const prStatusAccents: Record<PrStatus, Accent | undefined> = {
|
|
|
11
12
|
noReviewers: "warning",
|
|
12
13
|
waitingReview: "info",
|
|
13
14
|
};
|
|
15
|
+
|
|
16
|
+
/** The badge accent of `status`: the app's (the `prStatusAccents` slot) over the ui's. */
|
|
17
|
+
export const usePrStatusAccent = (status: PrStatus): Accent | undefined => {
|
|
18
|
+
const { prStatusAccents: appAccents = {} } = usePullRequestSlots();
|
|
19
|
+
return status in appAccents ? appAccents[status] : prStatusAccents[status];
|
|
20
|
+
};
|
package/src/slots.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { PrStatus } from "@reviewflow/sdk";
|
|
2
|
+
import type { Accent } from "alouette";
|
|
1
3
|
import type { ReactNode } from "react";
|
|
2
4
|
import { createContext, use } from "react";
|
|
3
5
|
|
|
@@ -25,6 +27,12 @@ export interface PullRequestSlots {
|
|
|
25
27
|
* checkout is configured. Absent: the message stands alone.
|
|
26
28
|
*/
|
|
27
29
|
renderRepositoryAction?: (ownerRepo: string) => ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* The status badge's accent, per status, over `prStatusAccents`: an app with
|
|
32
|
+
* an accent of its own for one (a theme it generates beside alouette's, cast
|
|
33
|
+
* to `Accent`) passes it here.
|
|
34
|
+
*/
|
|
35
|
+
prStatusAccents?: Partial<Record<PrStatus, Accent | undefined>>;
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
const SlotsContext = createContext<PullRequestSlots>({});
|