UNPKG

reviewit

Version:

A lightweight command-line tool that spins up a local web server to display Git commit diffs in a GitHub-like Files changed view

49 lines (48 loc) 1.7 kB
import React from 'react'; import { Box, Text } from 'ink'; const FileList = ({ files, selectedIndex }) => { const getStatusColor = (status) => { switch (status) { case 'A': return 'green'; case 'M': return 'yellow'; case 'D': return 'red'; default: return 'white'; } }; const getStatusLabel = (status) => { switch (status) { case 'A': return '[+]'; case 'M': return '[M]'; case 'D': return '[-]'; default: return '[?]'; } }; return (React.createElement(Box, { flexDirection: "column" }, React.createElement(Box, { marginBottom: 1 }, React.createElement(Text, { bold: true }, "Changed Files (", files.length, ")")), files.map((file, index) => (React.createElement(Box, { key: `${file.path}-${index}` }, React.createElement(Text, { color: index === selectedIndex ? 'cyan' : undefined, backgroundColor: index === selectedIndex ? 'gray' : undefined }, index === selectedIndex ? '▶ ' : ' ', React.createElement(Text, { color: getStatusColor(file.status) }, getStatusLabel(file.status)), ' ', file.path, ' ', React.createElement(Text, { dimColor: true }, "(+", file.additions, " -", file.deletions, ")"))))))); }; export default FileList;