GithubHelp home page GithubHelp logo

rhysd / react-embedded-browser Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 9.0 152 KB

Embedded browser like mobile apps for React and Electron

License: MIT License

CSS 21.27% HTML 10.30% JavaScript 15.14% TypeScript 53.28%

react-embedded-browser's Introduction

React Embedded Browser Component for Electron

This is a React.js component to provide an embedded browser like mobile apps. This component is assumed to be used in Electron app.

screenshot

Usage

You can try the example in this repository;

Insall as npm package

$ npm install react-embedded-browser

You can use default.css and EmbeddedBrowser component as below:

import React from 'react';
import EmbeddedBrowser from 'react-embedded-browser';

React.render(
    <div>
        <button onClick={show}>push me</button>
        <EmbeddedBrowser />
    </div>,
    document.body
);

And you can open URL with open() method of DOM node of <EmbeddedBrowser/>.

let browser = document.querySelector('.embedded-browser');
browser.open('https://example.com');

Note: Only one embedded browser can exist in the app.

Note: <EmbeddedBrowser> depends on FontAwesome. Please be sure to install it in your project.

Customization

If you only want to change the design of embedded browser, prepare your favorite CSS file and simply use it. You can copy the default.css and modify it.

If you want to arrange the back/forward buttons, external buttons, title and webview, you can use the each components and you can make your own embedded browser as you like. Please use <BackButton>, <ForwardButton>, <PageTitle>, <ExternalButton> and <BrowserBody> as below. Note that each elements don't depend on FontAwesome.

import {BackButton ForwardButton PageTitle ExternalButton BrowserBody} from 'react-embedded-browser';

React.render(
        <div className="my-so-cool-browser">
            <div className="my-so-cool-title-bar">
                <BackButton className="page-back">
                    Back!
                </BackButton>
                <ForwardButton className="page-forward">
                    Forward!
                </ForwardButton>
                <PageTitle className="page-title"/>
                <ExternalButton className="page-external">
                    Open in external browser!
                </ExternalButton>
            </div>
            <BrowserBody className="page-body" ref="body"/>
        </div>,
        document.body
    );

To tell which URL should be open, you can use open() method in <BrowserBody/> DOM node.

License

This repository is licensed under the MIT License.

react-embedded-browser's People

Contributors

rhysd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-embedded-browser's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.