termcast 1.3.48 → 1.3.49

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.
Files changed (255) hide show
  1. package/dist/build.d.ts.map +1 -1
  2. package/dist/build.js +12 -0
  3. package/dist/build.js.map +1 -1
  4. package/dist/cli.js +5 -40
  5. package/dist/cli.js.map +1 -1
  6. package/dist/colors.d.ts +7 -7
  7. package/dist/colors.js +7 -7
  8. package/dist/compile.d.ts +6 -1
  9. package/dist/compile.d.ts.map +1 -1
  10. package/dist/compile.js +45 -26
  11. package/dist/compile.js.map +1 -1
  12. package/dist/components/actions.js +1 -1
  13. package/dist/components/actions.js.map +1 -1
  14. package/dist/components/bar-chart.d.ts +38 -0
  15. package/dist/components/bar-chart.d.ts.map +1 -0
  16. package/dist/components/bar-chart.js +158 -0
  17. package/dist/components/bar-chart.js.map +1 -0
  18. package/dist/components/bar-graph.d.ts +41 -0
  19. package/dist/components/bar-graph.d.ts.map +1 -0
  20. package/dist/components/bar-graph.js +95 -0
  21. package/dist/components/bar-graph.js.map +1 -0
  22. package/dist/components/detail.d.ts.map +1 -1
  23. package/dist/components/detail.js +5 -7
  24. package/dist/components/detail.js.map +1 -1
  25. package/dist/components/footer.d.ts.map +1 -1
  26. package/dist/components/footer.js +8 -9
  27. package/dist/components/footer.js.map +1 -1
  28. package/dist/components/form/date-picker.d.ts.map +1 -1
  29. package/dist/components/form/date-picker.js +7 -1
  30. package/dist/components/form/date-picker.js.map +1 -1
  31. package/dist/components/form/dropdown.d.ts.map +1 -1
  32. package/dist/components/form/dropdown.js +10 -2
  33. package/dist/components/form/dropdown.js.map +1 -1
  34. package/dist/components/form/index.d.ts.map +1 -1
  35. package/dist/components/form/index.js +4 -5
  36. package/dist/components/form/index.js.map +1 -1
  37. package/dist/components/form/use-form-navigation.d.ts.map +1 -1
  38. package/dist/components/form/use-form-navigation.js +6 -0
  39. package/dist/components/form/use-form-navigation.js.map +1 -1
  40. package/dist/components/graph.d.ts +111 -0
  41. package/dist/components/graph.d.ts.map +1 -0
  42. package/dist/components/graph.js +392 -0
  43. package/dist/components/graph.js.map +1 -0
  44. package/dist/components/icon.js +5 -5
  45. package/dist/components/icon.js.map +1 -1
  46. package/dist/components/list.d.ts +53 -5
  47. package/dist/components/list.d.ts.map +1 -1
  48. package/dist/components/list.js +125 -71
  49. package/dist/components/list.js.map +1 -1
  50. package/dist/components/loading-bar.js +3 -3
  51. package/dist/components/loading-bar.js.map +1 -1
  52. package/dist/components/loading-text.d.ts +1 -1
  53. package/dist/components/loading-text.d.ts.map +1 -1
  54. package/dist/components/loading-text.js +3 -1
  55. package/dist/components/loading-text.js.map +1 -1
  56. package/dist/components/metadata.js +2 -2
  57. package/dist/components/metadata.js.map +1 -1
  58. package/dist/components/row.d.ts +10 -0
  59. package/dist/components/row.d.ts.map +1 -0
  60. package/dist/components/row.js +12 -0
  61. package/dist/components/row.js.map +1 -0
  62. package/dist/components/table.d.ts +57 -0
  63. package/dist/components/table.d.ts.map +1 -0
  64. package/dist/components/table.js +365 -0
  65. package/dist/components/table.js.map +1 -0
  66. package/dist/descendants.js +13 -13
  67. package/dist/descendants.js.map +1 -1
  68. package/dist/examples/bar-graph-weekly.d.ts +2 -0
  69. package/dist/examples/bar-graph-weekly.d.ts.map +1 -0
  70. package/dist/examples/bar-graph-weekly.js +95 -0
  71. package/dist/examples/bar-graph-weekly.js.map +1 -0
  72. package/dist/examples/components-weird-places.d.ts +2 -0
  73. package/dist/examples/components-weird-places.d.ts.map +1 -0
  74. package/dist/examples/components-weird-places.js +46 -0
  75. package/dist/examples/components-weird-places.js.map +1 -0
  76. package/dist/examples/graph-bar-chart.d.ts +2 -0
  77. package/dist/examples/graph-bar-chart.d.ts.map +1 -0
  78. package/dist/examples/graph-bar-chart.js +270 -0
  79. package/dist/examples/graph-bar-chart.js.map +1 -0
  80. package/dist/examples/graph-multi-series.d.ts +2 -0
  81. package/dist/examples/graph-multi-series.d.ts.map +1 -0
  82. package/dist/examples/graph-multi-series.js +23 -0
  83. package/dist/examples/graph-multi-series.js.map +1 -0
  84. package/dist/examples/graph-polymarket.d.ts +2 -0
  85. package/dist/examples/graph-polymarket.d.ts.map +1 -0
  86. package/dist/examples/graph-polymarket.js +109 -0
  87. package/dist/examples/graph-polymarket.js.map +1 -0
  88. package/dist/examples/graph-row.d.ts +2 -0
  89. package/dist/examples/graph-row.d.ts.map +1 -0
  90. package/dist/examples/graph-row.js +226 -0
  91. package/dist/examples/graph-row.js.map +1 -0
  92. package/dist/examples/graph-styles.d.ts +2 -0
  93. package/dist/examples/graph-styles.d.ts.map +1 -0
  94. package/dist/examples/graph-styles.js +316 -0
  95. package/dist/examples/graph-styles.js.map +1 -0
  96. package/dist/examples/list-accessory-table.d.ts +2 -0
  97. package/dist/examples/list-accessory-table.d.ts.map +1 -0
  98. package/dist/examples/list-accessory-table.js +46 -0
  99. package/dist/examples/list-accessory-table.js.map +1 -0
  100. package/dist/examples/list-item-accessories.d.ts +2 -0
  101. package/dist/examples/list-item-accessories.d.ts.map +1 -0
  102. package/dist/examples/list-item-accessories.js +27 -0
  103. package/dist/examples/list-item-accessories.js.map +1 -0
  104. package/dist/examples/list-no-actions.d.ts +2 -0
  105. package/dist/examples/list-no-actions.d.ts.map +1 -0
  106. package/dist/examples/list-no-actions.js +7 -0
  107. package/dist/examples/list-no-actions.js.map +1 -0
  108. package/dist/examples/simple-detail-table.d.ts +2 -0
  109. package/dist/examples/simple-detail-table.d.ts.map +1 -0
  110. package/dist/examples/simple-detail-table.js +45 -0
  111. package/dist/examples/simple-detail-table.js.map +1 -0
  112. package/dist/examples/simple-graph.d.ts +2 -0
  113. package/dist/examples/simple-graph.d.ts.map +1 -0
  114. package/dist/examples/simple-graph.js +32 -0
  115. package/dist/examples/simple-graph.js.map +1 -0
  116. package/dist/examples/simple-table-wrap.d.ts +2 -0
  117. package/dist/examples/simple-table-wrap.d.ts.map +1 -0
  118. package/dist/examples/simple-table-wrap.js +37 -0
  119. package/dist/examples/simple-table-wrap.js.map +1 -0
  120. package/dist/examples/table-edge-cases.d.ts +2 -0
  121. package/dist/examples/table-edge-cases.d.ts.map +1 -0
  122. package/dist/examples/table-edge-cases.js +70 -0
  123. package/dist/examples/table-edge-cases.js.map +1 -0
  124. package/dist/examples/table-flex-grow.d.ts +2 -0
  125. package/dist/examples/table-flex-grow.d.ts.map +1 -0
  126. package/dist/examples/table-flex-grow.js +18 -0
  127. package/dist/examples/table-flex-grow.js.map +1 -0
  128. package/dist/extensions/dev.d.ts.map +1 -1
  129. package/dist/extensions/dev.js +5 -1
  130. package/dist/extensions/dev.js.map +1 -1
  131. package/dist/globals.d.ts +1 -0
  132. package/dist/globals.d.ts.map +1 -1
  133. package/dist/globals.js +2 -0
  134. package/dist/globals.js.map +1 -1
  135. package/dist/index.d.ts +10 -0
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +10 -0
  138. package/dist/index.js.map +1 -1
  139. package/dist/internal/date-picker-widget.d.ts.map +1 -1
  140. package/dist/internal/date-picker-widget.js +4 -0
  141. package/dist/internal/date-picker-widget.js.map +1 -1
  142. package/dist/internal/providers.d.ts.map +1 -1
  143. package/dist/internal/providers.js +1 -3
  144. package/dist/internal/providers.js.map +1 -1
  145. package/dist/markdown-utils.d.ts +22 -1
  146. package/dist/markdown-utils.d.ts.map +1 -1
  147. package/dist/markdown-utils.js +66 -1
  148. package/dist/markdown-utils.js.map +1 -1
  149. package/dist/opentui.d.ts +4 -0
  150. package/dist/opentui.d.ts.map +1 -0
  151. package/dist/opentui.js +3 -0
  152. package/dist/opentui.js.map +1 -0
  153. package/dist/release.d.ts +2 -1
  154. package/dist/release.d.ts.map +1 -1
  155. package/dist/release.js +2 -1
  156. package/dist/release.js.map +1 -1
  157. package/dist/state.d.ts +1 -0
  158. package/dist/state.d.ts.map +1 -1
  159. package/dist/state.js +1 -1
  160. package/dist/state.js.map +1 -1
  161. package/dist/theme.d.ts +1 -0
  162. package/dist/theme.d.ts.map +1 -1
  163. package/dist/theme.js +13 -0
  164. package/dist/theme.js.map +1 -1
  165. package/dist/themes/nerv.json +227 -0
  166. package/dist/themes/termcast.json +72 -71
  167. package/dist/themes.d.ts +2 -1
  168. package/dist/themes.d.ts.map +1 -1
  169. package/dist/themes.js +7 -5
  170. package/dist/themes.js.map +1 -1
  171. package/dist/utils.d.ts.map +1 -1
  172. package/dist/utils.js +3 -0
  173. package/dist/utils.js.map +1 -1
  174. package/package.json +12 -4
  175. package/src/build.tsx +13 -0
  176. package/src/cli.tsx +5 -49
  177. package/src/colors.tsx +7 -7
  178. package/src/compile.tsx +52 -29
  179. package/src/components/actions.tsx +1 -1
  180. package/src/components/bar-chart.tsx +271 -0
  181. package/src/components/bar-graph.tsx +214 -0
  182. package/src/components/detail.tsx +7 -8
  183. package/src/components/footer.tsx +14 -15
  184. package/src/components/form/date-picker.tsx +9 -0
  185. package/src/components/form/dropdown.tsx +13 -3
  186. package/src/components/form/index.tsx +4 -6
  187. package/src/components/form/use-form-navigation.tsx +6 -0
  188. package/src/components/graph.tsx +506 -0
  189. package/src/components/icon.tsx +5 -5
  190. package/src/components/list.tsx +210 -102
  191. package/src/components/loading-bar.tsx +3 -3
  192. package/src/components/loading-text.tsx +4 -2
  193. package/src/components/metadata.tsx +2 -2
  194. package/src/components/row.tsx +31 -0
  195. package/src/components/table.tsx +511 -0
  196. package/src/descendants.tsx +13 -13
  197. package/src/examples/action-shortcut.vitest.tsx +1 -1
  198. package/src/examples/actions-context.vitest.tsx +1 -1
  199. package/src/examples/bar-graph-weekly.tsx +264 -0
  200. package/src/examples/bar-graph-weekly.vitest.tsx +275 -0
  201. package/src/examples/detail-metadata-showcase.vitest.tsx +8 -8
  202. package/src/examples/form-basic.vitest.tsx +239 -0
  203. package/src/examples/form-dropdown.vitest.tsx +29 -29
  204. package/src/examples/form-tagpicker.vitest.tsx +27 -27
  205. package/src/examples/github.vitest.tsx +4 -4
  206. package/src/examples/graph-bar-chart.tsx +408 -0
  207. package/src/examples/graph-bar-chart.vitest.tsx +283 -0
  208. package/src/examples/graph-multi-series.tsx +36 -0
  209. package/src/examples/graph-multi-series.vitest.tsx +89 -0
  210. package/src/examples/graph-polymarket.tsx +182 -0
  211. package/src/examples/graph-polymarket.vitest.tsx +130 -0
  212. package/src/examples/graph-row.tsx +347 -0
  213. package/src/examples/graph-row.vitest.tsx +295 -0
  214. package/src/examples/graph-styles.tsx +457 -0
  215. package/src/examples/graph-styles.vitest.tsx +322 -0
  216. package/src/examples/list-accessory-table.tsx +77 -0
  217. package/src/examples/list-detail-metadata.vitest.tsx +21 -21
  218. package/src/examples/list-dropdown-default.vitest.tsx +12 -12
  219. package/src/examples/list-item-accessories.tsx +106 -0
  220. package/src/examples/list-item-accessories.vitest.tsx +115 -0
  221. package/src/examples/list-no-actions.tsx +18 -0
  222. package/src/examples/list-no-actions.vitest.tsx +97 -0
  223. package/src/examples/list-spacing-mode.vitest.tsx +6 -6
  224. package/src/examples/list-with-detail.vitest.tsx +92 -92
  225. package/src/examples/list-with-dropdown.vitest.tsx +49 -6
  226. package/src/examples/list-with-sections.vitest.tsx +61 -56
  227. package/src/examples/simple-detail-markdown.vitest.tsx +21 -17
  228. package/src/examples/simple-detail-table.tsx +65 -0
  229. package/src/examples/simple-detail-table.vitest.tsx +200 -0
  230. package/src/examples/simple-graph.tsx +51 -0
  231. package/src/examples/simple-graph.vitest.tsx +124 -0
  232. package/src/examples/simple-grid.vitest.tsx +3 -3
  233. package/src/examples/simple-list-search.vitest.tsx +65 -0
  234. package/src/examples/simple-navigation.vitest.tsx +3 -3
  235. package/src/examples/simple-table-wrap.tsx +55 -0
  236. package/src/examples/simple-table-wrap.vitest.tsx +91 -0
  237. package/src/examples/store.vitest.tsx +1 -1
  238. package/src/examples/table-edge-cases.tsx +72 -0
  239. package/src/examples/table-edge-cases.vitest.tsx +307 -0
  240. package/src/examples/table-flex-grow.tsx +53 -0
  241. package/src/examples/table-flex-grow.vitest.tsx +124 -0
  242. package/src/extensions/dev.tsx +7 -1
  243. package/src/globals.ts +3 -0
  244. package/src/index.tsx +31 -0
  245. package/src/internal/date-picker-widget.tsx +4 -0
  246. package/src/internal/providers.tsx +1 -4
  247. package/src/markdown-utils.tsx +82 -1
  248. package/src/opentui.tsx +5 -0
  249. package/src/release.tsx +3 -0
  250. package/src/state.tsx +2 -1
  251. package/src/theme.tsx +14 -0
  252. package/src/themes/nerv.json +231 -0
  253. package/src/themes/termcast.json +75 -71
  254. package/src/themes.ts +8 -5
  255. package/src/utils.tsx +4 -0
