2
0

ScrollIndicator.tsx 723 B

1234567891011121314151617181920212223242526
  1. import { Box, Text } from "ink"
  2. import { memo } from "react"
  3. import * as theme from "../theme.js"
  4. interface ScrollIndicatorProps {
  5. scrollTop: number
  6. maxScroll: number
  7. isScrollFocused?: boolean
  8. }
  9. function ScrollIndicator({ scrollTop, maxScroll, isScrollFocused = false }: ScrollIndicatorProps) {
  10. // Calculate percentage - show 100% when at bottom or no scrolling needed.
  11. const percentage = maxScroll > 0 ? Math.round((scrollTop / maxScroll) * 100) : 100
  12. // Color changes based on focus state.
  13. const color = isScrollFocused ? theme.scrollActiveColor : theme.dimText
  14. return (
  15. <Box>
  16. <Text color={color}>{percentage}% • ↑↓ scroll • Ctrl+E end</Text>
  17. </Box>
  18. )
  19. }
  20. export default memo(ScrollIndicator)