jonmbake / react-terminal-ui

A terminal react component with support for light and dark modes.
https://jonmbake.github.io/react-terminal-ui/demo/
MIT License
214 stars 33 forks source link

Allow overriding default height #24

Closed FaresKi closed 1 year ago

FaresKi commented 2 years ago

Is your feature request related to a problem? Please describe. I'm trying to make my terminal full screen, unlike the way it currently is:

image

Describe the solution you'd like From a quick glance in your repo, it seems that the style.css limits the width and the height for the terminal itself, I'd like to have the option to provide a css or at least properties with the Terminal component. Describe alternatives you've considered Tried providing my own css, it got overridden by the default one.

jonmbake commented 2 years ago

Terminal width is set to 100% by default. Is the issue only with the height? (Height is set to 600px by default).

antanasramana commented 1 year ago

It is impossible to override height. Is it possible for you to change the default height to 100% so the terminal height would be controlled by the element that contains it?

jonmbake commented 1 year ago

@antanasramana There is not a great way to override the height right now. It would require a small update to make it easier.

drageelr commented 1 year ago

If anyone's still looking for a work around, I solved the problem by using a useEffect hook as follows:

useEffect(() => {
  if (wrapperDiv === undefined) {
    wrapperDiv = document.getElementsByClassName('react-terminal-wrapper')[0];
    wrapperDiv.setAttribute('style', `height: ${HEIGHT};`);
  }
});

However, I think a better solution would be to allow a height prop to be passed to the Terminal component that sets the wrapper-div's height @jonmbake.

drageelr commented 1 year ago

@jonmbake the height prop should be applied to the outermost div (the one who's class is react-terminal-wrapper), not the one inside it I think.

jonmbake commented 1 year ago

@drageelr I basically moved height from the .react-terminal style.css rule to a prop.

It seems to work from my testing:

 <Terminal name='React Terminal UI' colorMode={ colorMode }  onInput={ onInput } height="1000px">
  {lineData}
</Terminal>

Renders a 1000px height terminal:

Screenshot 2023-02-04 at 5 37 46 AM

Can you upgrade to v1.0.1 and try it out?

drageelr commented 1 year ago

Yes, tested it out. It's working. Great job!