[improvement] rename packages dir to src (#3659)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van-info {
|
||||
position: absolute;
|
||||
top: -@info-size / 2;
|
||||
right: 0;
|
||||
box-sizing: border-box;
|
||||
min-width: @info-size;
|
||||
padding: @info-padding;
|
||||
color: @info-color;
|
||||
font-weight: @info-font-weight;
|
||||
font-size: @info-font-size;
|
||||
font-family: @info-font-family;
|
||||
line-height: @info-size - @info-border-width * 2;
|
||||
text-align: center;
|
||||
background-color: @info-background-color;
|
||||
border: @info-border-width solid @white;
|
||||
border-radius: @info-size;
|
||||
transform: translateX(50%);
|
||||
transform-origin: 100%;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { createNamespace, isDef } from '../utils';
|
||||
import { inherit } from '../utils/functional';
|
||||
|
||||
// Types
|
||||
import { CreateElement, RenderContext } from 'vue/types';
|
||||
import { DefaultSlots } from '../utils/types';
|
||||
|
||||
export type InfoProps = {
|
||||
info?: string | number;
|
||||
};
|
||||
|
||||
const [createComponent, bem] = createNamespace('info');
|
||||
|
||||
function Info(
|
||||
h: CreateElement,
|
||||
props: InfoProps,
|
||||
slots: DefaultSlots,
|
||||
ctx: RenderContext<InfoProps>
|
||||
) {
|
||||
if (!isDef(props.info) || props.info === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={bem()} {...inherit(ctx, true)}>
|
||||
{props.info}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Info.props = {
|
||||
info: [String, Number]
|
||||
};
|
||||
|
||||
export default createComponent<InfoProps>(Info);
|
||||
@@ -0,0 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`should not render when info is empty string 1`] = ``;
|
||||
|
||||
exports[`should not render when info is empty undefined 1`] = ``;
|
||||
|
||||
exports[`should render when info is zero 1`] = `<div class="van-info">0</div>`;
|
||||
@@ -0,0 +1,32 @@
|
||||
import Info from '..';
|
||||
import { mount } from '../../../test/utils';
|
||||
|
||||
test('should not render when info is empty string', () => {
|
||||
const wrapper = mount(Info, {
|
||||
propsData: {
|
||||
info: ''
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should not render when info is empty undefined', () => {
|
||||
const wrapper = mount(Info, {
|
||||
propsData: {
|
||||
info: undefined
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should render when info is zero', () => {
|
||||
const wrapper = mount(Info, {
|
||||
propsData: {
|
||||
info: 0
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
Reference in New Issue
Block a user