1.0.21 • Published 2 years ago

@naschpitz/button-enhanced v1.0.21

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@naschpitz/button-enhanced

A button using React.js and Bootstrap 4 that will display a click confirmation pop-up.

NPM JavaScript Style Guide

Install

npm install --save @naschpitz/button-enhanced

Usage

import React, {useState} from 'react';
import _ from 'lodash'

import { ButtonEnhanced } from '@naschpitz/button-enhanced';
import '@naschpitz/button-enhanced/dist/index.css';

const App = () => {
    const [ results, setResults ] = useState([]);
    const [ isAction, setIsAction ] = useState(false);

    function onDone(result) {
        if (result) {
            setIsAction(true);

            setTimeout(() => {
                setIsAction(false);
            }, 2000);
        }

        const newResults = _.clone(results);
        newResults.push(result);

        setResults(newResults);
    }

    return (
        <div>
            <ButtonEnhanced buttonOptions={{id: "btnDoThis",
                                            regularText: "Do This",
                                            actionText: "Doing this...",
                                            isAction: isAction,
                                            className: "btn btn-sm btn-danger",
                                            type: "button"
                                          }}
                            confirmationOptions={{title: "Confirm that",
                                                  text: <span>Do you really want to do this?</span>,
                                                  confirmButtonText: "Do that",
                                                  confirmButtonActionText: "Doing that...",
                                                  cancelButtonText: "Cancel",
                                                  cancelButtonActionText: "Cancelling...",
                                                  onDone: onDone
                                                }}
            />

            <h6>Results</h6>
            {results.length}
            {results.map((result) => (<div>{result.toString()}</div>))}
        </div>
    );
}

export default App

License

MIT © naschpitz

1.0.21

2 years ago

1.0.20

3 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago