File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ import React , { useState } from 'react'
2+
3+ import { Button } from './button'
4+ import { useTerminalDimensions } from '../hooks/use-terminal-dimensions'
5+ import { useTheme } from '../hooks/use-theme'
6+ import { BORDER_CHARS } from '../utils/ui-constants'
7+
8+ export interface BannerWrapperProps {
9+ color : string
10+ text : string
11+ onClose : ( ) => void
12+ }
13+
14+ export const BannerWrapper = ( { color, text, onClose } : BannerWrapperProps ) => {
15+ const { terminalWidth } = useTerminalDimensions ( )
16+ const theme = useTheme ( )
17+ const [ isCloseHovered , setIsCloseHovered ] = useState ( false )
18+
19+ const isWideTerminal = terminalWidth > 80
20+
21+ return (
22+ < box
23+ key = { terminalWidth }
24+ style = { {
25+ marginLeft : isWideTerminal ? 1 : 0 ,
26+ marginRight : isWideTerminal ? 1 : 0 ,
27+ borderStyle : 'single' ,
28+ borderColor : color ,
29+ flexDirection : 'row' ,
30+ justifyContent : 'space-between' ,
31+ paddingLeft : 1 ,
32+ paddingRight : 1 ,
33+ marginTop : 0 ,
34+ marginBottom : 0 ,
35+ } }
36+ border = { [ 'bottom' , 'left' , 'right' ] }
37+ customBorderChars = { BORDER_CHARS }
38+ >
39+ < text
40+ style = { {
41+ fg : color ,
42+ wrapMode : 'word' ,
43+ flexShrink : 1 ,
44+ marginRight : 3 ,
45+ } }
46+ >
47+ { text }
48+ </ text >
49+ < Button
50+ onClick = { onClose }
51+ onMouseOver = { ( ) => setIsCloseHovered ( true ) }
52+ onMouseOut = { ( ) => setIsCloseHovered ( false ) }
53+ >
54+ < text style = { { fg : isCloseHovered ? theme . error : theme . muted } } > x</ text >
55+ </ Button >
56+ </ box >
57+ )
58+ }
You can’t perform that action at this time.
0 commit comments