File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
examples/counter-full-height Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { Box , render , Text } from '../../src/index.js' ;
3+
4+ function CounterFullHeight ( ) {
5+ const [ counter , setCounter ] = React . useState ( 0 ) ;
6+
7+ React . useEffect ( ( ) => {
8+ const timer = setInterval ( ( ) => {
9+ setCounter ( prevCounter => prevCounter + 1 ) ; // eslint-disable-line unicorn/prevent-abbreviations
10+ } , 100 ) ;
11+
12+ return ( ) => {
13+ clearInterval ( timer ) ;
14+ } ;
15+ } , [ ] ) ;
16+
17+ return (
18+ < Box borderStyle = "round" flexGrow = { 1 } >
19+ < Text color = "green" > { counter } tests passed</ Text >
20+ </ Box >
21+ ) ;
22+ }
23+
24+ render ( < CounterFullHeight /> , { fullHeight : true } ) ;
Original file line number Diff line number Diff line change 1+ import './counter-full-height.js' ;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export type Options = {
2424 debug : boolean ;
2525 exitOnCtrlC : boolean ;
2626 patchConsole : boolean ;
27+ fullHeight ?: boolean ;
2728 waitUntilExit ?: ( ) => Promise < void > ;
2829} ;
2930
@@ -130,6 +131,9 @@ export default class Ink {
130131 const terminalWidth = this . options . stdout . columns || 80 ;
131132
132133 this . rootNode . yogaNode ! . setWidth ( terminalWidth ) ;
134+ if ( this . options . fullHeight && this . options . stdout . rows ) {
135+ this . rootNode . yogaNode ! . setHeight ( this . options . stdout . rows ) ;
136+ }
133137
134138 this . rootNode . yogaNode ! . calculateLayout (
135139 undefined ,
Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ export type RenderOptions = {
4141 * @default true
4242 */
4343 patchConsole ?: boolean ;
44+ /**
45+ * If true, render output will use all avaliable height (rows)
46+ *
47+ * @default undefined
48+ */
49+ fullHeight ?: boolean ;
4450} ;
4551
4652export type Instance = {
You can’t perform that action at this time.
0 commit comments