Skip to content

Commit

Permalink
chore: using forEach instead of map
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Jul 12, 2023
1 parent 415097f commit e72025d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
17 changes: 11 additions & 6 deletions scripts/test/generate-css-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ const fs = require('fs');
const path = require('path');

const combine = {
cell: ['cell', 'cell-group'],
dropdown: ['dropdown-menu', 'dropdown-item'],
avatar: ['avatar-group', 'avatar'],
cell: ['cell-group', 'cell'],
collapse: ['collapse', 'collapse-panel'],
'dropdown-menu': ['dropdown-menu', 'dropdown-item'],
tag: ['tag', 'check-tag'],
checkbox: ['checkbox', 'checkbox-group'],
checkbox: ['checkbox-group', 'checkbox'],
indexes: ['indexes', 'indexes-anchor'],
picker: ['picker', 'picker-item'],
radio: ['radio-group', 'radio'],
'side-bar': ['side-bar', 'side-bar-item'],
steps: ['steps', 'step-item'],
swiper: ['swiper', 'swiper-nav'],
tabs: ['tabs', 'tab-panel'],
Expand Down Expand Up @@ -35,7 +40,7 @@ function findFilePath(componentName) {
// 使用 v2 文件夹下 _var.less 文件
const lessPath = [];
if (combine[COMPONENT_NAME]) {
combine[COMPONENT_NAME].map((item, index) => {
combine[COMPONENT_NAME].forEach((item) => {
lessPath.push(findFilePath(item));
});
} else {
Expand All @@ -50,7 +55,7 @@ fs.appendFileSync(resolveCwd(`src/${COMPONENT_NAME}/${COMPONENT_NAME}.md`), cssV
fs.appendFileSync(resolveCwd(`src/${COMPONENT_NAME}/${COMPONENT_NAME}.en-US.md`), cssVariableHeadContentEn);

// 读取 less 文件内容
lessPath.map((item, index) => {
lessPath.forEach((item) => {
if (fs.existsSync(item)) {
fs.readFile(item, 'utf8', (err, file) => {
if (err) {
Expand All @@ -59,7 +64,7 @@ lessPath.map((item, index) => {
}
const list = file.match(matchReg)?.sort();
let cssVariableBodyContent = '';
list?.map((item, index) => {
list?.forEach((item) => {
cssVariableBodyContent += `${item.slice(1, item.indexOf(','))} | ${item.slice(
item.indexOf(',') + 2,
item.length - 1,
Expand Down
6 changes: 3 additions & 3 deletions src/avatar/avatar.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ size | String | medium | size | N
The component provides the following CSS variables, which can be used to customize styles.
Name | Default Value | Description
-- | -- | --
--td-avatar-group-margin-left-large | -8px | -
--td-avatar-group-margin-left-medium | -6px | -
--td-avatar-group-margin-left-small | -4px | -
--td-avatar-bg-color | @brand-color-light-active | -
--td-avatar-border-color | #fff | -
--td-avatar-border-width-large | 4px | -
--td-avatar-border-width-medium | 3px | -
--td-avatar-border-width-small | 2px | -
--td-avatar-circle-border-radius | @radius-circle | -
--td-avatar-content-color | @brand-color | -
--td-avatar-group-margin-left-large | -8px | -
--td-avatar-group-margin-left-medium | -6px | -
--td-avatar-group-margin-left-small | -4px | -
--td-avatar-icon-large-font-size | 32px | -
--td-avatar-icon-medium-font-size | 24px | -
--td-avatar-icon-small-font-size | 20px | -
Expand Down
6 changes: 3 additions & 3 deletions src/avatar/avatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ size | String | medium | 尺寸,示例值:small/medium/large/24px/38px 等
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
--td-avatar-group-margin-left-large | -8px | -
--td-avatar-group-margin-left-medium | -6px | -
--td-avatar-group-margin-left-small | -4px | -
--td-avatar-bg-color | @brand-color-light-active | -
--td-avatar-border-color | #fff | -
--td-avatar-border-width-large | 4px | -
--td-avatar-border-width-medium | 3px | -
--td-avatar-border-width-small | 2px | -
--td-avatar-circle-border-radius | @radius-circle | -
--td-avatar-content-color | @brand-color | -
--td-avatar-group-margin-left-large | -8px | -
--td-avatar-group-margin-left-medium | -6px | -
--td-avatar-group-margin-left-small | -4px | -
--td-avatar-icon-large-font-size | 32px | -
--td-avatar-icon-medium-font-size | 24px | -
--td-avatar-icon-small-font-size | 20px | -
Expand Down
2 changes: 2 additions & 0 deletions src/dropdown-menu/dropdown-menu.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ reset | `(value: DropdownValue)` | \-
The component provides the following CSS variables, which can be used to customize styles.
Name | Default Value | Description
-- | -- | --
--td-dropdown-body-max-height | 280px | -
--td-dropdown-menu-bg-color | @bg-color-container | -
--td-dropdown-menu-active-colorm | @brand-color | -
--td-dropdown-menu-bg-colorm | @bg-color-container | -
--td-dropdown-menu-colorm | @font-gray-1 | -
Expand Down
2 changes: 2 additions & 0 deletions src/dropdown-menu/dropdown-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ reset | `(value: DropdownValue)` | 点击重置时触发
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
--td-dropdown-body-max-height | 280px | -
--td-dropdown-menu-bg-color | @bg-color-container | -
--td-dropdown-menu-active-colorm | @brand-color | -
--td-dropdown-menu-bg-colorm | @bg-color-container | -
--td-dropdown-menu-colorm | @font-gray-1 | -
Expand Down

0 comments on commit e72025d

Please sign in to comment.