Skip to content

Commit 313a880

Browse files
authored
style(Textarea): support --td-textarea-padding (#3937)
* style(Textarea): support --td-textarea-padding * chore: update generate-css-vars script * docs(Textarea): update
1 parent a5ee034 commit 313a880

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

packages/components/textarea/README.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ Name | Default Value | Description
6868
--td-textarea-disabled-text-color | @text-color-disabled | -
6969
--td-textarea-indicator-text-color | @text-color-placeholder | -
7070
--td-textarea-label-color | @text-color-primary | -
71+
--td-textarea-padding | 32rpx | -
7172
--td-textarea-placeholder-color | @text-color-placeholder | -
7273
--td-textarea-text-color | @text-color-primary | -

packages/components/textarea/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,6 @@ t-class-textarea | 多行文本框样式类
131131
--td-textarea-disabled-text-color | @text-color-disabled | -
132132
--td-textarea-indicator-text-color | @text-color-placeholder | -
133133
--td-textarea-label-color | @text-color-primary | -
134+
--td-textarea-padding | 32rpx | -
134135
--td-textarea-placeholder-color | @text-color-placeholder | -
135136
--td-textarea-text-color | @text-color-primary | -

packages/components/textarea/textarea.less

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@import '../common/style/base.less';
22

3-
@textarea-vertical-padding: 32rpx; // 文本框垂直方向间距
4-
@textarea-horizontal-padding: 32rpx; // 文本框水平方向间距
3+
@textarea-padding: var(--td-textarea-padding, 32rpx);
54
@textarea-text-line-height: 48rpx; // 输入框文本行高
65
@textarea-label-line-height: 44rpx; // 标签文本行高
76
@textarea-label-padding-bottom: @spacer;
@@ -35,7 +34,7 @@
3534
display: flex;
3635
flex-direction: column;
3736
box-sizing: border-box;
38-
padding: @textarea-vertical-padding @textarea-horizontal-padding;
37+
padding: @textarea-padding;
3938
background-color: @textarea-background-color;
4039

4140
&__label:not(:empty) {

packages/tdesign-miniprogram/site/scripts/generate-css-vars.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import fs from 'fs';
22
import resolveCwd from './utils.mjs';
33

44
const COMPONENT_NAME = process.argv[process.argv.indexOf('--NAME') + 1]; // 在 --NAME 后面
5-
const ROOT_DIR = resolveCwd('../../components');
5+
const ROOT_DIR = COMPONENT_NAME.includes('chat')
6+
? resolveCwd('/packages/pro-components')
7+
: resolveCwd('/packages/components');
68

79
const combine = {
810
avatar: ['avatar-group', 'avatar'],
@@ -72,23 +74,21 @@ const generateCssVariables = async (componentName) => {
7274
* @param {string} variables - 生成的变量内容
7375
*/
7476
const updateDocVariables = (filePath, headContent, variables) => {
75-
const path = resolveCwd(filePath);
77+
if (!fs.existsSync(filePath)) return;
7678

77-
if (!fs.existsSync(path)) return;
78-
79-
const content = fs.readFileSync(path, 'utf8');
79+
const content = fs.readFileSync(filePath, 'utf8');
8080
const cssVariablesSection = `\n${headContent}${variables}`;
8181

8282
// 检查是否存在 ### CSS Variables 部分
8383
if (content.includes('### CSS Variables')) {
8484
// 替换现有部分
8585
const newContent = content.replace(/(^|\n+)### CSS Variables[\s\S]*?(?=###|$)/, cssVariablesSection);
86-
fs.writeFileSync(path, newContent, 'utf8');
86+
fs.writeFileSync(filePath, newContent, 'utf8');
8787
} else {
8888
// 追加到文件末尾
8989
const trimmedContent = content.trimEnd();
9090
const newContent = `${trimmedContent}\n${cssVariablesSection}`;
91-
fs.writeFileSync(path, newContent, 'utf8');
91+
fs.writeFileSync(filePath, newContent, 'utf8');
9292
}
9393
};
9494

0 commit comments

Comments
 (0)