Skip to content

Commit

Permalink
Using input masks to help guide the users on what type of values to i…
Browse files Browse the repository at this point in the history
…nput.
  • Loading branch information
ryanwiemer committed Jun 13, 2017
1 parent 144cd14 commit 0208a0c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/components/Calculator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import MaskedTextInput from 'react-text-mask';
import { createNumberMask } from 'text-mask-addons';
import createNumberMask from 'text-mask-addons/dist/createNumberMask';

class Calculator extends Component {
constructor() {
Expand Down Expand Up @@ -30,14 +30,6 @@ class Calculator extends Component {
});
}

// Settings for the input masks via react-text-mask and text-mask-addons
maskSettings = () => {
const numberMask = createNumberMask({
decimalSymbol: '.',
allowDecimal: true
});
}

// Calculator Logic
calibrationEquation = (a,b) => {
const equationResult = a / b;
Expand Down Expand Up @@ -102,7 +94,7 @@ class Calculator extends Component {
<div className="calculator">
<div className="input-container">
<MaskedTextInput
mask={[/[0-9]/,/[0-9]/,/[0-9]/,/[0-9]/]}
mask={[/[1-9]/, /[0-9]/, /[0-9]/]}
guide={false}
className="input input--blood"
name="blood"
Expand All @@ -112,7 +104,12 @@ class Calculator extends Component {
onChange={(event) => this.setState({ blood: event.target.value })}
/>
<MaskedTextInput
mask={[/[0-9]/,/[0-9]/,/[0-9]/,/[0-9]/]}
mask={createNumberMask({
decimalSymbol: '.',
allowDecimal: true,
suffix: '',
prefix: '',
})}
guide={false}
className="input input--isig"
name="isig"
Expand Down

0 comments on commit 0208a0c

Please sign in to comment.