Merge pull request #249 from fsih/widthWidth

Set a width on stroke width, brush and eraser width inputs
This commit is contained in:
DD Liu 2018-01-10 15:45:10 -05:00 committed by GitHub
commit 136357463c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 2 deletions

View file

@ -2,6 +2,10 @@
@todo This file is copied from GUI and should be pulled out into a shared library.
See https://github.com/LLK/scratch-paint/issues/13 */
/* NOTE:
Edited to add input-range-small
*/
@import "../../css/units.css";
@import "../../css/colors.css";
@ -44,3 +48,8 @@ See https://github.com/LLK/scratch-paint/issues/13 */
width: 3rem;
text-align: center;
}
.input-small-range {
width: 3.75rem;
text-align: center;
}

View file

@ -2,6 +2,10 @@
@todo This file is copied from GUI and should be pulled out into a shared library.
See https://github.com/LLK/scratch-paint/issues/13 */
/* NOTE:
Edited to add range prop
*/
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
@ -9,7 +13,7 @@ import classNames from 'classnames';
import styles from './input.css';
const Input = props => {
const {small, ...componentProps} = props;
const {small, range, ...componentProps} = props;
return (
<input
{...componentProps}
@ -17,7 +21,8 @@ const Input = props => {
styles.inputForm,
props.className,
{
[styles.inputSmall]: small
[styles.inputSmall]: small && !range,
[styles.inputSmallRange]: small && range
}
)}
/>
@ -26,10 +31,12 @@ const Input = props => {
Input.propTypes = {
className: PropTypes.string,
range: PropTypes.bool,
small: PropTypes.bool
};
Input.defaultProps = {
range: false,
small: false
};

View file

@ -84,6 +84,8 @@ const ModeToolsComponent = props => {
/>
</div>
<LiveInput
range
small
max={MAX_STROKE_WIDTH}
min="1"
type="number"
@ -103,6 +105,8 @@ const ModeToolsComponent = props => {
/>
</div>
<LiveInput
range
small
max={MAX_STROKE_WIDTH}
min="1"
type="number"

View file

@ -11,6 +11,8 @@ const LiveInput = LiveInputHOC(Input);
const StrokeWidthIndicatorComponent = props => (
<InputGroup disabled={props.disabled}>
<LiveInput
range
small
disabled={props.disabled}
max={MAX_STROKE_WIDTH}
min="0"