1.0.1 • Published 7 years ago
terminal-for-react v1.0.1
Terminal for React
A fun terminal component for ReactJS.
Table of contents
Install
npm install terminal-for-react --saveor if you use yarn
yarn add terminal-for-reactThis package is created with react so make sure you have it installed.
Usage
import React, { Component } from 'react';
import Terminal from 'terminal-for-react';
class App extends Component {
// supports images!
render() {
return(
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100vh",
width: "100vw"
}}
>
<Terminal
style={{
fontWeight: "bold",
fontSize: "1em"
}}
backgroundColor='#000000'
barBackgroundColor='#000000'
barColor='#007705'
color='#007705'
initialMessage='hello welcome to custom properties'
title='terminal-for-react'
commands={{
help: 'commands: [help, icon, clear]',
icon: 'https://i.imgur.com/fj9gWRB.png'
}}
errorText='this command doesn\'t exist!'
/>
</div>
);
}
}
export default App;Working
Adding commands
To add your own command, use prop commands which accepts an object. This objects then maps command name -> <img> or <pre>.
Let's take an example. You want to display an image, with command name icon.
<Terminal commands={{ icon: 'https://i.imgur.com/fj9gWRB.png')}} />Customization
Use
- prop
colorto change the color of the text. - prop
backgroundColorto change the background color. - prop
barBackgroundColorto change the background color of bar. - prop
barColorto change the color of bar. - prop
initialMessageto change the initial message. - prop
commandsto change the commands. - prop
titleto change the title of the terminal. - prop
errorTextto change the error text of the terminal.
API
component props
| Props | Type | Default |
|---|---|---|
| color | string | 'green' |
| backgroundColor | string | 'black' |
| barBackgroundColor | string | 'black' |
| barColor | string | 'green' |
| initialMessage | string | 'run the \'help\' command for a list of commands.' |
| commands | object | { clear, help, icon } |
| title | string | 'terminal-for-react' |
| errorText | string | 'This command doesn\'t exist' |
Built-in commands
clear- Clears the screenhelp- List all the commandsicon- Shows the app icon
Where to use ?
- You can use this on your website.
- I used it on my about me page on my portfolio
- play around with it