1.0.14 • Published 6 years ago

library-button-component v1.0.14

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Button Component

Button component for React

Install and save component as a dependency

npm install --save library-button-component

Import component into your app

import Button from 'library-button-component'

Create and assign button states with empty values

constructor(props) {
	super(props)

	this.state = {
		buttonAction: '',
		buttonCode: '',
		buttonText: ''
	}
}

Create the function that will handle mouse click events

handleButtonClick(event) {
	this.setState ({
		buttonAction: 'Click'
	});
}

Create the function that will handle mouse hover enter and exit events

handleButtonHoverOver(event) {
	this.setState ({
		buttonAction: 'Hover',
		buttonCode: event.target.innerHTML,
		buttonText: event.target.textContent
	});

	event.target.innerHTML = "Hovering..."
}

handleButtonHoverExit(event) {
	event.target.innerHTML = this.state.buttonCode;
}

Render the component with the functions we created as well as any other props that are needed

render () {
	return (
		<ButtonComponent
		  buttonCategory="default"
		  buttonSize="default"
		  buttonText="Default"
		  handleButtonClick={this.handleButtonClick.bind(this)}
		  handleButtonHoverOver={this.handleButtonHoverOver.bind(this)}
		  handleButtonHoverExit={this.handleButtonHoverExit.bind(this)} />
	)
}
PropValues
buttonCategorydefault, primary, success, danger, info
buttonSizelarge
buttonTextString
buttonSymbol* Font Awesome class
handleButtonClickhandleButtonClick function
handleButtonHoverOverhandleButtonHoverOver function
handleButtonHoverExithandleButtonHoverExit function
  • Font Awesome needs to included in project for symbols to display
1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago