From 4b829ea7dd11b02d03ea6650dee255c16c0e7556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Mon, 8 Jul 2019 17:42:24 +0800 Subject: [PATCH] [improvement] rename suffixPx to addUnit --- src/field/index.js | 4 ++-- src/grid-item/index.js | 6 +++--- src/grid/index.js | 4 ++-- src/icon/index.tsx | 4 ++-- src/image/index.js | 6 +++--- src/loading/index.tsx | 6 +++--- src/mixins/checkbox.js | 4 ++-- src/password-input/index.tsx | 4 ++-- src/rate/index.tsx | 6 +++--- src/skeleton/index.tsx | 8 ++++---- src/stepper/index.js | 8 ++++---- src/tabs/index.js | 6 +++--- src/uploader/index.js | 4 ++-- src/utils/format/unit.ts | 2 +- src/utils/index.ts | 2 +- 15 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/field/index.js b/src/field/index.js index 48cb288aa..418677aeb 100644 --- a/src/field/index.js +++ b/src/field/index.js @@ -3,7 +3,7 @@ import Cell from '../cell'; import { cellProps } from '../cell/shared'; import { preventDefault } from '../utils/dom/event'; import { getRootScrollTop } from '../utils/dom/scroll'; -import { createNamespace, isObj, isDef, suffixPx } from '../utils'; +import { createNamespace, isObj, isDef, addUnit } from '../utils'; import { isIOS } from '../utils/validate/system'; const [createComponent, bem] = createNamespace('field'); @@ -76,7 +76,7 @@ export default createComponent({ labelStyle() { const { labelWidth } = this; if (labelWidth) { - return { width: suffixPx(labelWidth) }; + return { width: addUnit(labelWidth) }; } } }, diff --git a/src/grid-item/index.js b/src/grid-item/index.js index 7c651e3df..a48965f3d 100644 --- a/src/grid-item/index.js +++ b/src/grid-item/index.js @@ -1,4 +1,4 @@ -import { createNamespace, suffixPx } from '../utils'; +import { createNamespace, addUnit } from '../utils'; import { ChildrenMixin } from '../mixins/relation'; import { route, routeProps } from '../utils/router'; import Icon from '../icon'; @@ -26,7 +26,7 @@ export default createComponent({ if (square) { style.paddingTop = percent; } else if (gutter) { - const gutterValue = suffixPx(gutter); + const gutterValue = addUnit(gutter); style.paddingRight = gutterValue; if (this.index >= columnNum) { @@ -41,7 +41,7 @@ export default createComponent({ const { square, gutter } = this.parent; if (square && gutter) { - const gutterValue = suffixPx(gutter); + const gutterValue = addUnit(gutter); return { right: gutterValue, diff --git a/src/grid/index.js b/src/grid/index.js index 9578c8f84..1f1af856a 100644 --- a/src/grid/index.js +++ b/src/grid/index.js @@ -1,4 +1,4 @@ -import { createNamespace, suffixPx } from '../utils'; +import { createNamespace, addUnit } from '../utils'; import { ParentMixin } from '../mixins/relation'; const [createComponent, bem] = createNamespace('grid'); @@ -30,7 +30,7 @@ export default createComponent({ if (gutter) { return { - paddingLeft: suffixPx(gutter) + paddingLeft: addUnit(gutter) }; } } diff --git a/src/icon/index.tsx b/src/icon/index.tsx index bdf0ef70e..468c2804e 100644 --- a/src/icon/index.tsx +++ b/src/icon/index.tsx @@ -1,4 +1,4 @@ -import { createNamespace, suffixPx } from '../utils'; +import { createNamespace, addUnit } from '../utils'; import { inherit } from '../utils/functional'; import Info from '../info'; import Image from '../image'; @@ -39,7 +39,7 @@ function Icon( class={[props.classPrefix, imageIcon ? '' : `${props.classPrefix}-${props.name}`]} style={{ color: props.color, - fontSize: suffixPx(props.size) + fontSize: addUnit(props.size) }} {...inherit(ctx, true)} > diff --git a/src/image/index.js b/src/image/index.js index 533c20c54..542699bfb 100644 --- a/src/image/index.js +++ b/src/image/index.js @@ -1,4 +1,4 @@ -import { createNamespace, isDef, suffixPx } from '../utils'; +import { createNamespace, isDef, addUnit } from '../utils'; import Icon from '../icon'; const [createComponent, bem] = createNamespace('image'); @@ -32,11 +32,11 @@ export default createComponent({ const style = {}; if (isDef(this.width)) { - style.width = suffixPx(this.width); + style.width = addUnit(this.width); } if (isDef(this.height)) { - style.height = suffixPx(this.height); + style.height = addUnit(this.height); } return style; diff --git a/src/loading/index.tsx b/src/loading/index.tsx index 414eac39c..e7bec1e65 100644 --- a/src/loading/index.tsx +++ b/src/loading/index.tsx @@ -1,4 +1,4 @@ -import { createNamespace, suffixPx } from '../utils'; +import { createNamespace, addUnit } from '../utils'; import { GRAY } from '../utils/color'; import { inherit } from '../utils/functional'; @@ -37,7 +37,7 @@ function LoadingIcon(h: CreateElement, props: LoadingProps) { function LoadingText(h: CreateElement, props: LoadingProps, slots: DefaultSlots) { if (slots.default) { const style = props.textSize && { - fontSize: suffixPx(props.textSize) + fontSize: addUnit(props.textSize) }; return ( @@ -58,7 +58,7 @@ function Loading( const style: { [key: string]: string } = { color }; if (size) { - const iconSize = suffixPx(size) as string; + const iconSize = addUnit(size) as string; style.width = iconSize; style.height = iconSize; } diff --git a/src/mixins/checkbox.js b/src/mixins/checkbox.js index 0b65c2011..cd482e48d 100644 --- a/src/mixins/checkbox.js +++ b/src/mixins/checkbox.js @@ -3,7 +3,7 @@ */ import Icon from '../icon'; import { ChildrenMixin } from './relation'; -import { suffixPx } from '../utils'; +import { addUnit } from '../utils'; export const CheckboxMixin = ({ parent, bem, role }) => ({ mixins: [ChildrenMixin(parent)], @@ -65,7 +65,7 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({ const Children = [
{CheckIcon} diff --git a/src/password-input/index.tsx b/src/password-input/index.tsx index 446003dc6..2f10d9944 100644 --- a/src/password-input/index.tsx +++ b/src/password-input/index.tsx @@ -1,4 +1,4 @@ -import { createNamespace, suffixPx } from '../utils'; +import { createNamespace, addUnit } from '../utils'; import { emit, inherit } from '../utils/functional'; // Types @@ -31,7 +31,7 @@ function PasswordInput( let style; if (i !== 0 && props.gutter) { - style = { marginLeft: suffixPx(props.gutter) }; + style = { marginLeft: addUnit(props.gutter) }; } Points.push( diff --git a/src/rate/index.tsx b/src/rate/index.tsx index b22135e26..b36ff0897 100644 --- a/src/rate/index.tsx +++ b/src/rate/index.tsx @@ -1,5 +1,5 @@ /* eslint-disable prefer-spread */ -import { createNamespace, suffixPx } from '../utils'; +import { createNamespace, addUnit } from '../utils'; import { emit, inherit } from '../utils/functional'; import { preventDefault } from '../utils/dom/event'; import Icon from '../icon'; @@ -90,13 +90,13 @@ function Rate( } } - const gutter = suffixPx(props.gutter); + const gutter = addUnit(props.gutter); function renderStar(status: RateStatus, index: number) { const isFull = status === 'full'; const isVoid = status === 'void'; const score = index + 1; - const size = suffixPx(props.size); + const size = addUnit(props.size); let style; if (gutter && score !== count) { diff --git a/src/skeleton/index.tsx b/src/skeleton/index.tsx index 58f247c11..ab467382b 100644 --- a/src/skeleton/index.tsx +++ b/src/skeleton/index.tsx @@ -1,4 +1,4 @@ -import { createNamespace, suffixPx } from '../utils'; +import { createNamespace, addUnit } from '../utils'; import { inherit } from '../utils/functional'; // Types @@ -33,7 +33,7 @@ function Skeleton( function Title() { if (props.title) { - return

; + return

; } } @@ -54,7 +54,7 @@ function Skeleton( } for (let i = 0; i < props.row; i++) { - Rows.push(
); + Rows.push(
); } return Rows; @@ -62,7 +62,7 @@ function Skeleton( function Avatar() { if (props.avatar) { - const size = suffixPx(props.avatarSize); + const size = addUnit(props.avatarSize); return (