diff --git a/components/index.js b/components/index.js index 59fe61528..0f80d68f4 100644 --- a/components/index.js +++ b/components/index.js @@ -23,3 +23,5 @@ export { default as Tag } from './tag' export { default as Avatar } from './avatar' export { default as Badge } from './badge' + +export { default as Tabs } from './tabs' diff --git a/components/style.js b/components/style.js index 3a3d9aeec..8c8c5c93f 100644 --- a/components/style.js +++ b/components/style.js @@ -8,3 +8,4 @@ import './rate/style' import './pagination/style' import './avatar/style' import './badge/style' +import './tabs/style' diff --git a/components/tabs/KeyCode.js b/components/tabs/KeyCode.js new file mode 100644 index 000000000..d4203174f --- /dev/null +++ b/components/tabs/KeyCode.js @@ -0,0 +1,18 @@ +export default { + /** + * LEFT + */ + LEFT: 37, // also NUM_WEST + /** + * UP + */ + UP: 38, // also NUM_NORTH + /** + * RIGHT + */ + RIGHT: 39, // also NUM_EAST + /** + * DOWN + */ + DOWN: 40, // also NUM_SOUTH +} diff --git a/components/tabs/RefMixin.js b/components/tabs/RefMixin.js new file mode 100644 index 000000000..fdb8792ab --- /dev/null +++ b/components/tabs/RefMixin.js @@ -0,0 +1,7 @@ +export default { + saveRef (name) { + return node => { + this[name] = node + } + }, +} diff --git a/components/tabs/TabBar.vue b/components/tabs/TabBar.vue new file mode 100644 index 000000000..253b443ce --- /dev/null +++ b/components/tabs/TabBar.vue @@ -0,0 +1,75 @@ + + diff --git a/components/tabs/TabContent.vue b/components/tabs/TabContent.vue index e69de29bb..0a69ec3e2 100644 --- a/components/tabs/TabContent.vue +++ b/components/tabs/TabContent.vue @@ -0,0 +1,66 @@ + diff --git a/components/tabs/TabPane.vue b/components/tabs/TabPane.vue index e69de29bb..66d8c55a9 100644 --- a/components/tabs/TabPane.vue +++ b/components/tabs/TabPane.vue @@ -0,0 +1,48 @@ + + diff --git a/components/tabs/Tabs.vue b/components/tabs/Tabs.vue index e69de29bb..a25534b96 100644 --- a/components/tabs/Tabs.vue +++ b/components/tabs/Tabs.vue @@ -0,0 +1,174 @@ + diff --git a/components/tabs/demo/basic.vue b/components/tabs/demo/basic.vue new file mode 100644 index 000000000..c8d38a1f9 --- /dev/null +++ b/components/tabs/demo/basic.vue @@ -0,0 +1,17 @@ + + diff --git a/components/tabs/index.js b/components/tabs/index.js index 74d5a2707..6a4be685d 100644 --- a/components/tabs/index.js +++ b/components/tabs/index.js @@ -1,6 +1,6 @@ import Tabs from './Tabs' import TabPane from './TabPane' -import TabContent from './TabContent' - +// import TabContent from './TabContent' +Tabs.TabPane = TabPane export default Tabs -export { TabPane, TabContent } +export { TabPane } diff --git a/components/tabs/utils.js b/components/tabs/utils.js index 5c9323e2f..bb444f6ce 100644 --- a/components/tabs/utils.js +++ b/components/tabs/utils.js @@ -1,3 +1,29 @@ +export function toArray (children) { + // allow [c,[a,b]] + const c = [] + children.forEach(child => { + if (child.data) { + c.push(child) + } + }) + return c +} + +export function getActiveIndex (children, activeKey) { + const c = toArray(children) + for (let i = 0; i < c.length; i++) { + const pKey = c[i].pKey || c[i].componentOptions.propsData.pKey + if (pKey === activeKey) { + return i + } + } + return -1 +} + +export function getActiveKey (children, index) { + const c = toArray(children) + return c[index].pKey +} export function setTransform (style, v) { style.transform = v