Skip to content

Commit 2a0bece

Browse files
authored
Merge pull request #324 from puppetlabs/PDS-448-input-updates
(PDS-448) add size and shape props to input component
2 parents 78ed894 + 1ac0632 commit 2a0bece

File tree

3 files changed

+81
-5
lines changed

3 files changed

+81
-5
lines changed

packages/react-components/source/react/library/input/Input.js

+18-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ const propTypes = {
3030
placeholder: PropTypes.string,
3131
/** Alternate visual variation */
3232
simple: PropTypes.bool,
33+
/** Size of the input */
34+
size: PropTypes.oneOf(['medium', 'large']),
35+
/** Shape of the input */
36+
shape: PropTypes.oneOf(['squared', 'rounded']),
3337
/** Is the input disabled */
3438
disabled: PropTypes.bool,
3539
/** Form error, causing element to render red when present */
@@ -61,6 +65,8 @@ const defaultProps = {
6165
value: '',
6266
placeholder: '',
6367
simple: false,
68+
size: 'medium',
69+
shape: 'squared',
6470
disabled: false,
6571
error: false,
6672
icon: null,
@@ -91,6 +97,8 @@ const Input = ({
9197
name,
9298
type,
9399
simple,
100+
size,
101+
shape,
94102
error,
95103
icon,
96104
trailingIcon,
@@ -151,11 +159,16 @@ const Input = ({
151159
id={name}
152160
name={name}
153161
type={isMultiline ? undefined : type}
154-
className={classNames('rc-input', {
155-
'rc-input-error': error,
156-
'rc-input-simple': simple,
157-
'rc-input-multiline': isMultiline,
158-
})}
162+
className={classNames(
163+
'rc-input',
164+
`rc-input-${size}`,
165+
`rc-input-${shape}`,
166+
{
167+
'rc-input-error': error,
168+
'rc-input-simple': simple,
169+
'rc-input-multiline': isMultiline,
170+
},
171+
)}
159172
ref={inputRef}
160173
onChange={e => onChange(parseValue(e.target.value), e)}
161174
{...otherProps}

packages/react-components/source/react/library/input/Input.md

+47
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,53 @@ Inputs are available in a "simple" visual variant, primarily used for in-site se
7777
/>
7878
```
7979

80+
### Size and Shape
81+
82+
Inputs are available in two different sizes, "medium" and "large" and two different shapes, "squared" and "rounded". "medium" and "squared" inputs are the default.
83+
84+
```jsx
85+
<Input
86+
name="input-ex7"
87+
value={state.value}
88+
placeholder="blueberry spicehead"
89+
icon="scatter"
90+
shape="squared"
91+
size="medium"
92+
style={{ marginBottom: 10 }}
93+
onChange={value => setState({ value })}
94+
/>
95+
<Input
96+
name="input-ex7"
97+
value={state.value}
98+
placeholder="princess rainbow"
99+
icon="integration"
100+
shape="rounded"
101+
size="medium"
102+
style={{ marginBottom: 10 }}
103+
onChange={value => setState({ value })}
104+
/>
105+
<Input
106+
name="input-ex8"
107+
value={state.value}
108+
placeholder="twinkle starchild"
109+
icon="star"
110+
size="large"
111+
shape="squared"
112+
style={{ marginBottom: 10 }}
113+
onChange={value => setState({ value })}
114+
/>
115+
<Input
116+
name="input-ex9"
117+
value={state.value}
118+
placeholder="juniper lightning bug"
119+
icon="activity"
120+
size="large"
121+
shape="rounded"
122+
style={{ marginBottom: 10 }}
123+
onChange={value => setState({ value })}
124+
/>
125+
```
126+
80127
### Inputs with icons
81128

82129
#### Leading icon

packages/react-components/source/scss/library/components/forms/_input.scss

+16
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@
4646
box-shadow: 0 2px 0 0 $puppet-b300 !important;
4747
}
4848

49+
.rc-input-squared {
50+
border-radius: $puppet-common-border-radius;
51+
}
52+
53+
.rc-input-rounded {
54+
border-radius: 80px;
55+
}
56+
57+
.rc-input-medium {
58+
padding: 5px 7px;
59+
}
60+
61+
.rc-input-large {
62+
padding: 10px;
63+
}
64+
4965
.rc-input-multiline {
5066
height: $puppet-common-spacing-base * 18;
5167
resize: vertical;

0 commit comments

Comments
 (0)