Skip to content

Commit 28f2d60

Browse files
Add height prop to TextArea component (#1076)
This change introduces a new `height` prop to the `TextArea` component, allowing users to specify a starting (minimum) height for the input field. Key changes: 1. **TextArea.vue**: Added the `height` prop. 2. **BaseInput.vue**: Added the `height` prop and updated the `inputMinHeight` computed property to apply the style to the textarea element. 3. **Tests**: Added tests in `src/tests/Textarea.spec.js` and `src/tests/BaseInput.spec.js` to ensure the prop is correctly passed and applied. 4. **Documentation**: Updated `docs/components/forms/text-area.md` to include the new prop in the playground. 5. **Version**: Updated `package.json` version to `3.155.3`. 6. **Metadata**: Updated `docs/.docgen/components-metadata.json` via `npm run generate:docs`. --- *PR created automatically by Jules for task [13734789671786383417](https://jules.google.com/task/13734789671786383417) started by @lucasn4s* --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: lucasn4s <17988272+lucasn4s@users.noreply.github.com>
1 parent 664e00e commit 28f2d60

8 files changed

Lines changed: 84 additions & 5 deletions

File tree

docs/.docgen/components-metadata.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,17 @@
11551155
"func": false,
11561156
"value": "false"
11571157
}
1158+
},
1159+
{
1160+
"name": "height",
1161+
"description": "Especifica a altura mínima (min-height) do textarea.",
1162+
"type": {
1163+
"name": "number|string"
1164+
},
1165+
"defaultValue": {
1166+
"func": false,
1167+
"value": "null"
1168+
}
11581169
}
11591170
],
11601171
"events": [
@@ -13279,6 +13290,17 @@
1327913290
"func": false,
1328013291
"value": "false"
1328113292
}
13293+
},
13294+
{
13295+
"name": "height",
13296+
"description": "Especifica a altura mínima (min-height) do textarea.",
13297+
"type": {
13298+
"name": "number|string"
13299+
},
13300+
"defaultValue": {
13301+
"func": false,
13302+
"value": "null"
13303+
}
1328213304
}
1328313305
],
1328413306
"sourceFiles": [

docs/components/forms/text-area.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ const args = ref({
6868
supportingText: 'supportingTex',
6969
supportLink: '',
7070
supportLinkUrl: '',
71+
height: null,
7172
});
7273
</script>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sysvale/cuida",
3-
"version": "3.155.2",
3+
"version": "3.155.3",
44
"description": "A design system built by Sysvale, using storybook and Vue components",
55
"repository": {
66
"type": "git",

src/components/BaseInput.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,13 @@ const props = defineProps({
384384
type: Boolean,
385385
default: false,
386386
},
387+
/**
388+
* Especifica a altura mínima (min-height) do textarea.
389+
*/
390+
height: {
391+
type: [Number, String],
392+
default: null,
393+
},
387394
});
388395
389396
const emits = defineEmits({
@@ -429,7 +436,14 @@ const inputHeight = computed(() => {
429436
});
430437
431438
const inputMinHeight = computed(() => {
432-
return props.type === 'textarea' ? '120px' : 'auto';
439+
if (props.type !== 'textarea') return 'auto';
440+
if (!props.height) return '120px';
441+
442+
if (typeof props.height === 'number') {
443+
return `${props.height}px`;
444+
}
445+
446+
return props.height;
433447
});
434448
435449
const inputTopPadding = computed(() => {
@@ -648,7 +662,7 @@ defineExpose({
648662
padding: tokens.pTRBL(0, 2, 3, 2);
649663
padding-top: v-bind(inputTopPadding);
650664
height: v-bind(inputHeight);
651-
min-height: v-bind(inputMinHeight);
665+
min-height: v-bind(inputMinHeight) !important;
652666
border-radius: tokens.$border-radius-extra-small;
653667
border: none;
654668
text-align: start;

src/components/TextArea.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ const props = defineProps({
134134
type: Boolean,
135135
default: false,
136136
},
137+
/**
138+
* Especifica a altura mínima (min-height) do textarea.
139+
*/
140+
height: {
141+
type: [Number, String],
142+
default: null,
143+
},
137144
});
138145
139146
const emits = defineEmits({

src/tests/BaseInput.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,28 @@ describe('BaseInput', () => {
290290
expect(wrapper.findComponent(CdsLink).props('text')).toBe('Support Link');
291291
expect(wrapper.findComponent(CdsLink).props('href')).toBe('https://example.com');
292292
});
293+
294+
test('computes inputMinHeight correctly when height prop is provided', () => {
295+
const wrapper = mount(BaseInput, {
296+
props: {
297+
id: 'base-input',
298+
type: 'textarea',
299+
height: 300,
300+
},
301+
});
302+
303+
expect(wrapper.vm.inputMinHeight).toBe('300px');
304+
});
305+
306+
test('computes inputMinHeight correctly when height prop is provided as string', () => {
307+
const wrapper = mount(BaseInput, {
308+
props: {
309+
id: 'base-input',
310+
type: 'textarea',
311+
height: '400px',
312+
},
313+
});
314+
315+
expect(wrapper.vm.inputMinHeight).toBe('400px');
316+
});
293317
});

src/tests/Textarea.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,15 @@ describe('TextArea', () => {
120120
await baseInput.setValue('new value');
121121
expect(wrapper.vm.internalValue).toBe('new value');
122122
});
123+
124+
test('passes the height prop to CdsBaseInput', () => {
125+
const wrapper = mount(TextArea, {
126+
props: {
127+
id: 'text-area',
128+
height: 200,
129+
},
130+
});
131+
132+
expect(wrapper.findComponent(CdsBaseInput).props('height')).toBe(200);
133+
});
123134
});

0 commit comments

Comments
 (0)