@@ -0,0 +1,457 @@
1
+ // Example: Graph variants and color combinations showcase.
2
+ // Demonstrates all three variants (area, filled, striped) with various
3
+ // color schemes, theme defaults, multi-series charts, and detail views
4
+ // combining graphs with metadata and markdown.
5
+
6
+ import React from 'react'
7
+ import { List, Detail, Graph, Color, Action, ActionPanel } from 'termcast'
8
+ import { useNavigation } from 'termcast/src/internal/navigation'
9
+ import { renderWithProviders } from '../utils'
10
+
11
+ // ── Data sets ────────────────────────────────────────────────────────
12
+
13
+ const stockPrices = [
14
+ 150, 155, 148, 162, 158, 165, 170, 168, 175, 180,
15
+ 178, 185, 190, 188, 195, 192, 198, 202, 200, 208,
16
+ ]
17
+ const cpuUsage = [
18
+ 25, 30, 45, 60, 55, 72, 80, 65, 50, 40,
19
+ 35, 55, 70, 85, 90, 75, 60, 45, 38, 30,
20
+ ]
21
+ const memoryUsage = [
22
+ 40, 42, 44, 48, 52, 55, 58, 60, 62, 65,
23
+ 68, 70, 72, 74, 76, 78, 80, 82, 84, 86,
24
+ ]
25
+ const revenue = [
26
+ 10, 15, 12, 18, 25, 22, 30, 35, 28, 40,
27
+ 45, 42, 50, 55, 60, 58, 65, 70, 68, 75,
28
+ ]
29
+ const temperature = [
30
+ 15, 14, 16, 18, 22, 25, 28, 30, 29, 27,
31
+ 24, 20, 17, 15, 14, 16, 19, 23, 26, 28,
32
+ ]
33
+ const sineWave = Array.from({ length: 20 }, (_, i) => {
34
+ return Math.sin(i * 0.5) * 40 + 50
35
+ })
36
+ const cosWave = Array.from({ length: 20 }, (_, i) => {
37
+ return Math.cos(i * 0.5) * 40 + 50
38
+ })
39
+
40
+ const stockLabels = ['1', '5', '10', '15', '20']
41
+ const monthLabels = ['Jan', 'Apr', 'Jul', 'Oct']
42
+ const hourLabels = ['0h', '6h', '12h', '18h', '24h']
43
+
44
+ // ── Item definitions ─────────────────────────────────────────────────
45
+
46
+ interface GraphItem {
47
+ title: string
48
+ subtitle: string
49
+ variant: 'area' | 'filled' | 'striped'
50
+ series: Array<{ data: number[]; color?: Color.ColorLike }>
51
+ xLabels: string[]
52
+ yRange?: [number, number]
53
+ yTicks?: number
54
+ stripeColors?: [Color.ColorLike, Color.ColorLike]
55
+ markdown?: string
56
+ meta: Array<{ title: string; text: string; color?: Color.ColorLike }>
57
+ tags?: Array<{ text: string; color: Color.ColorLike }>
58
+ }
59
+
60
+ const items: GraphItem[] = [
61
+ // ── Area variants ──────────────────────────────────────────
62
+ {
63
+ title: 'Area - Stock Price',
64
+ subtitle: 'Orange braille dots',
65
+ variant: 'area',
66
+ series: [{ data: stockPrices, color: Color.Orange }],
67
+ xLabels: stockLabels,
68
+ meta: [
69
+ { title: 'Variant', text: 'area' },
70
+ { title: 'Color', text: 'Orange', color: Color.Orange },
71
+ { title: 'Points', text: '20' },
72
+ ],
73
+ },
74
+ {
75
+ title: 'Area - Multi Series',
76
+ subtitle: 'CPU + Memory overlay',
77
+ variant: 'area',
78
+ series: [
79
+ { data: cpuUsage, color: Color.Blue },
80
+ { data: memoryUsage, color: Color.Green },
81
+ ],
82
+ xLabels: hourLabels,
83
+ yRange: [0, 100],
84
+ yTicks: 5,
85
+ markdown: [
86
+ '## System Metrics',
87
+ '',
88
+ 'CPU usage (blue) vs memory usage (green) over 24 hours.',
89
+ '',
90
+ '- Peak CPU at **90%** around 15h',
91
+ '- Memory steadily climbing to **86%**',
92
+ '- CPU has high variance, memory is monotonic',
93
+ ].join('\n'),
94
+ meta: [
95
+ { title: 'CPU Peak', text: '90%', color: Color.Blue },
96
+ { title: 'Mem Peak', text: '86%', color: Color.Green },
97
+ ],
98
+ tags: [
99
+ { text: 'CPU', color: Color.Blue },
100
+ { text: 'Memory', color: Color.Green },
101
+ ],
102
+ },
103
+ {
104
+ title: 'Area - Waves',
105
+ subtitle: 'Purple + Magenta sine/cosine',
106
+ variant: 'area',
107
+ series: [
108
+ { data: sineWave, color: Color.Purple },
109
+ { data: cosWave, color: Color.Magenta },
110
+ ],
111
+ xLabels: ['0', '\u03C0', '2\u03C0', '3\u03C0'],
112
+ yRange: [0, 100],
113
+ meta: [
114
+ { title: 'Functions', text: 'sin(x), cos(x)' },
115
+ { title: 'Phase', text: '\u03C0/2 offset' },
116
+ { title: 'Points', text: '20' },
117
+ ],
118
+ tags: [
119
+ { text: 'sin', color: Color.Purple },
120
+ { text: 'cos', color: Color.Magenta },
121
+ ],
122
+ },
123
+ {
124
+ title: 'Area - Blue Revenue',
125
+ subtitle: 'Single series, auto range',
126
+ variant: 'area',
127
+ series: [{ data: revenue, color: Color.Blue }],
128
+ xLabels: monthLabels,
129
+ meta: [
130
+ { title: 'Color', text: 'Blue', color: Color.Blue },
131
+ { title: 'Min', text: '$10k' },
132
+ { title: 'Max', text: '$75k' },
133
+ ],
134
+ },
135
+
136
+ // ── Filled variants ────────────────────────────────────────
137
+ {
138
+ title: 'Filled - Red Revenue',
139
+ subtitle: 'Solid block growth chart',
140
+ variant: 'filled',
141
+ series: [{ data: revenue, color: Color.Red }],
142
+ xLabels: monthLabels,
143
+ markdown: [
144
+ '## Revenue Growth',
145
+ '',
146
+ 'Quarterly revenue from **$10k** to **$75k**.',
147
+ '',
148
+ '```',
149
+ 'Q1: $10k \u2192 Q2: $25k (+150%)',
150
+ 'Q2: $25k \u2192 Q3: $50k (+100%)',
151
+ 'Q3: $50k \u2192 Q4: $75k (+50%)',
152
+ '```',
153
+ ].join('\n'),
154
+ meta: [
155
+ { title: 'Growth', text: '+650%', color: Color.Green },
156
+ { title: 'Color', text: 'Red', color: Color.Red },
157
+ ],
158
+ },
159
+ {
160
+ title: 'Filled - Green Temp',
161
+ subtitle: 'Daily temperature curve',
162
+ variant: 'filled',
163
+ series: [{ data: temperature, color: Color.Green }],
164
+ xLabels: hourLabels,
165
+ yRange: [10, 35],
166
+ yTicks: 6,
167
+ meta: [
168
+ { title: 'Min', text: '14\u00B0C', color: Color.Blue },
169
+ { title: 'Max', text: '30\u00B0C', color: Color.Red },
170
+ { title: 'Avg', text: '21\u00B0C', color: Color.Green },
171
+ ],
172
+ },
173
+ {
174
+ title: 'Filled - Yellow CPU',
175
+ subtitle: 'High contrast on dark',
176
+ variant: 'filled',
177
+ series: [{ data: cpuUsage, color: Color.Yellow }],
178
+ xLabels: hourLabels,
179
+ yRange: [0, 100],
180
+ meta: [
181
+ { title: 'Color', text: 'Yellow', color: Color.Yellow },
182
+ { title: 'Peak', text: '90%' },
183
+ { title: 'Avg', text: '54%' },
184
+ ],
185
+ },
186
+ {
187
+ title: 'Filled - Magenta Waves',
188
+ subtitle: 'Smooth curve with blocks',
189
+ variant: 'filled',
190
+ series: [{ data: sineWave, color: Color.Magenta }],
191
+ xLabels: ['0', '\u03C0', '2\u03C0', '3\u03C0'],
192
+ yRange: [0, 100],
193
+ meta: [
194
+ { title: 'Color', text: 'Magenta', color: Color.Magenta },
195
+ { title: 'Range', text: '10\u201390' },
196
+ ],
197
+ },
198
+
199
+ // ── Striped variants ───────────────────────────────────────
200
+ {
201
+ title: 'Striped - Purple/Orange',
202
+ subtitle: 'Warm alternating colors',
203
+ variant: 'striped',
204
+ series: [{ data: stockPrices }],
205
+ xLabels: stockLabels,
206
+ stripeColors: [Color.Purple, Color.Orange],
207
+ meta: [
208
+ { title: 'Even cols', text: 'Purple', color: Color.Purple },
209
+ { title: 'Odd cols', text: 'Orange', color: Color.Orange },
210
+ ],
211
+ tags: [
212
+ { text: 'Purple', color: Color.Purple },
213
+ { text: 'Orange', color: Color.Orange },
214
+ ],
215
+ },
216
+ {
217
+ title: 'Striped - Blue/Red',
218
+ subtitle: 'High contrast stripes',
219
+ variant: 'striped',
220
+ series: [{ data: revenue }],
221
+ xLabels: monthLabels,
222
+ stripeColors: [Color.Blue, Color.Red],
223
+ markdown: [
224
+ '## Stripe Colors',
225
+ '',
226
+ 'Pass `stripeColors` as a tuple of two colors.',
227
+ 'Even columns get the first color, odd columns the second.',
228
+ '',
229
+ '```tsx',
230
+ 'stripeColors={[Color.Blue, Color.Red]}',
231
+ '```',
232
+ ].join('\n'),
233
+ meta: [
234
+ { title: 'Color 1', text: 'Blue', color: Color.Blue },
235
+ { title: 'Color 2', text: 'Red', color: Color.Red },
236
+ ],
237
+ },
238
+ {
239
+ title: 'Striped - Theme Default',
240
+ subtitle: 'primary + accent (no prop)',
241
+ variant: 'striped',
242
+ series: [{ data: cpuUsage }],
243
+ xLabels: hourLabels,
244
+ yRange: [0, 100],
245
+ // no stripeColors → defaults to theme.primary + theme.accent
246
+ markdown: [
247
+ '## Theme Colors',
248
+ '',
249
+ 'When `stripeColors` is omitted the graph',
250
+ 'defaults to **theme.primary** and **theme.accent**.',
251
+ '',
252
+ 'Switch themes to see different combinations.',
253
+ ].join('\n'),
254
+ meta: [
255
+ { title: 'Color 1', text: 'theme.primary' },
256
+ { title: 'Color 2', text: 'theme.accent' },
257
+ ],
258
+ },
259
+ {
260
+ title: 'Striped - Green/Yellow',
261
+ subtitle: 'Nature-inspired',
262
+ variant: 'striped',
263
+ series: [{ data: sineWave }],
264
+ xLabels: ['0', '\u03C0', '2\u03C0', '3\u03C0'],
265
+ yRange: [0, 100],
266
+ stripeColors: [Color.Green, Color.Yellow],
267
+ meta: [
268
+ { title: 'Color 1', text: 'Green', color: Color.Green },
269
+ { title: 'Color 2', text: 'Yellow', color: Color.Yellow },
270
+ ],
271
+ },
272
+ {
273
+ title: 'Striped - Red/Magenta',
274
+ subtitle: 'Warm gradient feel',
275
+ variant: 'striped',
276
+ series: [{ data: temperature }],
277
+ xLabels: hourLabels,
278
+ yRange: [10, 35],
279
+ stripeColors: [Color.Red, Color.Magenta],
280
+ meta: [
281
+ { title: 'Color 1', text: 'Red', color: Color.Red },
282
+ { title: 'Color 2', text: 'Magenta', color: Color.Magenta },
283
+ { title: 'Min', text: '14\u00B0C' },
284
+ { title: 'Max', text: '30\u00B0C' },
285
+ ],
286
+ },
287
+ {
288
+ title: 'Striped - Blue/Green',
289
+ subtitle: 'Cool tones memory chart',
290
+ variant: 'striped',
291
+ series: [{ data: memoryUsage }],
292
+ xLabels: hourLabels,
293
+ yRange: [30, 90],
294
+ stripeColors: [Color.Blue, Color.Green],
295
+ markdown: [
296
+ '## Memory Trend',
297
+ '',
298
+ 'Steady climb from **40%** to **86%** over 24h.',
299
+ 'Blue/green stripes give a cool-toned look.',
300
+ ].join('\n'),
301
+ meta: [
302
+ { title: 'Start', text: '40%' },
303
+ { title: 'End', text: '86%' },
304
+ { title: 'Trend', text: 'monotonic rise', color: Color.Green },
305
+ ],
306
+ },
307
+ ]
308
+
309
+ // ── Full Detail view (pushed on Enter) ───────────────────────────────
310
+
311
+ function GraphDetailView({ item }: { item: GraphItem }): any {
312
+ const { pop } = useNavigation()
313
+
314
+ const markdown = [
315
+ `# ${item.title}`,
316
+ '',
317
+ item.subtitle,
318
+ '',
319
+ ...(item.markdown ? [item.markdown, ''] : []),
320
+ `**Variant:** \`${item.variant}\` `,
321
+ `**Data points:** ${item.series[0]?.data.length ?? 0} `,
322
+ ...(item.stripeColors ? [`**Stripe colors:** custom pair`] : []),
323
+ ].join('\n')
324
+
325
+ return (
326
+ <Detail
327
+ navigationTitle={item.title}
328
+ markdown={markdown}
329
+ metadata={
330
+ <Detail.Metadata>
331
+ <Graph
332
+ variant={item.variant}
333
+ height={15}
334
+ xLabels={item.xLabels}
335
+ yRange={item.yRange}
336
+ yTicks={item.yTicks ?? 5}
337
+ yFormat={(v) => v.toFixed(0)}
338
+ stripeColors={item.stripeColors}
339
+ >
340
+ {item.series.map((s, si) => {
341
+ return <Graph.Line key={si} data={s.data} color={s.color} />
342
+ })}
343
+ </Graph>
344
+ <Detail.Metadata.Separator />
345
+ {item.meta.map((m) => {
346
+ return (
347
+ <Detail.Metadata.Label
348
+ key={m.title}
349
+ title={m.title}
350
+ text={m.color ? { value: m.text, color: m.color } : m.text}
351
+ />
352
+ )
353
+ })}
354
+ {Boolean(item.tags) && (
355
+ <>
356
+ <Detail.Metadata.Separator />
357
+ <Detail.Metadata.TagList title="Colors">
358
+ {item.tags!.map((t) => {
359
+ return (
360
+ <Detail.Metadata.TagList.Item
361
+ key={t.text}
362
+ text={t.text}
363
+ color={t.color}
364
+ />
365
+ )
366
+ })}
367
+ </Detail.Metadata.TagList>
368
+ </>
369
+ )}
370
+ </Detail.Metadata>
371
+ }
372
+ actions={
373
+ <ActionPanel>
374
+ <Action title="Go Back" onAction={() => { pop() }} />
375
+ </ActionPanel>
376
+ }
377
+ />
378
+ )
379
+ }
380
+
381
+ // ── Main list ────────────────────────────────────────────────────────
382
+
383
+ function GraphStylesExample() {
384
+ const { push } = useNavigation()
385
+
386
+ return (
387
+ <List navigationTitle="Graph Styles" isShowingDetail={true}>
388
+ {items.map((item) => {
389
+ return (
390
+ <List.Item
391
+ key={item.title}
392
+ title={item.title}
393
+ subtitle={item.subtitle}
394
+ detail={
395
+ <List.Item.Detail
396
+ markdown={item.markdown}
397
+ metadata={
398
+ <List.Item.Detail.Metadata>
399
+ <Graph
400
+ variant={item.variant}
401
+ height={10}
402
+ xLabels={item.xLabels}
403
+ yRange={item.yRange}
404
+ yTicks={item.yTicks ?? 4}
405
+ yFormat={(v) => v.toFixed(0)}
406
+ stripeColors={item.stripeColors}
407
+ >
408
+ {item.series.map((s, si) => {
409
+ return <Graph.Line key={si} data={s.data} color={s.color} />
410
+ })}
411
+ </Graph>
412
+ <List.Item.Detail.Metadata.Separator />
413
+ {item.meta.map((m) => {
414
+ return (
415
+ <List.Item.Detail.Metadata.Label
416
+ key={m.title}
417
+ title={m.title}
418
+ text={m.color ? { value: m.text, color: m.color } : m.text}
419
+ />
420
+ )
421
+ })}
422
+ {Boolean(item.tags) && (
423
+ <>
424
+ <List.Item.Detail.Metadata.Separator />
425
+ <List.Item.Detail.Metadata.TagList title="Colors">
426
+ {item.tags!.map((t) => {
427
+ return (
428
+ <List.Item.Detail.Metadata.TagList.Item
429
+ key={t.text}
430
+ text={t.text}
431
+ color={t.color}
432
+ />
433
+ )
434
+ })}
435
+ </List.Item.Detail.Metadata.TagList>
436
+ </>
437
+ )}
438
+ </List.Item.Detail.Metadata>
439
+ }
440
+ />
441
+ }
442
+ actions={
443
+ <ActionPanel>
444
+ <Action
445
+ title="Open Detail"
446
+ onAction={() => { push(<GraphDetailView item={item} />) }}
447
+ />
448
+ </ActionPanel>
449
+ }
450
+ />
451
+ )
452
+ })}
453
+ </List>
454
+ )
455
+ }
456
+
457
+ renderWithProviders(<GraphStylesExample />)