react-terminal-ui icon indicating copy to clipboard operation
react-terminal-ui copied to clipboard

How to override default style

Open FaresKi opened this issue 3 years ago • 1 comments

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.

FaresKi avatar Jul 02 '22 17:07 FaresKi

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

jonmbake avatar Jul 03 '22 17:07 jonmbake

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?

antanasramana avatar Jan 11 '23 11:01 antanasramana

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

jonmbake avatar Jan 18 '23 02:01 jonmbake

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 avatar Feb 03 '23 18:02 drageelr

@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.

drageelr avatar Feb 04 '23 09:02 drageelr

@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?

jonmbake avatar Feb 04 '23 11:02 jonmbake

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

drageelr avatar Feb 04 '23 14:02 drageelr