返回 CodeWhale
artifacts.rs
根目录 / vendor / codewhale-ratatui / src / gallery / artifacts.rs
1 //! Artifact fixtures over illustrative caller data, without filesystem or run claims.
2
3 use ratatui::{buffer::Buffer, layout::Rect};
4
5 use super::Entry;
6 use crate::{Artifact, ArtifactKind, ArtifactShelf, Paint, ReceiptValue, State, Theme};
7
8 fn artifact(area: Rect, buf: &mut Buffer, theme: &Theme) {
9 Artifact::new("Release checklist.md", ArtifactKind::File, State::Done)
10 .detail("docs/release-checklist.md")
11 .action("Open")
12 .receipt("Size", ReceiptValue::Bytes(Some(4280)))
13 .paint(area, buf, theme);
14 }
15
16 fn shelf(area: Rect, buf: &mut Buffer, theme: &Theme) {
17 ArtifactShelf::new(vec![
18 Artifact::new("Release checklist.md", ArtifactKind::File, State::Done)
19 .detail("docs/release-checklist.md")
20 .action("Open")
21 .receipt("Size", ReceiptValue::Bytes(Some(4280))),
22 Artifact::new(
23 "Conversation changes",
24 ArtifactKind::Review,
25 State::NeedsYou,
26 )
27 .detail("Composer and transcript")
28 .action("Review")
29 .receipt("Files", ReceiptValue::Count(Some(3))),
30 Artifact::new("Local verification", ArtifactKind::Run, State::Done)
31 .detail("Reported by the host")
32 .action("Inspect")
33 .receipt("Checks", ReceiptValue::Count(Some(15))),
34 Artifact::new("Working notes", ArtifactKind::Link, State::Ready)
35 .detail("Project reference")
36 .action("Open"),
37 ])
38 .selected(1)
39 .focused(true)
40 .paint(area, buf, theme);
41 }
42
43 fn narrow(area: Rect, buf: &mut Buffer, theme: &Theme) {
44 ArtifactShelf::new(vec![
45 Artifact::new(
46 "cafe\u{301} 鲸鱼 — terminal review.md",
47 ArtifactKind::File,
48 State::Done,
49 )
50 .detail("notes/terminal-review.md")
51 .action("Open"),
52 Artifact::new(
53 "Changes still need a decision",
54 ArtifactKind::Review,
55 State::NeedsYou,
56 )
57 .detail("A long caller-provided review summary")
58 .action("Review"),
59 Artifact::new("Verification has gaps", ArtifactKind::Run, State::NeedsYou)
60 .status_word("Finished with gaps")
61 .detail("One check was not reported")
62 .action("Inspect"),
63 ])
64 .selected(2)
65 .focused(true)
66 .omitted(1)
67 .paint(area, buf, theme);
68 }
69
70 fn unknown(area: Rect, buf: &mut Buffer, theme: &Theme) {
71 ArtifactShelf::new(vec![
72 Artifact::new("Imported report", ArtifactKind::File, State::Unknown)
73 .detail("No verification reported")
74 .action("Inspect")
75 .receipt("Size", ReceiptValue::Bytes(None)),
76 Artifact::new("Check failed", ArtifactKind::Run, State::Failed)
77 .detail("The host reported an error")
78 .action("Read error"),
79 ])
80 .selected(0)
81 .paint(area, buf, theme);
82 }
83
84 fn empty(area: Rect, buf: &mut Buffer, theme: &Theme) {
85 ArtifactShelf::new(Vec::new()).paint(area, buf, theme);
86 }
87
88 pub(crate) fn entries() -> Vec<Entry> {
89 vec![
90 Entry {
91 name: "artifact",
92 width: 80,
93 height: 2,
94 draw: artifact,
95 },
96 Entry {
97 name: "artifact-shelf",
98 width: 80,
99 height: 8,
100 draw: shelf,
101 },
102 Entry {
103 name: "artifact-narrow",
104 width: 40,
105 height: 5,
106 draw: narrow,
107 },
108 Entry {
109 name: "artifact-unknown",
110 width: 80,
111 height: 4,
112 draw: unknown,
113 },
114 Entry {
115 name: "artifact-empty",
116 width: 40,
117 height: 2,
118 draw: empty,
119 },
120 ]
121 }
122
122 lines RUST