[improvement] add constant of border (#4078)

This commit is contained in:
neverland 2019-08-09 14:15:49 +08:00 committed by GitHub
parent 4cba618792
commit 24f5a91cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 88 additions and 57 deletions

View File

@ -66,7 +66,7 @@
</template> </template>
<script> <script>
import { GREEN } from '../../utils/color'; import { GREEN } from '../../utils/constant';
export default { export default {
i18n: { i18n: {

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { emit, inherit } from '../utils/functional'; import { emit, inherit } from '../utils/functional';
import { BORDER_TOP, BORDER_BOTTOM } from '../utils/constant';
import { PopupMixin } from '../mixins/popup'; import { PopupMixin } from '../mixins/popup';
import Icon from '../icon'; import Icon from '../icon';
import Popup from '../popup'; import Popup from '../popup';
@ -48,7 +49,7 @@ function ActionSheet(
function Header() { function Header() {
if (title) { if (title) {
return ( return (
<div class={[bem('header'), 'van-hairline--bottom']}> <div class={[bem('header'), BORDER_BOTTOM]}>
{title} {title}
<Icon name="close" class={bem('close')} onClick={onCancel} /> <Icon name="close" class={bem('close')} onClick={onCancel} />
</div> </div>
@ -96,7 +97,7 @@ function ActionSheet(
return ( return (
<div <div
class={[bem('item', { disabled }), item.className, 'van-hairline--top']} class={[bem('item', { disabled }), item.className, BORDER_TOP]}
style={{ color: item.color }} style={{ color: item.color }}
onClick={onClickOption} onClick={onClickOption}
> >

View File

@ -1,5 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { RED } from '../utils/color'; import { RED } from '../utils/constant';
import { emit, inherit } from '../utils/functional'; import { emit, inherit } from '../utils/functional';
import Icon from '../icon'; import Icon from '../icon';
import Cell from '../cell'; import Cell from '../cell';

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { emit, inherit } from '../utils/functional'; import { emit, inherit } from '../utils/functional';
import { BORDER_SURROUND } from '../utils/constant';
import { routeProps, RouteProps, functionalRoute } from '../utils/router'; import { routeProps, RouteProps, functionalRoute } from '../utils/router';
import Icon from '../icon'; import Icon from '../icon';
import Loading, { LoadingType } from '../loading'; import Loading, { LoadingType } from '../loading';
@ -69,7 +70,7 @@ function Button(
square: props.square square: props.square
} }
]), ]),
{ 'van-hairline--surround': hairline } { [BORDER_SURROUND]: hairline }
]; ];
function Content() { function Content() {

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { inherit } from '../utils/functional'; import { inherit } from '../utils/functional';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
// Types // Types
import { CreateElement, RenderContext } from 'vue/types'; import { CreateElement, RenderContext } from 'vue/types';
@ -20,7 +21,7 @@ function CellGroup(
) { ) {
const Group = ( const Group = (
<div <div
class={[bem(), { 'van-hairline--top-bottom': props.border }]} class={[bem(), { [BORDER_TOP_BOTTOM]: props.border }]}
{...inherit(ctx, true)} {...inherit(ctx, true)}
> >
{slots.default && slots.default()} {slots.default && slots.default()}

View File

@ -1,6 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { raf, cancelRaf } from '../utils/dom/raf'; import { raf, cancelRaf } from '../utils/dom/raf';
import { BLUE, WHITE } from '../utils/color'; import { BLUE, WHITE } from '../utils/constant';
const [createComponent, bem] = createNamespace('circle'); const [createComponent, bem] = createNamespace('circle');
const PERIMETER = 3140; const PERIMETER = 3140;

View File

@ -1,4 +1,5 @@
import { createNamespace, isDef } from '../utils'; import { createNamespace, isDef } from '../utils';
import { BORDER_TOP } from '../utils/constant';
import { raf, doubleRaf } from '../utils/dom/raf'; import { raf, doubleRaf } from '../utils/dom/raf';
import Cell from '../cell'; import Cell from '../cell';
import { cellProps } from '../cell/shared'; import { cellProps } from '../cell/shared';
@ -147,7 +148,7 @@ export default createComponent({
); );
return ( return (
<div class={[bem(), { 'van-hairline--top': this.index }]}> <div class={[bem(), { [BORDER_TOP]: this.index }]}>
{Title} {Title}
{Content} {Content}
</div> </div>

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { ParentMixin } from '../mixins/relation'; import { ParentMixin } from '../mixins/relation';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
const [createComponent, bem] = createNamespace('collapse'); const [createComponent, bem] = createNamespace('collapse');
@ -29,7 +30,7 @@ export default createComponent({
render() { render() {
return ( return (
<div class={[bem(), { 'van-hairline--top-bottom': this.border }]}> <div class={[bem(), { [BORDER_TOP_BOTTOM]: this.border }]}>
{this.slots()} {this.slots()}
</div> </div>
); );

View File

@ -1,5 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { RED } from '../utils/color'; import { RED } from '../utils/constant';
import { emit, inherit } from '../utils/functional'; import { emit, inherit } from '../utils/functional';
import Icon from '../icon'; import Icon from '../icon';
import Cell from '../cell'; import Cell from '../cell';

View File

@ -1,5 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { RED } from '../utils/color'; import { RED } from '../utils/constant';
import { padZero } from '../utils/format/string'; import { padZero } from '../utils/format/string';
import Checkbox from '../checkbox'; import Checkbox from '../checkbox';

View File

@ -1,4 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { BORDER_TOP, BORDER_LEFT } from '../utils/constant';
import { PopupMixin } from '../mixins/popup'; import { PopupMixin } from '../mixins/popup';
import { CloseOnPopstateMixin } from '../mixins/close-on-popstate'; import { CloseOnPopstateMixin } from '../mixins/close-on-popstate';
import Button from '../button'; import Button from '../button';
@ -99,7 +100,7 @@ export default createComponent({
const hasButtons = this.showCancelButton && this.showConfirmButton; const hasButtons = this.showCancelButton && this.showConfirmButton;
const ButtonGroup = ( const ButtonGroup = (
<div class={['van-hairline--top', bem('footer', { buttons: hasButtons })]}> <div class={[BORDER_TOP, bem('footer', { buttons: hasButtons })]}>
{this.showCancelButton && ( {this.showCancelButton && (
<Button <Button
size="large" size="large"
@ -115,7 +116,7 @@ export default createComponent({
{this.showConfirmButton && ( {this.showConfirmButton && (
<Button <Button
size="large" size="large"
class={[bem('confirm'), { 'van-hairline--left': hasButtons }]} class={[bem('confirm'), { [BORDER_LEFT]: hasButtons }]}
loading={this.loading.confirm} loading={this.loading.confirm}
text={this.confirmButtonText || t('confirm')} text={this.confirmButtonText || t('confirm')}
style={{ color: this.confirmButtonColor }} style={{ color: this.confirmButtonColor }}

View File

@ -38,7 +38,7 @@
</template> </template>
<script> <script>
import { BLUE } from '../../utils/color'; import { BLUE } from '../../utils/constant';
export default { export default {
i18n: { i18n: {

View File

@ -1,5 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { BLUE } from '../utils/color'; import { BLUE, BORDER_TOP_BOTTOM } from '../utils/constant';
import { ParentMixin } from '../mixins/relation'; import { ParentMixin } from '../mixins/relation';
import { ClickOutsideMixin } from '../mixins/click-outside'; import { ClickOutsideMixin } from '../mixins/click-outside';
@ -103,7 +103,7 @@ export default createComponent({
)); ));
return ( return (
<div ref="menu" class={[bem(), 'van-hairline--top-bottom']}> <div ref="menu" class={[bem(), BORDER_TOP_BOTTOM]}>
{Titles} {Titles}
{this.slots('default')} {this.slots('default')}
</div> </div>

View File

@ -1,4 +1,5 @@
import { createNamespace, addUnit } from '../utils'; import { createNamespace, addUnit } from '../utils';
import { BORDER } from '../utils/constant';
import { ChildrenMixin } from '../mixins/relation'; import { ChildrenMixin } from '../mixins/relation';
import { route, routeProps } from '../utils/router'; import { route, routeProps } from '../utils/router';
import Icon from '../icon'; import Icon from '../icon';
@ -86,7 +87,7 @@ export default createComponent({
clickable, clickable,
surround: border && gutter surround: border && gutter
}), }),
{ 'van-hairline': border } { [BORDER]: border }
]} ]}
> >
{this.renderContent()} {this.renderContent()}

View File

@ -1,5 +1,6 @@
import { createNamespace, addUnit } from '../utils'; import { createNamespace, addUnit } from '../utils';
import { ParentMixin } from '../mixins/relation'; import { ParentMixin } from '../mixins/relation';
import { BORDER_TOP } from '../utils/constant';
const [createComponent, bem] = createNamespace('grid'); const [createComponent, bem] = createNamespace('grid');
@ -40,7 +41,7 @@ export default createComponent({
return ( return (
<div <div
style={this.style} style={this.style}
class={[bem(), { 'van-hairline--top': this.border && !this.gutter }]} class={[bem(), { [BORDER_TOP]: this.border && !this.gutter }]}
> >
{this.slots()} {this.slots()}
</div> </div>

View File

@ -41,7 +41,7 @@
<script> <script>
import icons from '@vant/icons'; import icons from '@vant/icons';
import { BLUE } from '../../utils/color'; import { BLUE } from '../../utils/constant';
export default { export default {
i18n: { i18n: {

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { ChildrenMixin } from '../mixins/relation'; import { ChildrenMixin } from '../mixins/relation';
import { BORDER_BOTTOM } from '../utils/constant';
const [createComponent, bem] = createNamespace('index-anchor'); const [createComponent, bem] = createNamespace('index-anchor');
@ -50,7 +51,7 @@ export default createComponent({
<div style={{ height: sticky ? `${this.height}px` : null }}> <div style={{ height: sticky ? `${this.height}px` : null }}>
<div <div
style={this.anchorStyle} style={this.anchorStyle}
class={[bem({ sticky }), { 'van-hairline--bottom': sticky }]} class={[bem({ sticky }), { [BORDER_BOTTOM]: sticky }]}
> >
{this.slots('default') || this.index} {this.slots('default') || this.index}
</div> </div>

View File

@ -2,7 +2,7 @@ import { createNamespace } from '../utils';
import { TouchMixin } from '../mixins/touch'; import { TouchMixin } from '../mixins/touch';
import { ParentMixin } from '../mixins/relation'; import { ParentMixin } from '../mixins/relation';
import { BindEventMixin } from '../mixins/bind-event'; import { BindEventMixin } from '../mixins/bind-event';
import { GREEN } from '../utils/color'; import { GREEN } from '../utils/constant';
import { import {
getScrollTop, getScrollTop,
getElementTop, getElementTop,

View File

@ -1,5 +1,5 @@
import { createNamespace, addUnit } from '../utils'; import { createNamespace, addUnit } from '../utils';
import { GRAY } from '../utils/color'; import { GRAY } from '../utils/constant';
import { inherit } from '../utils/functional'; import { inherit } from '../utils/functional';
// Types // Types

View File

@ -1,5 +1,6 @@
import { createNamespace, noop } from '../utils'; import { createNamespace, noop } from '../utils';
import { inherit } from '../utils/functional'; import { inherit } from '../utils/functional';
import { BORDER_BOTTOM } from '../utils/constant';
import Icon from '../icon'; import Icon from '../icon';
// Types // Types
@ -39,7 +40,7 @@ function NavBar(
<div <div
class={[ class={[
bem({ fixed: props.fixed }), bem({ fixed: props.fixed }),
{ 'van-hairline--bottom': props.border } { [BORDER_BOTTOM]: props.border }
]} ]}
style={{ zIndex: props.zIndex }} style={{ zIndex: props.zIndex }}
{...inherit(ctx)} {...inherit(ctx)}

View File

@ -1,5 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { RED, WHITE } from '../utils/color'; import { RED, WHITE } from '../utils/constant';
import { inherit } from '../utils/functional'; import { inherit } from '../utils/functional';
import { PopupMixin } from '../mixins/popup'; import { PopupMixin } from '../mixins/popup';
import Popup from '../popup'; import Popup from '../popup';

View File

@ -1,6 +1,6 @@
import Vue from 'vue'; import Vue from 'vue';
import VanNotify from './Notify'; import VanNotify from './Notify';
import { RED, WHITE } from '../utils/color'; import { RED, WHITE } from '../utils/constant';
import { isObj, isServer } from '../utils'; import { isObj, isServer } from '../utils';
import { mount } from '../utils/functional'; import { mount } from '../utils/functional';
import { NotifyOptions } from 'types/notify'; import { NotifyOptions } from 'types/notify';

View File

@ -1,4 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { BORDER } from '../utils/constant';
const [createComponent, bem] = createNamespace('key'); const [createComponent, bem] = createNamespace('key');
@ -54,7 +55,7 @@ export default createComponent({
<i <i
role="button" role="button"
tabindex="0" tabindex="0"
class={['van-hairline', this.className]} class={[BORDER, this.className]}
onClick={this.onClick} onClick={this.onClick}
onTouchstart={this.onFocus} onTouchstart={this.onFocus}
onTouchmove={onBlur} onTouchmove={onBlur}

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { stopPropagation } from '../utils/dom/event'; import { stopPropagation } from '../utils/dom/event';
import { BORDER_TOP } from '../utils/constant';
import { BindEventMixin } from '../mixins/bind-event'; import { BindEventMixin } from '../mixins/bind-event';
import Key from './Key'; import Key from './Key';
@ -137,7 +138,7 @@ export default createComponent({
const showTitle = title || showTitleClose || titleLeftSlot; const showTitle = title || showTitleClose || titleLeftSlot;
const Title = showTitle && ( const Title = showTitle && (
<div class={[bem('title'), 'van-hairline--top']}> <div class={[bem('title'), BORDER_TOP]}>
{titleLeftSlot && <span class={bem('title-left')}>{titleLeftSlot}</span>} {titleLeftSlot && <span class={bem('title-left')}>{titleLeftSlot}</span>}
{title && <span>{title}</span>} {title && <span>{title}</span>}
{showTitleClose && ( {showTitleClose && (

View File

@ -1,4 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { BORDER } from '../utils/constant';
const [createComponent, bem, t] = createNamespace('pagination'); const [createComponent, bem, t] = createNamespace('pagination');
@ -125,14 +126,14 @@ export default createComponent({
return ( return (
<ul class={bem({ simple })}> <ul class={bem({ simple })}>
<li <li
class={[bem('item', { disabled: value === 1 }), bem('prev'), 'van-hairline']} class={[bem('item', { disabled: value === 1 }), bem('prev'), BORDER]}
onClick={onSelect(value - 1)} onClick={onSelect(value - 1)}
> >
{this.prevText || t('prev')} {this.prevText || t('prev')}
</li> </li>
{this.pages.map(page => ( {this.pages.map(page => (
<li <li
class={[bem('item', { active: page.active }), bem('page'), 'van-hairline']} class={[bem('item', { active: page.active }), bem('page'), BORDER]}
onClick={onSelect(page.number)} onClick={onSelect(page.number)}
> >
{page.text} {page.text}
@ -142,7 +143,7 @@ export default createComponent({
<li class={bem('page-desc')}>{this.slots('pageDesc') || `${value}/${this.count}`}</li> <li class={bem('page-desc')}>{this.slots('pageDesc') || `${value}/${this.count}`}</li>
)} )}
<li <li
class={[bem('item', { disabled: value === this.count }), bem('next'), 'van-hairline']} class={[bem('item', { disabled: value === this.count }), bem('next'), BORDER]}
onClick={onSelect(value + 1)} onClick={onSelect(value + 1)}
> >
{this.nextText || t('next')} {this.nextText || t('next')}

View File

@ -1,7 +1,8 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { inherit } from '../utils/functional';
import { BORDER_TOP } from '../utils/constant';
import Cell from '../cell'; import Cell from '../cell';
import CellGroup from '../cell-group'; import CellGroup from '../cell-group';
import { inherit } from '../utils/functional';
// Types // Types
import { CreateElement, RenderContext } from 'vue/types'; import { CreateElement, RenderContext } from 'vue/types';
@ -42,7 +43,7 @@ function Panel(
), ),
<div class={bem('content')}>{slots.default && slots.default()}</div>, <div class={bem('content')}>{slots.default && slots.default()}</div>,
slots.footer && ( slots.footer && (
<div class={[bem('footer'), 'van-hairline--top']}>{slots.footer()}</div> <div class={[bem('footer'), BORDER_TOP]}>{slots.footer()}</div>
) )
]; ];

View File

@ -1,5 +1,6 @@
import { createNamespace, addUnit } from '../utils'; import { createNamespace, addUnit } from '../utils';
import { emit, inherit } from '../utils/functional'; import { emit, inherit } from '../utils/functional';
import { BORDER_LEFT, BORDER_SURROUND } from '../utils/constant';
// Types // Types
import { CreateElement, RenderContext } from 'vue/types'; import { CreateElement, RenderContext } from 'vue/types';
@ -35,7 +36,7 @@ function PasswordInput(
} }
Points.push( Points.push(
<li class={{ 'van-hairline--left': showBorder }} style={style}> <li class={{ [BORDER_LEFT]: showBorder }} style={style}>
{props.mask ? <i style={{ visibility: char ? 'visible' : 'hidden' }} /> : char} {props.mask ? <i style={{ visibility: char ? 'visible' : 'hidden' }} /> : char}
</li> </li>
); );
@ -44,7 +45,7 @@ function PasswordInput(
return ( return (
<div class={bem()}> <div class={bem()}>
<ul <ul
class={[bem('security'), { 'van-hairline--surround': !props.gutter }]} class={[bem('security'), { [BORDER_SURROUND]: !props.gutter }]}
onTouchstart={(event: TouchEvent) => { onTouchstart={(event: TouchEvent) => {
event.stopPropagation(); event.stopPropagation();
emit(ctx, 'focus', event); emit(ctx, 'focus', event);

View File

@ -2,7 +2,7 @@ import { createNamespace } from '../utils';
import { preventDefault } from '../utils/dom/event'; import { preventDefault } from '../utils/dom/event';
import { deepClone } from '../utils/deep-clone'; import { deepClone } from '../utils/deep-clone';
import { pickerProps } from './shared'; import { pickerProps } from './shared';
import { BLUE } from '../utils/color'; import { BLUE, BORDER_TOP_BOTTOM } from '../utils/constant';
import Loading from '../loading'; import Loading from '../loading';
import PickerColumn from './PickerColumn'; import PickerColumn from './PickerColumn';
@ -163,7 +163,7 @@ export default createComponent({
}; };
const Toolbar = this.showToolbar && ( const Toolbar = this.showToolbar && (
<div class={['van-hairline--top-bottom', bem('toolbar')]}> <div class={[BORDER_TOP_BOTTOM, bem('toolbar')]}>
{this.slots() || [ {this.slots() || [
<div role="button" tabindex="0" class={bem('cancel')} onClick={this.onCancel}> <div role="button" tabindex="0" class={bem('cancel')} onClick={this.onCancel}>
{this.cancelButtonText || t('cancel')} {this.cancelButtonText || t('cancel')}
@ -198,7 +198,7 @@ export default createComponent({
/> />
))} ))}
<div class={bem('mask')} style={maskStyle} /> <div class={bem('mask')} style={maskStyle} />
<div class={['van-hairline--top-bottom', bem('frame')]} style={frameStyle} /> <div class={[BORDER_TOP_BOTTOM, bem('frame')]} style={frameStyle} />
</div> </div>
{this.toolbarPosition === 'bottom' ? Toolbar : h()} {this.toolbarPosition === 'bottom' ? Toolbar : h()}
</div> </div>

View File

@ -1,5 +1,5 @@
import { createNamespace, isDef } from '../utils'; import { createNamespace, isDef } from '../utils';
import { BLUE, WHITE } from '../utils/color'; import { BLUE, WHITE } from '../utils/constant';
const [createComponent, bem] = createNamespace('progress'); const [createComponent, bem] = createNamespace('progress');

View File

@ -1,7 +1,8 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import Info from '../info';
import { ChildrenMixin } from '../mixins/relation'; import { ChildrenMixin } from '../mixins/relation';
import { route, routeProps } from '../utils/router'; import { route, routeProps } from '../utils/router';
import { BORDER } from '../utils/constant';
import Info from '../info';
const [createComponent, bem] = createNamespace('sidebar-item'); const [createComponent, bem] = createNamespace('sidebar-item');
@ -32,7 +33,7 @@ export default createComponent({
render() { render() {
return ( return (
<a <a
class={[bem({ select: this.select }), 'van-hairline']} class={[bem({ select: this.select }), BORDER]}
onClick={this.onClick} onClick={this.onClick}
> >
<div class={bem('text')}> <div class={bem('text')}>

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { ParentMixin } from '../mixins/relation'; import { ParentMixin } from '../mixins/relation';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
const [createComponent, bem] = createNamespace('sidebar'); const [createComponent, bem] = createNamespace('sidebar');
@ -18,6 +19,6 @@ export default createComponent({
}, },
render() { render() {
return <div class={[bem(), 'van-hairline--top-bottom']}>{this.slots()}</div>; return <div class={[bem(), BORDER_TOP_BOTTOM]}>{this.slots()}</div>;
} }
}); });

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../../utils'; import { createNamespace } from '../../utils';
import { inherit } from '../../utils/functional'; import { inherit } from '../../utils/functional';
import { BORDER_BOTTOM } from '../../utils/constant';
import Icon from '../../icon'; import Icon from '../../icon';
// Types // Types
@ -45,7 +46,7 @@ function SkuHeader(
}; };
return ( return (
<div class={[bem(), 'van-hairline--bottom']} {...inherit(ctx)}> <div class={[bem(), BORDER_BOTTOM]} {...inherit(ctx)}>
<div class={bem('img-wrap')} onClick={previewImage}> <div class={bem('img-wrap')} onClick={previewImage}>
<img src={goodsImg} /> <img src={goodsImg} />
</div> </div>

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../../utils'; import { createNamespace } from '../../utils';
import { inherit } from '../../utils/functional'; import { inherit } from '../../utils/functional';
import { BORDER_BOTTOM } from '../../utils/constant';
// Types // Types
import { CreateElement, RenderContext } from 'vue/types'; import { CreateElement, RenderContext } from 'vue/types';
@ -19,7 +20,7 @@ function SkuRow(
ctx: RenderContext<SkuRowProps> ctx: RenderContext<SkuRowProps>
) { ) {
return ( return (
<div class={[bem(), 'van-hairline--bottom']} {...inherit(ctx)}> <div class={[bem(), BORDER_BOTTOM]} {...inherit(ctx)}>
<div class={bem('title')}>{props.skuRow.k}</div> <div class={bem('title')}>{props.skuRow.k}</div>
{slots.default && slots.default()} {slots.default && slots.default()}
</div> </div>

View File

@ -1,4 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { BORDER } from '../utils/constant';
import Icon from '../icon'; import Icon from '../icon';
const [createComponent, bem] = createNamespace('step'); const [createComponent, bem] = createNamespace('step');
@ -54,7 +55,7 @@ export default createComponent({
} }
return ( return (
<div class={['van-hairline', bem([direction, { [status]: status }])]}> <div class={[BORDER, bem([direction, { [status]: status }])]}>
<div class={bem('title')} style={titleStyle}> <div class={bem('title')} style={titleStyle}>
{this.slots()} {this.slots()}
</div> </div>

View File

@ -1,5 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { GREEN } from '../utils/color'; import { GREEN } from '../utils/constant';
const [createComponent, bem] = createNamespace('steps'); const [createComponent, bem] = createNamespace('steps');

View File

@ -1,5 +1,5 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { BLUE, GRAY_DARK } from '../utils/color'; import { BLUE, GRAY_DARK } from '../utils/constant';
import { switchProps, SharedSwitchProps } from './shared'; import { switchProps, SharedSwitchProps } from './shared';
import { emit, inherit } from '../utils/functional'; import { emit, inherit } from '../utils/functional';
import Loading from '../loading'; import Loading from '../loading';

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { ParentMixin } from '../mixins/relation'; import { ParentMixin } from '../mixins/relation';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
const [createComponent, bem] = createNamespace('tabbar'); const [createComponent, bem] = createNamespace('tabbar');
@ -54,7 +55,7 @@ export default createComponent({
<div <div
style={{ zIndex: this.zIndex }} style={{ zIndex: this.zIndex }}
class={[ class={[
{ 'van-hairline--top-bottom': this.border }, { [BORDER_TOP_BOTTOM]: this.border },
bem({ bem({
fixed: this.fixed, fixed: this.fixed,
'safe-area-inset-bottom': this.safeAreaInsetBottom 'safe-area-inset-bottom': this.safeAreaInsetBottom

View File

@ -3,6 +3,7 @@ import { scrollLeftTo } from './utils';
import { isHidden } from '../utils/dom/style'; import { isHidden } from '../utils/dom/style';
import { ParentMixin } from '../mixins/relation'; import { ParentMixin } from '../mixins/relation';
import { BindEventMixin } from '../mixins/bind-event'; import { BindEventMixin } from '../mixins/bind-event';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
import { setRootScrollTop, getElementTop } from '../utils/dom/scroll'; import { setRootScrollTop, getElementTop } from '../utils/dom/scroll';
import Title from './Title'; import Title from './Title';
import Content from './Content'; import Content from './Content';
@ -282,7 +283,7 @@ export default createComponent({
ref="wrap" ref="wrap"
class={[ class={[
bem('wrap', { scrollable }), bem('wrap', { scrollable }),
{ 'van-hairline--top-bottom': type === 'line' && this.border } { [BORDER_TOP_BOTTOM]: type === 'line' && this.border }
]} ]}
> >
<div ref="nav" role="tablist" class={bem('nav', [type])} style={this.navStyle}> <div ref="nav" role="tablist" class={bem('nav', [type])} style={this.navStyle}>

View File

@ -1,5 +1,6 @@
import { createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { inherit } from '../utils/functional'; import { inherit } from '../utils/functional';
import { BORDER_SURROUND } from '../utils/constant';
// Types // Types
import { CreateElement, RenderContext } from 'vue/types'; import { CreateElement, RenderContext } from 'vue/types';
@ -46,9 +47,7 @@ function Tag(
style={style} style={style}
class={[ class={[
bem([classes, type]), bem([classes, type]),
{ { [BORDER_SURROUND]: plain }
'van-hairline--surround': plain
}
]} ]}
{...inherit(ctx, true)} {...inherit(ctx, true)}
> >

View File

@ -1,6 +0,0 @@
export const RED = '#f44';
export const BLUE = '#1989fa';
export const GREEN = '#07c160';
export const WHITE = '#fff';
export const GRAY = '#c9c9c9';
export const GRAY_DARK = '#969799';

16
src/utils/constant.ts Normal file
View File

@ -0,0 +1,16 @@
// color
export const RED = '#f44';
export const BLUE = '#1989fa';
export const GREEN = '#07c160';
export const WHITE = '#fff';
export const GRAY = '#c9c9c9';
export const GRAY_DARK = '#969799';
// border
export const BORDER = 'van-hairline';
export const BORDER_TOP = `${BORDER}--top`;
export const BORDER_LEFT = `${BORDER}--left`;
export const BORDER_RIGHT = `${BORDER}--right`;
export const BORDER_BOTTOM = `${BORDER}--bottom`;
export const BORDER_SURROUND = `${BORDER}--surround`;
export const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;