Skip to content

Commit 10450e4

Browse files
nmergetmfranzke
andauthored
feat: add field-sizing for input and textarea (#4254)
* feat: add field-sizing for input and textarea * Update model.ts * feat: add showResizer to align with design * chore: update snapshots --------- Co-authored-by: Maximilian Franzke <[email protected]>
1 parent 7548c2f commit 10450e4

File tree

18 files changed

+109
-10
lines changed

18 files changed

+109
-10
lines changed

packages/components/src/components/input/input.lite.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export default function DBInput(props: DBInputProps) {
207207
<input
208208
aria-invalid={props.validation === 'invalid'}
209209
data-custom-validity={props.validation}
210+
data-field-sizing={props.fieldSizing}
210211
ref={_ref}
211212
id={state._id}
212213
name={props.name}

packages/components/src/components/textarea/model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ export type DBTextareaDefaultProps = {
3434
* In most browsers, textareas are resizable — you'll notice the drag handle in the right-hand corner, you can control it with this
3535
*/
3636
resize?: TextareaResizeType;
37+
38+
/**
39+
* Show/Hides drag handle in the right-hand corner - default: true
40+
*/
41+
showResizer?: boolean | string;
42+
3743
/**
3844
* The number of visible text lines for the control. If it is specified, it must be a positive integer
3945
*/

packages/components/src/components/textarea/textarea.lite.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ export default function DBTextarea(props: DBTextareaProps) {
176176
<textarea
177177
aria-invalid={props.validation === 'invalid'}
178178
data-custom-validity={props.validation}
179+
data-field-sizing={props.fieldSizing}
179180
ref={_ref}
180181
id={state._id}
181182
data-resize={props.resize}
183+
data-hide-resizer={getHideProp(props.showResizer ?? true)}
182184
disabled={getBoolean(props.disabled, 'disabled')}
183185
required={getBoolean(props.required, 'required')}
184186
readOnly={

packages/components/src/components/textarea/textarea.scss

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,27 @@
88
@use "../../styles/internal/scrollbar";
99

1010
%resize-textarea {
11-
&[data-resize="none"] {
11+
&[data-hide-resizer="true"] {
1212
resize: none;
1313
}
1414

15-
&[data-resize="both"] {
16-
resize: both;
17-
}
15+
// TODO: Consolidate data-hide-resizer and data-resize attributes in the future
16+
&:not([data-hide-resizer="true"]) {
17+
&[data-resize="none"] {
18+
resize: none;
19+
}
1820

19-
&[data-resize="horizontal"] {
20-
resize: horizontal;
21-
}
21+
&[data-resize="both"] {
22+
resize: both;
23+
}
2224

23-
&[data-resize="vertical"] {
24-
resize: vertical;
25+
&[data-resize="horizontal"] {
26+
resize: horizontal;
27+
}
28+
29+
&[data-resize="vertical"] {
30+
resize: vertical;
31+
}
2532
}
2633
}
2734

0 commit comments

Comments
 (0)