From 8972f980d0dddee30fd61ebaa0f75fc07a7a36b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=84=B6=E5=88=99?= Date: Tue, 11 Oct 2016 18:23:59 +0800 Subject: [PATCH] add data-api support for log statistics --- components/_util/getDataAttr.tsx | 9 +++++++++ components/action-sheet/demo/basic.md | 1 + components/action-sheet/index.web.tsx | 13 +------------ components/button/demo/basic.md | 2 +- components/checkbox/AgreeItem.web.tsx | 3 ++- components/checkbox/CheckboxItem.web.tsx | 3 ++- components/checkbox/demo/agreeitem.md | 2 +- components/checkbox/demo/checkboxitem.md | 2 +- components/input-item/demo/1.md | 3 ++- components/input-item/index.web.tsx | 3 ++- components/list-view/index.md | 2 +- components/list/ListItem.web.tsx | 3 ++- components/list/demo/basic.md | 2 +- components/notice-bar/demo/link.md | 2 +- components/notice-bar/index.web.tsx | 3 ++- components/popover/demo/basic.md | 2 +- components/popover/index.web.tsx | 2 +- components/popover/{item.tsx => item.web.tsx} | 0 components/radio/RadioItem.web.tsx | 3 ++- components/radio/demo/RadioItem.md | 1 + components/tab-bar/Tab.web.tsx | 2 +- components/tab-bar/demo/basic.md | 2 ++ components/tab-bar/index.web.tsx | 2 ++ components/tag/demo/basic.md | 2 +- components/tag/index.web.tsx | 3 ++- components/textarea-item/demo/1.md | 3 ++- components/textarea-item/index.web.tsx | 3 ++- 27 files changed, 46 insertions(+), 32 deletions(-) create mode 100644 components/_util/getDataAttr.tsx rename components/popover/{item.tsx => item.web.tsx} (100%) diff --git a/components/_util/getDataAttr.tsx b/components/_util/getDataAttr.tsx new file mode 100644 index 0000000000..a21d18f3d3 --- /dev/null +++ b/components/_util/getDataAttr.tsx @@ -0,0 +1,9 @@ +export default function getDataAttr(props) { + const dataAttrs = {}; + Object.keys(props).forEach(i => { + if (i.indexOf('data-') === 0) { + dataAttrs[i] = props[i]; + } + }); + return dataAttrs; +} diff --git a/components/action-sheet/demo/basic.md b/components/action-sheet/demo/basic.md index eec19423ab..de5cdc71b1 100644 --- a/components/action-sheet/demo/basic.md +++ b/components/action-sheet/demo/basic.md @@ -24,6 +24,7 @@ const Test = React.createClass({ // title: '标题', message: '我是描述我是描述', maskClosable: true, + 'data-seed': 'logId', }, (buttonIndex) => { this.setState({ clicked: BUTTONS[buttonIndex] }); diff --git a/components/action-sheet/index.web.tsx b/components/action-sheet/index.web.tsx index a856620efe..4d11341fc7 100644 --- a/components/action-sheet/index.web.tsx +++ b/components/action-sheet/index.web.tsx @@ -6,23 +6,12 @@ import Dialog from 'rc-dialog'; import classNames from 'classnames'; import Icon from '../icon/index.web'; import assign from 'object-assign'; +import getDataAttr from '../_util/getDataAttr'; import ButtonListItem from './ButtonListItem.web'; const NORMAL = 'NORMAL'; const SHARE = 'SHARE'; - function noop() { } - -function getDataAttr(props) { - const dataAttrs = {}; - Object.keys(props).forEach(i => { - if (i.indexOf('data-') === 0) { - dataAttrs[i] = props[i]; - } - }); - return dataAttrs; -} - const queue = []; function createActionSheet(flag, config, callback) { diff --git a/components/button/demo/basic.md b/components/button/demo/basic.md index 31026166b3..7e4dad7e39 100644 --- a/components/button/demo/basic.md +++ b/components/button/demo/basic.md @@ -19,7 +19,7 @@ const ButtonExample = React.createClass({
- +
diff --git a/components/checkbox/AgreeItem.web.tsx b/components/checkbox/AgreeItem.web.tsx index 08887f9223..0b797b5911 100644 --- a/components/checkbox/AgreeItem.web.tsx +++ b/components/checkbox/AgreeItem.web.tsx @@ -2,6 +2,7 @@ import React from 'react'; import classNames from 'classnames'; import Checkbox from './Checkbox.web'; import AgreeItemProps from './AgreeItemPropsType'; +import getDataAttr from '../_util/getDataAttr'; export default class AgreeItem extends React.Component { static defaultProps = { @@ -15,7 +16,7 @@ export default class AgreeItem extends React.Component { [className]: className, }); - return (
diff --git a/components/checkbox/CheckboxItem.web.tsx b/components/checkbox/CheckboxItem.web.tsx index 524cafa747..b96013ee68 100644 --- a/components/checkbox/CheckboxItem.web.tsx +++ b/components/checkbox/CheckboxItem.web.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import Checkbox from './Checkbox.web'; import List from '../list/index.web'; import CheckboxItemProps from './CheckboxItemPropsType'; +import getDataAttr from '../_util/getDataAttr'; const ListItem = List.Item; @@ -25,7 +26,7 @@ export default class CheckboxItem extends React.Component {} }; - return ( '多项选择操作'} > - 非受控 , mountNode); .demoTitle:after { border-bottom: none; } -```` \ No newline at end of file +```` diff --git a/components/input-item/index.web.tsx b/components/input-item/index.web.tsx index 0737c7c332..ff6dea97b3 100644 --- a/components/input-item/index.web.tsx +++ b/components/input-item/index.web.tsx @@ -2,6 +2,7 @@ import React from 'react'; import classNames from 'classnames'; function noop() { } import InputItemProps from './InputItemPropsType'; +import getDataAttr from '../_util/getDataAttr'; function fixControlledValue(value) { if (typeof value === 'undefined' || value === null) { @@ -180,7 +181,7 @@ export default class InputItem extends React.Component +
{children ? (
{children}
) : null}
注意:由于需要直接scroll到任意位置、只支持分两步渲染,所以列表数据量过大时、性能会有影响 支持右侧导航功能 diff --git a/components/list/ListItem.web.tsx b/components/list/ListItem.web.tsx index f7d210d263..e3dcfb8ad4 100644 --- a/components/list/ListItem.web.tsx +++ b/components/list/ListItem.web.tsx @@ -1,6 +1,7 @@ import React from 'react'; import classNames from 'classnames'; import { ListItemProps, BriefProps } from './ListPropTypes'; +import getDataAttr from '../_util/getDataAttr'; export class Brief extends React.Component { render() { @@ -102,7 +103,7 @@ export default class ListItem extends React.Component { } return ( -
'我是华丽丽的列表头部'} renderFooter={() => '我是列表尾部'} > - 标题文字点击无反馈,文字超长则隐藏 + 标题文字点击无反馈,文字超长则隐藏 文字超长折行文字超长折行文字超长折行文字超长折行文字超长折行文字超长折行 {}} diff --git a/components/notice-bar/demo/link.md b/components/notice-bar/demo/link.md index 2b8cdb2346..2bf95e1e72 100644 --- a/components/notice-bar/demo/link.md +++ b/components/notice-bar/demo/link.md @@ -17,7 +17,7 @@ const NoticeBarExample = React.createClass({ return (
- + 国庆期间余额宝收益和转出到账时间 diff --git a/components/notice-bar/index.web.tsx b/components/notice-bar/index.web.tsx index 5cac126016..71616be4f9 100644 --- a/components/notice-bar/index.web.tsx +++ b/components/notice-bar/index.web.tsx @@ -1,6 +1,7 @@ /* tslint:disable:no-switch-case-fall-through */ import React from 'react'; import classNames from 'classnames'; +import getDataAttr from '../_util/getDataAttr'; import Icon from '../icon'; import NoticeBarProps from './NoticeBarPropsType'; @@ -81,7 +82,7 @@ export default class NoticeBar extends React.Component {
: null; return this.state.show ? ( -
+
{iconDom}
{children}
{operationDom} diff --git a/components/popover/demo/basic.md b/components/popover/demo/basic.md index 0e974d9584..6946889471 100644 --- a/components/popover/demo/basic.md +++ b/components/popover/demo/basic.md @@ -34,7 +34,7 @@ const App = React.createClass({ 扫一扫), + (扫一扫), (我的二维码), ( 帮助 diff --git a/components/popover/index.web.tsx b/components/popover/index.web.tsx index 4c85194cb4..3e90249377 100644 --- a/components/popover/index.web.tsx +++ b/components/popover/index.web.tsx @@ -1,6 +1,6 @@ import React from 'react'; import Tooltip from 'rc-tooltip'; -import Item from './item'; +import Item from './item.web'; import splitObject from '../_util/splitObject'; import tsPropsType from './PropsType'; diff --git a/components/popover/item.tsx b/components/popover/item.web.tsx similarity index 100% rename from components/popover/item.tsx rename to components/popover/item.web.tsx diff --git a/components/radio/RadioItem.web.tsx b/components/radio/RadioItem.web.tsx index 549ae822a0..6d628ffa99 100644 --- a/components/radio/RadioItem.web.tsx +++ b/components/radio/RadioItem.web.tsx @@ -2,6 +2,7 @@ import React from 'react'; import classNames from 'classnames'; import Radio from './Radio.web'; import List from '../list'; +import getDataAttr from '../_util/getDataAttr'; const ListItem = List.Item; @@ -25,7 +26,7 @@ export default class RadioItem extends React.Component { const onClickProps = disabled ? {} : { onClick: () => {} }; - return ( 博士 diff --git a/components/tab-bar/Tab.web.tsx b/components/tab-bar/Tab.web.tsx index 1c7336e117..49ef23e53a 100644 --- a/components/tab-bar/Tab.web.tsx +++ b/components/tab-bar/Tab.web.tsx @@ -9,7 +9,7 @@ class Tab extends React.Component { const iconRes = selected ? selectedIcon : icon; return ( -
+
{ badge ? ( diff --git a/components/tab-bar/demo/basic.md b/components/tab-bar/demo/basic.md index 9ec8f1377a..81b9afb4ab 100644 --- a/components/tab-bar/demo/basic.md +++ b/components/tab-bar/demo/basic.md @@ -52,6 +52,7 @@ const TabBarExample = React.createClass({ selectedTab: 'blueTab', }); }} + data-seed="logId" > {this.renderContent('生活')} @@ -67,6 +68,7 @@ const TabBarExample = React.createClass({ selectedTab: 'redTab', }); }} + data-seed="logId1" > {this.renderContent('口碑')} diff --git a/components/tab-bar/index.web.tsx b/components/tab-bar/index.web.tsx index 83ef4eee6f..fb9c6d7844 100644 --- a/components/tab-bar/index.web.tsx +++ b/components/tab-bar/index.web.tsx @@ -3,6 +3,7 @@ import Tabs, { TabPane } from 'rc-tabs'; import Tab from './Tab.web'; import TabContent from 'rc-tabs/lib/TabContent'; import TabBar from 'rc-tabs/lib/TabBar'; +import getDataAttr from '../_util/getDataAttr'; const AntTabBar = React.createClass({ statics: { @@ -57,6 +58,7 @@ const AntTabBar = React.createClass({ title={cProps.title} tintColor={tintColor} unselectedTintColor={unselectedTintColor} + dataAttrs={getDataAttr(cProps)} />); return ( - 通用标签 + 通用标签 默认选中 失效标签 事件回调 diff --git a/components/tag/index.web.tsx b/components/tag/index.web.tsx index c75fc7edae..7cc002c740 100644 --- a/components/tag/index.web.tsx +++ b/components/tag/index.web.tsx @@ -2,6 +2,7 @@ import React from 'react'; import classNames from 'classnames'; import TagProps from './TagPropsType'; import Icon from '../icon'; +import getDataAttr from '../_util/getDataAttr'; export default class Tag extends React.Component { static defaultProps = { @@ -63,7 +64,7 @@ export default class Tag extends React.Component { }); return !this.state.closed ? ( -
+
{children}
{ closable && !disabled && !small &&
, mountNode); .demoTitle:after { border-bottom: none; } -```` \ No newline at end of file +```` diff --git a/components/textarea-item/index.web.tsx b/components/textarea-item/index.web.tsx index 5c74479d44..10fb73a244 100644 --- a/components/textarea-item/index.web.tsx +++ b/components/textarea-item/index.web.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; function noop() {} import TextareaItemProps from './TextAreaItemPropsType'; +import getDataAttr from '../_util/getDataAttr'; function fixControlledValue(value) { if (typeof value === 'undefined' || value === null) { @@ -147,7 +148,7 @@ export default class TextareaItem extends React.Component +
{title ? (
{title}
) : null}