Git Product home page Git Product logo

react-splash's Introduction

React Splash

Easily add splash images with animated text to React web sites. Requires React and CSS flexbox browser support.

Live Demo - The big image on the front page with the animated words "Solar League" written over it.

tl;dr

In the command prompt run:

npm install react-splash --save

Import all necessary modules:

import Splash from 'react-splash';

Somewhere in your render method:

<Splash 
  text="Project Name" 
  src="https://source.unsplash.com/FxU8KV7psMY/1600x900" 
  style={{ height: '70vh' }}
/>

Documentation

Properties

  • text string Animated text covering the splash image. At the moment, the maximum is two words only. Defaults to "React Splash". Optional.

  • src string Image source for the splash image. Defaults to "https://source.unsplash.com/weekly". Optional.

  • style object React inline styles object. Useful for setting splash image height. Defaults to { height: '100vh' }. Optional.

Children

Children are ignored.

Universal Rendering

This component is compatible with universal or server side rendering (SSR).

Step by Step Instructions

In order to start from scratch we'll use Facebook react starter kit called Create React App. In the command prompt type:

npm install -g create-react-app

create-react-app my-app
cd my-app/
npm install react-splash --save
subl src/App.js #open with Sublime Text. Or use any other text editor.
npm start

Copy and paste the following code into app.js:

import React, { Component } from 'react';
import Splash from 'react-splash';
import logo from './logo.svg';
import './App.css';

class App extends Component {
  render() {
    return (
      <div className="App">
        <Splash 
          text="Project Name" 
          src="https://source.unsplash.com/FxU8KV7psMY/1600x900" 
          style={{ height: '60vh' }}
        />
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
      </div>
    );
  }
}

export default App;

Save it, then open http://localhost:3000/ to see the result.

Forking This Package

Clone the this repository using the following command:

git clone https://github.com/rnosov/react-splash.git

In the cloned directory, you can run following commands:

npm install

Installs required node modules

npm run build

Builds the package for production to the dist folder

npm test

Runs tests

License

Copyright © 2016 Roman Nosov. This source code is licensed under the MIT license.

react-splash's People

Contributors

rnosov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nathanieltalbot

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.