1.2.3 • Published 2 years ago

progress-button v1.2.3

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

Angular Progress Button

Build Status npm version demo online npm downloads Code Climate maintainability Code Coverage Dependencies GitHub issues Conventional Commits npm bundle size

This represents a button element where the button itself serves as a progress indicator. You can choose from 16 types of animations. 3D animation styles are used for showing the progress indication on one side of the button while rotating the button in perspective.

Table of contents

Features

  • Choose from 16 different types of progress animations
  • Choose the direction of the progress animation
  • Manage success and error statuses
  • Setup all style variables

Getting started

Step 1: Install progress-button:

npm i progress-button

Step 2: Import ProgressButtonModule:

import {ProgressButtonModule} from 'progress-button';

@NgModule({
  declarations: [AppComponent],
  imports: [ProgressButtonModule],
  bootstrap: [AppComponent]
})
export class AppModule {}

Usage sample

<ydd-progress-button 
    (action)="run($event)" 
    [progress]="progressData" 
    [design]="designData">
    Submit
</ydd-progress-button>
let progressData = {
    animation: 'shrink',
    direction: 'vertical',
}
  
let designData = {
    background: '#222222',
    color: '#FFFFFF',
    successBackground: '#00e175',
    errorBackground: '#ff0c00',
    successIconColor: '#ffffff',
    errorIconColor: '#ffffff',
    progressBackground: '#000000',
    progressInnerBackground: 'rgba(255, 255, 255,0.5)',
    radius:50
}

run = (instance)=>{
    let progress = 0;
    // initialize the progress
    instance.progressInit();
    // This is an example of interval useful to set the progress value
    const interval = setInterval(() => {
      progress += 5;
      // set the progress value
      instance.progressValue = progress;
      if (progress === 100) {
        // stop the progress with success status
        const sub = instance.progressStop('success').subscribe({
          complete() {
            sub.unsubscribe();
          }
        });
        clearInterval(interval);
      }
    }, 200);
  }

Global Configuration

You can easily define progress options and design during the import phase using the method forRoot. This is useful if you need to setup a common behaviour and/or a common style for your buttons.

import {ProgressButtonModule} from 'progress-button';  
  
@NgModule({  
  declarations: [AppComponent],  
  imports: [
	  ProgressButtonModule.forRoot({  
		  design: {...}, // ProgressButtonDesign interface  
		  progress: {...} // ProgressButtonData interface 
	  })
  ],  
  bootstrap: [AppComponent]  
})  
export class AppModule {}

API

Inputs

InputTypeDefaultRequiredDescription
namestring, nullnullnoA name for the button.
valuestring, nullnullnoAn initial value for the button.
typebutton, reset, submitbuttonnoThe type of button.
autofocustrue, nullnullnoSpecifies that a button should automatically get focus when the page loads.
disabledtrue, nullnullnoSpecifies that a button should be disabled.
formProgressButtonFormnoForm parameters for the button.
progressProgressButtonDatanoSpecifies progress parameters.
designProgressButtonDesignnoSpecifies button and progress design
ProgressButtonForm
PropertyTypeDefaultRequiredDescription
idstring, nullnullnoSpecifies one or more forms the button belongs to.
actionstring, nullnullnoSpecifies where to send the form-data when a form is submitted. Only for type="submit".
noValidateboolean, nullbuttonnoSpecifies that the form-data should not be validated on submission. Only for type="submit".
enctypeapplication/x-www-form-urlencoded, multipart/form-data, text/plain, nullnullnoSpecifies how form-data should be encoded before sending it to a server. Only for type="submit".
methodget,post, nullnullnoSpecifies how to send the form-data (which HTTP method to use). Only for type="submit".
target_blank, _self, _parent, _top, nullnullnoSpecifies where to display the response after submitting the form. Only for type="submit".
ProgressButtonData
PropertyTypeDefaultRequiredDescription
animationfill, shrink, rotate-angle-bottom, rotate-angle-top, rotate-angle-left, rotate-angle-right, rotate-side-down, rotate-side-up, rotate-side-left, rotate-side-right, rotate-back, flip-open, slide-down, move-up, top-line, lateral-linesfillnoDefines the progress animation style.
directionhorizontal, verticalhorizontalnoDefines the progress animation direction.
statusTimenumber1500noTime in ms that the status (success or error) will be displayed.
ProgressButtonDesign
PropertyTypeDefaultRequiredDescription
backgroundstring (css color)#222222noThe background of the button.
colorstring (css color)#FFFFFFnoThe text color of the button.
successBackgroundstring (css color)#00E175noThe background of the button when status is success.
errorBackgroundstring (css color)#FF0C00noThe background of the button when status is error.
successIconColorstring (css color)#FFFFFFnoThe color of the icon when status is success.
errorIconColorstring (css color)#FFFFFFnoThe color of the icon when status is error.
progressBackgroundstring (css color)#000000noThe background of the progress element.
progressInnerBackgroundstring (css color)rgba(255, 255, 255,0.5)noThe background of the progress inner element.
linesSizenumber10noThe size in px of the progress lines. This value is used in the animation styles top-line and lateral-lines.
radiusnumber0noSets rounded shape to button with given radius size. This value is used in all the animation styles except rotate-* animations.

Outputs

OutputParamsDescription
(action)ProgressButtonComponentFires on a mouse click on the element.

Methods ProgressButtonComponent

MethodParamsDescription
progressInitInitialize the progress component. You can use it inside the action Output
progressStopsuccess or errorStop the progress component. You can use it inside the action Output.

Properties ProgressButtonComponent

NameDescription
progressValueUseful to change the value of the progress. You can use it inside the action Output

Support

If this project help you reduce time to develop, you can give me a cup of coffee :)

Donate

Author

Credits

This angular component is liberally inspired to Progress Button Styles of Mary Lou.

License

This project is licensed under the terms of the MIT license.

1.2.3

2 years ago

1.2.0

3 years ago

1.1.19

3 years ago

1.1.18

3 years ago

1.1.17

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago