@akita-protocol/algomd-rn 1.0.0-alpha.1 → 1.0.0-alpha.2
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 +2 -2
- package/src/presentation/icons.tsx +108 -1
- package/src/presentation/pluginColors.ts +1 -0
- package/src/presentation/runtime.tsx +11 -0
- package/src/refs/AccountRef.tsx +24 -10
- package/src/refs/GuildActions.tsx +913 -0
- package/src/refs/GuildProposalRef.tsx +60 -55
- package/src/refs/index.tsx +1 -0
- package/src/refs/primitives.tsx +51 -19
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
2
|
import { StyleSheet, View } from "react-native";
|
|
3
3
|
import {
|
|
4
|
-
GUILD_ZERO_ADDRESS,
|
|
5
4
|
formatRelativeTime,
|
|
6
5
|
guildBallotOutcome,
|
|
7
6
|
guildProposalStatusLabel,
|
|
@@ -12,21 +11,20 @@ import {
|
|
|
12
11
|
type GuildProposalStatus,
|
|
13
12
|
} from "@akita-protocol/algomd-core";
|
|
14
13
|
import { useGuildProposal } from "@akita-protocol/algomd-core/react";
|
|
15
|
-
import {
|
|
14
|
+
import { GuildIcon, HandThumbDownIcon, HandThumbUpIcon } from "../presentation/icons";
|
|
15
|
+
import { PLUGIN_COLORS } from "../presentation/pluginColors";
|
|
16
16
|
import { Text, useAppTheme, usePresentation, type GuildVoteChoice } from "../presentation/runtime";
|
|
17
|
-
import { PersonRow } from "./AccountRef";
|
|
18
17
|
import { ActionButton, plural, useNow } from "./contractParts";
|
|
18
|
+
import { GuildActionList } from "./GuildActions";
|
|
19
19
|
import {
|
|
20
20
|
Card,
|
|
21
21
|
CardHeader,
|
|
22
22
|
CardSkeleton,
|
|
23
|
-
headerMedia,
|
|
24
23
|
InlinePill,
|
|
25
24
|
KindTile,
|
|
26
25
|
Note,
|
|
27
26
|
Row,
|
|
28
27
|
RowSkeleton,
|
|
29
|
-
Section,
|
|
30
28
|
StatusBadge,
|
|
31
29
|
Title,
|
|
32
30
|
Unavailable,
|
|
@@ -43,7 +41,7 @@ const PROGRESS: Record<CardAction, string> = {
|
|
|
43
41
|
abstain: "Abstaining…",
|
|
44
42
|
submit: "Opening the vote…",
|
|
45
43
|
finalize: "Closing the vote…",
|
|
46
|
-
execute: "
|
|
44
|
+
execute: "Applying the changes…",
|
|
47
45
|
};
|
|
48
46
|
|
|
49
47
|
const VOTED: Record<GuildVoteChoice, string> = {
|
|
@@ -61,6 +59,9 @@ const STATUS_TONE: Record<GuildProposalStatus, Tone> = {
|
|
|
61
59
|
executed: "good",
|
|
62
60
|
};
|
|
63
61
|
|
|
62
|
+
/** How long the host's automation gets before the card offers to do it by hand. */
|
|
63
|
+
const AUTOMATION_GRACE = 10 * 60;
|
|
64
|
+
|
|
64
65
|
function timeLeft(votingEnd: string, now: number): string {
|
|
65
66
|
const remaining = Number(votingEnd) - now;
|
|
66
67
|
if (remaining <= 0) return "Voting closed";
|
|
@@ -86,15 +87,15 @@ export function GuildProposalRef({ id, size = "large", params, onPress, visible
|
|
|
86
87
|
const retry = proposal.isError ? () => void proposal.refetch() : undefined;
|
|
87
88
|
|
|
88
89
|
if (size === "inline") {
|
|
89
|
-
return <InlinePill label={label} dim={proposal.isPending} leading={<
|
|
90
|
+
return <InlinePill label={label} dim={proposal.isPending} leading={<GuildIcon size={12} color={PLUGIN_COLORS.Guild} />} onPress={press} />;
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
if (size === "small") {
|
|
93
94
|
if (proposal.isPending) return <RowSkeleton shape="rounded" />;
|
|
94
|
-
if (!data) return <Unavailable size="small" label={label} Icon={
|
|
95
|
+
if (!data) return <Unavailable size="small" label={label} Icon={GuildIcon} onRetry={retry} />;
|
|
95
96
|
return (
|
|
96
97
|
<Row
|
|
97
|
-
leading={<KindTile Icon={
|
|
98
|
+
leading={<KindTile Icon={GuildIcon} color={PLUGIN_COLORS.Guild} size={40} />}
|
|
98
99
|
title={<Title>{label}</Title>}
|
|
99
100
|
subtitle={`Guild proposal #${data.proposalId} · ${plural(data.actions.length, "action")}`}
|
|
100
101
|
trailing={<StatusBadge label={guildProposalStatusLabel(data.status)} tone={STATUS_TONE[data.status]} />}
|
|
@@ -105,7 +106,7 @@ export function GuildProposalRef({ id, size = "large", params, onPress, visible
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
if (proposal.isPending) return <CardSkeleton media="rounded" blocks={3} action full={size === "full"} />;
|
|
108
|
-
if (!data) return <Unavailable size={size} label={label} Icon={
|
|
109
|
+
if (!data) return <Unavailable size={size} label={label} Icon={GuildIcon} onRetry={retry} />;
|
|
109
110
|
return (
|
|
110
111
|
<GuildProposalCard
|
|
111
112
|
data={data}
|
|
@@ -152,7 +153,8 @@ function GuildProposalCard({
|
|
|
152
153
|
const { theme, tone } = usePalette();
|
|
153
154
|
const presentation = usePresentation();
|
|
154
155
|
const actions = presentation.actions;
|
|
155
|
-
const
|
|
156
|
+
const automated = !!presentation.guildAutomation;
|
|
157
|
+
const now = useNow(automated ? 15_000 : 60_000, data.status === "voting" || (automated && data.status === "approved"));
|
|
156
158
|
const [busy, setBusy] = useState<CardAction>();
|
|
157
159
|
const [error, setError] = useState<string>();
|
|
158
160
|
const [voted, setVoted] = useState<GuildVoteChoice>();
|
|
@@ -161,12 +163,29 @@ function GuildProposalCard({
|
|
|
161
163
|
const blocked = presentation.guildActionBlock?.(data.guildAppId);
|
|
162
164
|
const open = data.status === "voting" && !!ballot && !ballot.resolved;
|
|
163
165
|
const canVote = open && outcome === undefined && now <= Number(ballot!.votingEnd) && !!actions?.guildVote;
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
+
const settled = open && outcome !== undefined;
|
|
167
|
+
// Bootstrap proposals (no vote) only run for their creator, so the host's automation skips them.
|
|
168
|
+
const pendingRun = data.status === "approved" && data.votingTs !== "0";
|
|
169
|
+
const waiting = automated && (settled || pendingRun);
|
|
170
|
+
// When the automation's turn began: the vote's end, or when this card first saw it due.
|
|
171
|
+
const firstDue = useRef<number | undefined>(undefined);
|
|
172
|
+
if (waiting && firstDue.current === undefined) firstDue.current = now;
|
|
173
|
+
const dueSince = Math.min(Number(ballot?.votingEnd) || Infinity, firstDue.current ?? now);
|
|
174
|
+
const late = waiting && now - dueSince >= AUTOMATION_GRACE;
|
|
175
|
+
// Re-read the proposal while the automation works, so the card moves on by itself.
|
|
176
|
+
const refreshRef = useRef(refresh);
|
|
177
|
+
refreshRef.current = refresh;
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (!waiting) return;
|
|
180
|
+
const t = setInterval(() => refreshRef.current(), 20_000);
|
|
181
|
+
return () => clearInterval(t);
|
|
182
|
+
}, [waiting]);
|
|
183
|
+
const canFinalize = settled && !!actions?.guildFinalize && (!automated || late);
|
|
184
|
+
const canExecute = (automated ? pendingRun && late : data.status === "approved") && !!actions?.guildExecute;
|
|
166
185
|
const canSubmit =
|
|
167
186
|
data.status === "draft" && !!data.creator && data.creator === presentation.viewerAddress && !!actions?.guildSubmit;
|
|
168
|
-
const statusLabel =
|
|
169
|
-
const statusTone: Tone =
|
|
187
|
+
const statusLabel = settled ? (outcome === "approved" ? "Passed" : "Rejected") : guildProposalStatusLabel(data.status);
|
|
188
|
+
const statusTone: Tone = settled ? (outcome === "approved" ? "good" : "bad") : STATUS_TONE[data.status];
|
|
170
189
|
|
|
171
190
|
const run = async (action: CardAction) => {
|
|
172
191
|
if (busy || blocked) return;
|
|
@@ -191,12 +210,12 @@ function GuildProposalCard({
|
|
|
191
210
|
return (
|
|
192
211
|
<Card>
|
|
193
212
|
<CardHeader
|
|
194
|
-
|
|
213
|
+
eyebrow={{ label: "Guild proposal", Icon: GuildIcon, color: PLUGIN_COLORS.Guild }}
|
|
195
214
|
title={title}
|
|
196
215
|
titleLines={3}
|
|
197
216
|
full={full}
|
|
198
217
|
status={<StatusBadge label={statusLabel} tone={statusTone} />}
|
|
199
|
-
meta={
|
|
218
|
+
meta={`#${data.proposalId}${data.created && data.created !== "0" ? ` · ${formatRelativeTime(Number(data.created))}` : ""}`}
|
|
200
219
|
/>
|
|
201
220
|
|
|
202
221
|
{summary ? (
|
|
@@ -205,40 +224,20 @@ function GuildProposalCard({
|
|
|
205
224
|
</Text>
|
|
206
225
|
) : null}
|
|
207
226
|
|
|
208
|
-
{data.actions.length ?
|
|
209
|
-
<Section label={data.actions.length === 1 ? "If it passes" : `If it passes · ${data.actions.length} actions`}>
|
|
210
|
-
<View style={{ gap: 6 }}>
|
|
211
|
-
{data.actions.map((action, i) => (
|
|
212
|
-
<View key={`${action.type}:${i}`} style={{ gap: 6 }}>
|
|
213
|
-
<View style={styles.actionRow}>
|
|
214
|
-
<View style={[styles.dot, { backgroundColor: theme.colors.primary }]} />
|
|
215
|
-
<Text size="xs" style={{ flex: 1 }}>
|
|
216
|
-
{action.label}
|
|
217
|
-
{action.pluginAppId ? ` #${action.pluginAppId}` : ""}
|
|
218
|
-
{action.caller === GUILD_ZERO_ADDRESS ? " for members by vote" : ""}
|
|
219
|
-
</Text>
|
|
220
|
-
</View>
|
|
221
|
-
{action.caller && action.caller !== GUILD_ZERO_ADDRESS ? (
|
|
222
|
-
<PersonRow address={action.caller} role={action.type === 40 ? "Loses the plugin" : "Gets the plugin"} visible={visible} />
|
|
223
|
-
) : null}
|
|
224
|
-
</View>
|
|
225
|
-
))}
|
|
226
|
-
</View>
|
|
227
|
-
</Section>
|
|
228
|
-
) : null}
|
|
227
|
+
{data.actions.length ? <GuildActionList actions={data.actions} consensus={data.consensus} feeAsset={data.feeAsset} visible={visible} /> : null}
|
|
229
228
|
|
|
230
229
|
{ballot ? (
|
|
231
230
|
<View style={{ gap: 6 }}>
|
|
231
|
+
{guildRequirementsText(ballot) ? <Note>{guildRequirementsText(ballot)}</Note> : null}
|
|
232
232
|
<TallyBar ballot={ballot} />
|
|
233
233
|
<View style={styles.legend}>
|
|
234
234
|
<Text size="xxs" style={{ color: theme.colors.textDim }}>
|
|
235
235
|
{`${ballot.votes.approvals} yes · ${ballot.votes.rejections} no · ${ballot.votes.abstains} abstain`}
|
|
236
236
|
</Text>
|
|
237
237
|
<Text size="xxs" style={{ color: theme.colors.textDim }}>
|
|
238
|
-
{ballot.resolved ? "Closed" : timeLeft(ballot.votingEnd, now)}
|
|
238
|
+
{ballot.resolved ? "Closed" : settled && now <= Number(ballot.votingEnd) ? "Decided early" : timeLeft(ballot.votingEnd, now)}
|
|
239
239
|
</Text>
|
|
240
240
|
</View>
|
|
241
|
-
{guildRequirementsText(ballot) ? <Note>{guildRequirementsText(ballot)}</Note> : null}
|
|
242
241
|
</View>
|
|
243
242
|
) : null}
|
|
244
243
|
|
|
@@ -252,20 +251,29 @@ function GuildProposalCard({
|
|
|
252
251
|
</Text>
|
|
253
252
|
) : canVote ? (
|
|
254
253
|
<View style={styles.buttons}>
|
|
255
|
-
<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
<
|
|
262
|
-
|
|
263
|
-
|
|
254
|
+
<ActionButton label="Abstain" variant="text" onPress={() => void run("abstain")} />
|
|
255
|
+
<ActionButton label="No" Icon={HandThumbDownIcon} variant="secondary" onPress={() => void run("reject")} accessibilityLabel="Vote no" />
|
|
256
|
+
<ActionButton label="Yes" Icon={HandThumbUpIcon} onPress={() => void run("approve")} accessibilityLabel="Vote yes" />
|
|
257
|
+
</View>
|
|
258
|
+
) : late && (canFinalize || canExecute) ? (
|
|
259
|
+
<View style={{ gap: 8 }}>
|
|
260
|
+
<Note tone="warn">
|
|
261
|
+
{canFinalize
|
|
262
|
+
? "Closing this vote is taking longer than usual. You can close it yourself; your wallet pays the network fee."
|
|
263
|
+
: "Applying this proposal is taking longer than usual. You can apply it yourself; your wallet pays the network fee."}
|
|
264
|
+
</Note>
|
|
265
|
+
<ActionButton
|
|
266
|
+
label={canFinalize ? "Close the vote now" : "Apply it now"}
|
|
267
|
+
variant="secondary"
|
|
268
|
+
onPress={() => void run(canFinalize ? "finalize" : "execute")}
|
|
269
|
+
/>
|
|
264
270
|
</View>
|
|
271
|
+
) : waiting ? (
|
|
272
|
+
<Note>{settled ? (outcome === "approved" ? "The vote passed. The changes apply automatically in a moment." : "The vote failed. It closes automatically in a moment.") : "Passed. The changes are being applied automatically."}</Note>
|
|
265
273
|
) : canFinalize ? (
|
|
266
274
|
<ActionButton label="Close the vote" onPress={() => void run("finalize")} />
|
|
267
275
|
) : canExecute ? (
|
|
268
|
-
<ActionButton label="
|
|
276
|
+
<ActionButton label="Apply the changes" onPress={() => void run("execute")} />
|
|
269
277
|
) : canSubmit ? (
|
|
270
278
|
<ActionButton label="Open voting" onPress={() => void run("submit")} />
|
|
271
279
|
) : null}
|
|
@@ -278,8 +286,5 @@ function GuildProposalCard({
|
|
|
278
286
|
const styles = StyleSheet.create({
|
|
279
287
|
track: { borderRadius: 3, flexDirection: "row", height: 6, overflow: "hidden" },
|
|
280
288
|
legend: { flexDirection: "row", justifyContent: "space-between", gap: 12 },
|
|
281
|
-
|
|
282
|
-
dot: { borderRadius: 3, height: 6, marginTop: 6, width: 6 },
|
|
283
|
-
buttons: { flexDirection: "row", gap: 8 },
|
|
284
|
-
flex: { flex: 1 },
|
|
289
|
+
buttons: { alignItems: "center", flexDirection: "row", gap: 8, justifyContent: "flex-end" },
|
|
285
290
|
});
|
package/src/refs/index.tsx
CHANGED
|
@@ -37,6 +37,7 @@ export { SubscriptionRef } from "./SubscriptionRef";
|
|
|
37
37
|
export { TradeRef } from "./TradeRef";
|
|
38
38
|
export { DualStakeRef } from "./DualStakeRef";
|
|
39
39
|
export { GuildProposalRef } from "./GuildProposalRef";
|
|
40
|
+
export { GuildActionList, GuildPluginDetails } from "./GuildActions";
|
|
40
41
|
export { PageCardRef, PageLinksProvider, PrivateContentRef, type PageLinks } from "./HostRefs";
|
|
41
42
|
export { useAssetInfo, useFormattedAmount, ALGO_ASSET, type AssetInfo } from "./assetInfo";
|
|
42
43
|
export { Amount, StatusChip, ProvenanceNote, useNow } from "./contractParts";
|
package/src/refs/primitives.tsx
CHANGED
|
@@ -110,11 +110,11 @@ export function Avatar({ uri, size, shape = "circle", initial, icon }: AvatarPro
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/** The tile for kinds without their own image: the kind's icon on a primary tint. */
|
|
113
|
-
export function KindTile({ Icon, size, dim }: { Icon: IconComponent; size: number; dim?: boolean }) {
|
|
113
|
+
export function KindTile({ Icon, size, dim, color }: { Icon: IconComponent; size: number; dim?: boolean; color?: string }) {
|
|
114
114
|
const { theme, tint } = usePalette();
|
|
115
115
|
return (
|
|
116
116
|
<View style={[styles.center, { width: size, height: size, borderRadius: Math.max(4, size / 4), backgroundColor: dim ? theme.colors.border : tint }]}>
|
|
117
|
-
<Icon size={Math.round(size * 0.48)} color={dim ? theme.colors.textDim : theme.colors.primary} />
|
|
117
|
+
<Icon size={Math.round(size * 0.48)} color={dim ? theme.colors.textDim : (color ?? theme.colors.primary)} />
|
|
118
118
|
</View>
|
|
119
119
|
);
|
|
120
120
|
}
|
|
@@ -130,18 +130,20 @@ export interface InlinePillProps {
|
|
|
130
130
|
leading?: React.ReactNode;
|
|
131
131
|
trailing?: React.ReactNode;
|
|
132
132
|
dim?: boolean;
|
|
133
|
+
/** Tints the pill with the primary color, to pick a name out of a sentence. */
|
|
134
|
+
highlight?: boolean;
|
|
133
135
|
onPress?: () => void;
|
|
134
136
|
onLongPress?: () => void;
|
|
135
137
|
accessibilityLabel?: string;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
/** The inline shape. It is a View, so it can sit inside a Text run. */
|
|
139
|
-
export function InlinePill({ label, leading, trailing, dim, onPress, onLongPress, accessibilityLabel }: InlinePillProps) {
|
|
141
|
+
export function InlinePill({ label, leading, trailing, dim, highlight, onPress, onLongPress, accessibilityLabel }: InlinePillProps) {
|
|
140
142
|
const { theme } = useAppTheme();
|
|
141
143
|
const pill = (
|
|
142
|
-
<View style={[styles.pill, { backgroundColor: theme.colors.accentBackground, opacity: dim ? 0.6 : 1 }]}>
|
|
144
|
+
<View style={[styles.pill, { backgroundColor: highlight ? `${theme.colors.primary}24` : theme.colors.accentBackground, opacity: dim ? 0.6 : 1 }]}>
|
|
143
145
|
{leading}
|
|
144
|
-
<Text weight="medium" numberOfLines={1} style={[styles.pillText, { color: theme.colors.text }]}>
|
|
146
|
+
<Text weight="medium" numberOfLines={1} style={[styles.pillText, { color: highlight ? theme.colors.primary : theme.colors.text }]}>
|
|
145
147
|
{label}
|
|
146
148
|
</Text>
|
|
147
149
|
{trailing}
|
|
@@ -225,7 +227,13 @@ export function Card({ children, style }: { children: React.ReactNode; style?: S
|
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
export interface CardHeaderProps {
|
|
228
|
-
|
|
230
|
+
/** The image or kind tile. Leave out when the eyebrow already names the kind. */
|
|
231
|
+
media?: React.ReactNode;
|
|
232
|
+
/**
|
|
233
|
+
* The card's kind above the title, like the auction, listing and raffle
|
|
234
|
+
* cards: a small icon and an uppercase label in the kind's colour.
|
|
235
|
+
*/
|
|
236
|
+
eyebrow?: { label: string; Icon?: IconComponent; color?: string };
|
|
229
237
|
title: React.ReactNode;
|
|
230
238
|
verified?: boolean;
|
|
231
239
|
/** A status badge, shown before the meta line. */
|
|
@@ -244,12 +252,21 @@ export interface CardHeaderProps {
|
|
|
244
252
|
* line of context under it. Status sits under the title so a long name keeps
|
|
245
253
|
* the full width on a phone.
|
|
246
254
|
*/
|
|
247
|
-
export function CardHeader({ media, title, verified, status, meta, menu, full, titleLines = 2 }: CardHeaderProps) {
|
|
255
|
+
export function CardHeader({ media, eyebrow, title, verified, status, meta, menu, full, titleLines = 2 }: CardHeaderProps) {
|
|
248
256
|
const { theme } = useAppTheme();
|
|
257
|
+
const eyebrowColor = eyebrow?.color ?? theme.colors.primary;
|
|
249
258
|
return (
|
|
250
259
|
<View style={styles.header}>
|
|
251
260
|
{media}
|
|
252
261
|
<View style={styles.headerText}>
|
|
262
|
+
{eyebrow ? (
|
|
263
|
+
<View style={styles.eyebrow}>
|
|
264
|
+
{eyebrow.Icon ? <eyebrow.Icon size={13} color={eyebrowColor} /> : null}
|
|
265
|
+
<Text size="xxs" weight="semiBold" numberOfLines={1} style={{ color: eyebrowColor, letterSpacing: 0.6, textTransform: "uppercase" }}>
|
|
266
|
+
{eyebrow.label}
|
|
267
|
+
</Text>
|
|
268
|
+
</View>
|
|
269
|
+
) : null}
|
|
253
270
|
<View style={styles.inlineRow}>
|
|
254
271
|
{typeof title === "string" ? (
|
|
255
272
|
<Text size={full ? "lg" : "md"} weight="bold" numberOfLines={titleLines} style={{ flexShrink: 1 }}>
|
|
@@ -388,14 +405,31 @@ export function StatusBadge({ label, tone = "neutral" }: { label: string; tone?:
|
|
|
388
405
|
export interface ActionButtonProps {
|
|
389
406
|
label: string;
|
|
390
407
|
onPress: () => void;
|
|
391
|
-
/**
|
|
392
|
-
|
|
408
|
+
/**
|
|
409
|
+
* `secondary` is a quiet fill for the second of two actions. `text` has no
|
|
410
|
+
* fill, for an action to de-emphasize.
|
|
411
|
+
*/
|
|
412
|
+
variant?: "primary" | "secondary" | "text";
|
|
413
|
+
/** Draws the icon in place of the label, in a button only as wide as it needs. The label stays for accessibility. */
|
|
414
|
+
Icon?: IconComponent;
|
|
393
415
|
accessibilityLabel?: string;
|
|
394
416
|
}
|
|
395
417
|
|
|
396
418
|
/** The card's action, drawn like the Akita app's confirm buttons. */
|
|
397
|
-
export function ActionButton({ label, onPress, variant = "primary", accessibilityLabel }: ActionButtonProps) {
|
|
419
|
+
export function ActionButton({ label, onPress, variant = "primary", Icon, accessibilityLabel }: ActionButtonProps) {
|
|
398
420
|
const { theme, inset } = usePalette();
|
|
421
|
+
const color = variant === "primary" ? theme.gradients.interactiveText : variant === "text" ? theme.colors.textDim : theme.colors.text;
|
|
422
|
+
const content = Icon ? (
|
|
423
|
+
// Positioned, so the web renderer paints it above the gradient fill.
|
|
424
|
+
<View style={{ position: "relative" }}>
|
|
425
|
+
<Icon size={20} color={color} />
|
|
426
|
+
</View>
|
|
427
|
+
) : (
|
|
428
|
+
<Text size="sm" weight={variant === "text" ? "semiBold" : "bold"} numberOfLines={1} style={{ color }}>
|
|
429
|
+
{label}
|
|
430
|
+
</Text>
|
|
431
|
+
);
|
|
432
|
+
const shape = StyleSheet.flatten([styles.button, Icon && styles.iconButton, variant === "text" && styles.textButton]);
|
|
399
433
|
return (
|
|
400
434
|
<SquishyPressable pressedScale={0.97} onPress={onPress} accessibilityRole="button" accessibilityLabel={accessibilityLabel ?? label}>
|
|
401
435
|
{variant === "primary" ? (
|
|
@@ -404,18 +438,12 @@ export function ActionButton({ label, onPress, variant = "primary", accessibilit
|
|
|
404
438
|
locations={theme.gradients.interactiveLocations ? [...theme.gradients.interactiveLocations] : undefined}
|
|
405
439
|
start={{ x: 0, y: 0 }}
|
|
406
440
|
end={{ x: 1, y: 0 }}
|
|
407
|
-
style={
|
|
441
|
+
style={shape}
|
|
408
442
|
>
|
|
409
|
-
|
|
410
|
-
{label}
|
|
411
|
-
</Text>
|
|
443
|
+
{content}
|
|
412
444
|
</LinearGradient>
|
|
413
445
|
) : (
|
|
414
|
-
<View style={[
|
|
415
|
-
<Text size="sm" weight="bold" numberOfLines={1}>
|
|
416
|
-
{label}
|
|
417
|
-
</Text>
|
|
418
|
-
</View>
|
|
446
|
+
<View style={[shape, variant === "secondary" && { backgroundColor: inset }]}>{content}</View>
|
|
419
447
|
)}
|
|
420
448
|
</SquishyPressable>
|
|
421
449
|
);
|
|
@@ -570,6 +598,7 @@ const styles = StyleSheet.create({
|
|
|
570
598
|
card: { borderRadius: 16, gap: 16, overflow: "hidden", padding: 16 },
|
|
571
599
|
header: { alignItems: "center", flexDirection: "row", gap: 12 },
|
|
572
600
|
headerText: { flex: 1, minWidth: 0, gap: 4 },
|
|
601
|
+
eyebrow: { alignItems: "center", flexDirection: "row", gap: 4, marginBottom: -2 },
|
|
573
602
|
metaRow: { alignItems: "center", flexDirection: "row", flexWrap: "wrap", columnGap: 8, rowGap: 2 },
|
|
574
603
|
statRow: { borderRadius: 14, flexDirection: "row", gap: 12, paddingHorizontal: 14, paddingVertical: 12 },
|
|
575
604
|
inset: { borderRadius: 14, paddingHorizontal: 14, paddingVertical: 4 },
|
|
@@ -585,4 +614,7 @@ const styles = StyleSheet.create({
|
|
|
585
614
|
badge: { alignItems: "center", flexDirection: "row", gap: 5 },
|
|
586
615
|
dot: { borderRadius: 3, height: 6, marginHorizontal: 3, width: 6 },
|
|
587
616
|
button: { alignItems: "center", borderRadius: 14, height: 48, justifyContent: "center", paddingHorizontal: 16 },
|
|
617
|
+
// Icon buttons are pills: the radius is half the 48px height.
|
|
618
|
+
iconButton: { borderRadius: 24, paddingHorizontal: 28 },
|
|
619
|
+
textButton: { paddingHorizontal: 8 },
|
|
588
620
|
});
|