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 16165af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions scripts/test/generate-css-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const fs = require('fs');
const path = require('path');

const combine = {
cell: ['cell', 'cell-group'],
avatar: ['avatar-group', 'avatar'],
cell: ['cell-group', 'cell'],
dropdown: ['dropdown-menu', 'dropdown-item'],
tag: ['tag', 'check-tag'],
checkbox: ['checkbox', 'checkbox-group'],
checkbox: ['checkbox-group', 'checkbox'],
indexes: ['indexes', 'indexes-anchor'],
steps: ['steps', 'step-item'],
swiper: ['swiper', 'swiper-nav'],
Expand Down Expand Up @@ -35,7 +36,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 +51,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 +60,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

0 comments on commit 16165af

Please sign in to comment.