terminal-emulator-wc

1.0.0 • Public • Published

Terminal Emulator WebComponent

Example

How It Works

Use the insertTerminalEmulator function to provide the querySelector for where the emulator should be inserted, and the array of commands you would like to have the terminal mock execution for. Each command consists of three parts, path, input, and results. The path is what will be shown as the current path, the input is the mock terminal input and the results, is what the execution of the input returns. Note that results can be an empty array for commands like cd.

Example:

    import { insertTerminalEmulator } from 'terminal-emulator-wc';
    
    const terminalLines = [
            {
                path: '~/Jon/Skills',
                input: 'ls',
                results: ['React', 'JavaScript', 'GraphQL', 'Node', 'HTML', 'CSS', 'SCSS', 'Web-Components', 'Ruby', 'Swift', 'SwiftUI'],
            },
            {
                path: '~/Jon/Skills',
                input: 'cd ..',
                results: [],
            }
        ];
     insertTerminalEmulator({ querySelector: '#terminal', terminalLines, disableFontInsertion: false }));

Important Notes

  • The terminal will add scroll bars if the content gets too tall and will automatically scroll to the bottom
  • The font the terminal uses is Inconsolata. The terminal emulator will insert a link to the Google Font for you. If you already have this font, you can disable the auto insertion of the font by sending disableFontInsertion as true.

Package Sidebar

Install

npm i terminal-emulator-wc

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

14.3 kB

Total Files

3

Last publish

Collaborators

  • jonrosedev