Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Fix/tabview (#139)
Browse files Browse the repository at this point in the history
* fixing lazy component

* adding lifecycle for tabbar and beagleChildren for lazy-component

* fixing tabview

* fixing tabview

* removing console.log

* removing unused file
  • Loading branch information
Tiagoperes authored Sep 4, 2020
1 parent 554ab03 commit 1fff68d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 0 additions & 4 deletions packages/beagle-react/src/components/BeagleTabBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
*/

import React, { FC } from 'react'
import { BeforeViewSnapshot } from '@zup-it/beagle-web'
import { BeagleDefaultComponent } from '../types'
import withTheme from '../utils/withTheme'
import { ImagePath } from '../BeagleImage'
import { transformItems } from './lifecycles'
import {
StyledTabBar,
StyledBeagleTabItem,
Expand Down Expand Up @@ -65,6 +63,4 @@ const BeagleTabBar: FC<BeagleTabBarInterface> = ({ onTabSelection, currentTab, i
)
}

BeforeViewSnapshot(transformItems)(BeagleTabBar)

export default withTheme(BeagleTabBar)
9 changes: 7 additions & 2 deletions packages/beagle-react/src/components/BeagleTabView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*/

import React, { FC, useState, useEffect } from 'react'
import { logger, BeforeViewSnapshot } from '@zup-it/beagle-web'
import withTheme from '../utils/withTheme'
import { BeagleDefaultComponent } from '../types'
import { BeagleComponentsProvider } from './context'
import { StyledTabView } from './styled'
import { transformItems } from './lifecycles'

export interface BeagleChildren {
key: string,
Expand All @@ -43,7 +45,7 @@ const BeagleTabView: FC<BeagleDefaultComponent> = props => {
const firstChildren = children[0] as BeagleChildren
tabViewContext.setActiveTab(firstChildren.key)
}
console.warn(`Tabview is deprecated. This will be removed in a future version.
logger.warn(`Tabview is deprecated. This will be removed in a future version.
Please consider replacing this component for a tabBar with a pageview.`)
}, [])

Expand All @@ -56,4 +58,7 @@ const BeagleTabView: FC<BeagleDefaultComponent> = props => {
)
}

export default withTheme(BeagleTabView)
const TabViewWithTheme = withTheme(BeagleTabView)
BeforeViewSnapshot(transformItems)(TabViewWithTheme)

export default TabViewWithTheme
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

export function transformItems(tabBar: Record<string, any>) {
if (!Array.isArray(tabBar.items)) return
tabBar.children = tabBar.items.map(item => ({
_beagleComponent_: 'beagle:tabitem',
id: `${tabBar.id}_${item.title}`,
...item,
}))
import { BeagleUIElement } from '@zup-it/beagle-web'

export function transformItems(tabView: Record<string, any>) {
if (!Array.isArray(tabView.children)) return
tabView.children.forEach((child: BeagleUIElement) => {
child._beagleComponent_ = 'beagle:tabitem'
})
}

0 comments on commit 1fff68d

Please sign in to comment.