Coder Social home page Coder Social logo

ggregoire / react-ladda Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jsdir/react-ladda

1.0 3.0 0.0 81 KB

react-ladda that works in create-react-app v2. See this comment to install it: https://github.com/jsdir/react-ladda/pull/58#issue-219793321

License: MIT License

HTML 2.01% JavaScript 93.42% CSS 4.57%

react-ladda's Introduction

react-ladda

Build Status Dependency Status NPM version Code Climate

A React wrapper for Ladda buttons. Example

Installation

react-ladda can be installed directly through npm:

$ npm install --save react-ladda

Usage

LaddaButton is a React component that renders a Ladda button. You can change the button's loading state and progress using the loading and progress props.

import React, { Component } from 'react';

import LaddaButton, { XL, SLIDE_UP } from 'react-ladda';

class App extends Component {

  state = { loading: false };

  toggle() {
    this.setState({
      loading: !this.state.loading,
      progress: 0.5,
    });
  }

  render() {
    return (
      <LaddaButton
        loading={this.state.loading}
        onClick={this.toggle}
        data-color="#eee"
        data-size={XL}
        data-style={SLIDE_UP}
        data-spinner-size={30}
        data-spinner-color="#ddd"
        data-spinner-lines={12}
      >
        Click Here!
      </LaddaButton>
    );
  }
};

ReactDOM.render(<App />, document.body);

Although this package doesn't include the styles for the Ladda buttons, there are many different ways to include them. The easiest way is to add the following tag to your document:

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/Ladda/1.0.0/ladda.min.css">

Props

All of the native Ladda button options are supported through props:

Prop Type Description
loading boolean Displays the button's loading indicator
progress number Number from 0.0 to 1.0
data-color string Color applied to the button ({green,red,blue,purple,mint})
data-size string A button size
data-style string A button style
data-spinner-size number Number representing the size of the spinner in pixels
data-spinner-color string Color applied to the spinner (eg. #eee)
data-spinner-lines number Number of spokes in the spinner

Sizes and Styles

Ladda comes with a variety of different sizes and styles that you can use. Button sizes and styles can be directly imported from react-ladda:

import LaddaButton, { XS, EXPAND_LEFT } from 'react-ladda'

Sizes

  • XS
  • S
  • L
  • XL

Styles

  • CONTRACT
  • CONTRACT_OVERLAY
  • EXPAND_LEFT
  • EXPAND_RIGHT
  • EXPAND_UP
  • EXPAND_DOWN
  • SLIDE_LEFT
  • SLIDE_RIGHT
  • SLIDE_UP
  • SLIDE_DOWN
  • ZOOM_IN
  • ZOOM_OUT

Development

After cloning and running npm install, you can use the following npm commands for easier development:

Command Description
npm test Runs the test suite
npm run watch Runs the test suite and reruns when any source or test file changes
npm run lint Lints both the source and test files
npm run build Compiles the source into ES5 and outputs the results into dist

Contributions are more than welcome!

react-ladda's People

Contributors

darmody avatar darthwade avatar dbunker avatar foxxmd avatar ggregoire avatar iswanj avatar jmartin84 avatar jsdir avatar kevnz avatar mokone91 avatar oliger avatar rbinksy avatar xakep139 avatar zachdixon avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.