Skip to content

Commit

Permalink
Merge branch 'master' into select
Browse files Browse the repository at this point in the history
  • Loading branch information
berber1016 authored Dec 21, 2020
2 parents 4ffb226 + 6af7df1 commit 7770c9a
Show file tree
Hide file tree
Showing 39 changed files with 1,373 additions and 1,118 deletions.
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gio-design/components",
"version": "20.12.2",
"version": "20.12.3",
"description": "GrowingIO Design components",
"author": "GrowingIO Frontend Team <eng-frontend@growingio.com>",
"module": "./es/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Avatar = React.forwardRef<HTMLSpanElement, AvatarProps>((props: AvatarProp
if (userName !== undefined && typeof userName === 'string') {
const prefixUserName = omit && typeof userName === 'string' ? userName.trim()[0].toUpperCase() : userName.trim();
return (
<span ref={childrenRef} style={childrenStyle}>
<span ref={childrenRef} style={childrenStyle} className={`${prefixCls}-string`}>
{prefixUserName}
</span>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Testing Avatar should be stable 1`] = `
className="gio-avatar gio-avatar-df"
>
<span
className="gio-avatar-string"
style={
Object {
"transform": "scale(1) translateX(-50%)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports[`Testing AvatarGroup should be stable 1`] = `
onMouseLeave={[Function]}
>
<span
className="gio-avatar-string"
style={
Object {
"transform": "scale(1) translateX(-50%)",
Expand Down Expand Up @@ -51,6 +52,7 @@ exports[`Testing AvatarGroup should be stable 1`] = `
onMouseLeave={[Function]}
>
<span
className="gio-avatar-string"
style={
Object {
"transform": "scale(1) translateX(-50%)",
Expand All @@ -64,6 +66,7 @@ exports[`Testing AvatarGroup should be stable 1`] = `
className="gio-avatar-rest gio-avatar gio-avatar-df"
>
<span
className="gio-avatar-string"
style={
Object {
"transform": "scale(1) translateX(-50%)",
Expand Down
15 changes: 6 additions & 9 deletions packages/components/src/components/avatar/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
opacity: 1;
user-select: none;

&:hover {
.@{avatar-prefix-cls}-droppable {
background-color: @color-background-avatar-hover-dropdown;

svg {
transform: scale(1);
}
&:hover &-droppable {
background-color: @color-background-avatar-hover-dropdown;
span {
transform: scale(1);
}
}

Expand All @@ -35,14 +32,14 @@
cursor: pointer;
transition: all 0.3s;

svg {
span {
vertical-align: middle;
transform: scale(0);
transition: all 0.3s;
}
}

span {
&-string {
position: absolute;
left: 50%;
transform-origin: 0 center;
Expand Down
22 changes: 1 addition & 21 deletions packages/components/src/components/cascader/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useState } from 'react';
import isEmpty from 'lodash/isEmpty';
import isFunction from 'lodash/isFunction';
import findIndex from 'lodash/findIndex';

import { NodeData, KeyMapping } from './menu-item';
Expand Down Expand Up @@ -76,25 +75,6 @@ export const dataKeyMapping = (data: NodeData, keyMapping = {} as KeyMapping) =>
return { ...data, label: label as NodeData['label'], value: value as NodeData['value'] };
};

/**
* 合并 ref
*/
export const useMergeRef = <T>(
forwardRef: React.MutableRefObject<T | null> | ((instance: T | null) => void) | null
) => {
const innerRef = useRef<T>((null as unknown) as T);
useEffect(() => {
if (isFunction(forwardRef)) {
forwardRef(innerRef.current);
} else if (forwardRef) {
// eslint-disable-next-line no-param-reassign
forwardRef.current = innerRef.current;
}
}, [innerRef, forwardRef]);

return innerRef;
};

export const useKeyboardNav = (wrapRef: React.MutableRefObject<HTMLElement>) => {
useEffect(() => {
const { current: wrapper } = wrapRef;
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/components/cascader/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import classNames from 'classnames';
import isEmpty from 'lodash/isEmpty';

import { Props as MenuItemProps, NodeData } from './menu-item';
import { dataKeyMapping, toInt, useDynamicData, useKeyboardNav, useMergeRef, withPrefix } from './helper';
import { dataKeyMapping, toInt, useDynamicData, useKeyboardNav, withPrefix } from './helper';
import SingleMenu, { Props as SingleMenuProps } from './single-menu';
import useMergeRef from '../../utils/hooks/useMergeRef';

export type Props = SingleMenuProps;

Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/components/cascader/single-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import isEmpty from 'lodash/isEmpty';
import isFunction from 'lodash/isFunction';
import trim from 'lodash/trim';

import { dataFilter, makeSearchParttern, mergeKeyMapping, toInt, useMergeRef, withPrefix } from './helper';
import useMergeRef from '../../utils/hooks/useMergeRef';
import { dataFilter, makeSearchParttern, mergeKeyMapping, toInt, withPrefix } from './helper';
import Empty from './empty';
import MenuItem, { Props as MenuItemProps, NodeData } from './menu-item';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ initialize {
"children": Array [
Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "请输入…",
"type": "text",
"value": "2015/06/01",
Expand Down Expand Up @@ -81,12 +81,12 @@ initialize {
"parent": [Circular],
"prev": Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "请输入…",
"type": "text",
"value": "2015/06/01",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ initialize {
"children": Array [
Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "please select",
"type": "text",
"value": "2015/06/01",
Expand Down Expand Up @@ -64,12 +64,12 @@ initialize {
"namespace": "http://www.w3.org/1999/xhtml",
"next": Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "please select",
"type": "text",
"value": "2015/06/02",
Expand Down Expand Up @@ -162,12 +162,12 @@ initialize {
"namespace": "http://www.w3.org/1999/xhtml",
"next": Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "please select",
"type": "text",
"value": "2015/06/02",
Expand Down Expand Up @@ -226,12 +226,12 @@ initialize {
"parent": [Circular],
"prev": Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "please select",
"type": "text",
"value": "2015/06/01",
Expand Down Expand Up @@ -280,12 +280,12 @@ initialize {
},
Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "please select",
"type": "text",
"value": "2015/06/02",
Expand Down Expand Up @@ -351,12 +351,12 @@ initialize {
"parent": [Circular],
"prev": Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "please select",
"type": "text",
"value": "2015/06/01",
Expand Down Expand Up @@ -422,12 +422,12 @@ initialize {
"parent": [Circular],
"prev": Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "please select",
"type": "text",
"value": "2015/06/02",
Expand Down Expand Up @@ -476,12 +476,12 @@ initialize {
"parent": [Circular],
"prev": Object {
"attribs": Object {
"class": "gio-input gio-input-container-middle",
"class": "gio-input gio-input--middle",
},
"children": Array [
Object {
"attribs": Object {
"class": "gio-input-content",
"class": "gio-input__content",
"placeholder": "please select",
"type": "text",
"value": "2015/06/01",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ describe('DatePicker ui test', () => {

it('should popup corretly', (done) => {
const wrapper = mount(DatePickerInstance());
wrapper.find('.gio-input-content').simulate('click');
wrapper.find('.gio-input__content').simulate('click');
waitComponentRender(wrapper).then(() => {
expect(wrapper.exists('.gio-input-content')).toBe(true);
expect(wrapper.exists('.gio-input__content')).toBe(true);
done();
});
});

it('should render corretly', () => {
const wrapper = mount(DatePickerInstance());
const content = wrapper.find('.gio-input-content');
const content = wrapper.find('.gio-input__content');
expect(content.html().includes('2015/05/01'));
});
});
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('DatePicker action Test', () => {
/>
);
act(() => {
wrapper.find('.gio-input-content').simulate('click');
wrapper.find('.gio-input__content').simulate('click');
})
waitComponentRender(wrapper).then(() => {
act(() => {
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('DatePicker action Test', () => {
/>
);
act(() => {
wrapper.find('.gio-input-content').simulate('click');
wrapper.find('.gio-input__content').simulate('click');
})
waitComponentRender(wrapper).then(() => {
act(() => {
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('DatePicker action Test', () => {
/>
);
act(() => {
wrapper.find('.gio-input-content').simulate('click');
wrapper.find('.gio-input__content').simulate('click');
})
waitComponentRender(wrapper).then(() => {
act(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ describe('DateRangePicker ui test', () => {

it('should popup corretly', (done) => {
const wrapper = mount(DateRangePickerInstance());
wrapper.find('.gio-input-content').at(0).simulate('click');
wrapper.find('.gio-input__content').at(0).simulate('click');
waitComponentRender(wrapper).then(() => {
expect(wrapper.exists('.gio-input-content')).toBe(true);
expect(wrapper.exists('.gio-input__content')).toBe(true);
done();
});
});

it('should render corretly', () => {
const wrapper = mount(DateRangePickerInstance());
const content = wrapper.find('.gio-input-content').at(0);
const content = wrapper.find('.gio-input__content').at(0);
expect(content.html().includes('2015/05/01'));
});
});
Expand All @@ -67,7 +67,7 @@ describe('DatePicker action Test', () => {
<DateRangePicker value={VALUE} onChange={onChange} format={format} showFooter disabledDate={disabledDate} />
);
act(() => {
wrapper.find('.gio-input-content').at(0).simulate('click');
wrapper.find('.gio-input__content').at(0).simulate('click');
});
waitComponentRender(wrapper).then(() => {
act(() => {
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('DatePicker action Test', () => {
/>
);
act(() => {
wrapper.find('.gio-input-content').at(0).simulate('click');
wrapper.find('.gio-input__content').at(0).simulate('click');
})
waitComponentRender(wrapper).then(() => {
act(() => {
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('DatePicker action Test', () => {
/>
);
act(() => {
wrapper.find('.gio-input-content').at(0).simulate('click');
wrapper.find('.gio-input__content').at(0).simulate('click');
})
waitComponentRender(wrapper).then(() => {
act(() => {
Expand Down
Loading

0 comments on commit 7770c9a

Please sign in to comment.