diff --git a/src/components/SettingsPage/index.js b/src/components/SettingsPage/index.js index 725549f2..cfcc4bbf 100644 --- a/src/components/SettingsPage/index.js +++ b/src/components/SettingsPage/index.js @@ -13,9 +13,8 @@ import type { FetchCounterValues } from 'actions/counterValues' import { saveSettings } from 'actions/settings' import { fetchCounterValues } from 'actions/counterValues' +import Pills from 'components/base/Pills' import Box from 'components/base/Box' -import Text from 'components/base/Text' -import Tabs from 'components/base/Tabs' import TabDisplay from './Display' import TabProfile from './Profile' @@ -48,7 +47,12 @@ class SettingsPage extends PureComponent { tab: 0, } - handleChangeTab = (tab: number) => this.setState({ tab }) + _items = [] + + handleChangeTab = (item: any) => { + const tab = this._items.indexOf(item) + this.setState({ tab }) + } handleSaveSettings = newSettings => { const { fetchCounterValues, saveSettings, i18n, settings } = this.props @@ -75,53 +79,56 @@ class SettingsPage extends PureComponent { onSaveSettings: this.handleSaveSettings, } + this._items = [ + { + key: 'display', + label: t('settings:tabs.display'), + value: () => , + }, + { + key: 'money', + label: t('settings:tabs.money'), + value: () => , + }, + { + key: 'material', + isDisabled: true, + label: t('settings:tabs.material'), + value: () =>
{'Matériel'}
, + }, + { + key: 'app', + isDisabled: true, + label: t('settings:tabs.app'), + value: () =>
{'App (beta)'}
, + }, + { + key: 'tools', + label: t('settings:tabs.tools'), + value: () => , + }, + { + key: 'blockchain', + isDisabled: true, + label: t('settings:tabs.blockchain'), + value: () =>
{'Blockchain'}
, + }, + { + key: 'profile', + label: t('settings:tabs.profile'), + value: () => , + }, + ] + + const item = this._items[tab] + return ( - - {t('settings:title')} - , - }, - { - key: 'money', - title: t('settings:tabs.money'), - render: () => , - }, - { - key: 'material', - isDisabled: true, - title: t('settings:tabs.material'), - render: () =>
{'Matériel'}
, - }, - { - key: 'app', - isDisabled: true, - title: t('settings:tabs.app'), - render: () =>
{'App (beta)'}
, - }, - { - key: 'tools', - title: t('settings:tabs.tools'), - render: () => , - }, - { - key: 'blockchain', - isDisabled: true, - title: t('settings:tabs.blockchain'), - render: () =>
{'Blockchain'}
, - }, - { - key: 'profile', - title: t('settings:tabs.profile'), - render: () => , - }, - ]} - /> + + + {t('settings:title')} + + + {item.value && item.value()} ) } diff --git a/src/components/base/Tabs/index.js b/src/components/base/Tabs/index.js deleted file mode 100644 index f2db1445..00000000 --- a/src/components/base/Tabs/index.js +++ /dev/null @@ -1,68 +0,0 @@ -// @flow - -import React, { Fragment } from 'react' -import styled from 'styled-components' - -import type { Element } from 'react' - -import Box, { Tabbable } from 'components/base/Box' - -const WrapperTab = styled(Box).attrs({ - horizontal: true, -})` - border-bottom: 1px solid ${p => p.theme.colors.fog}; -` - -const Tab = styled(Tabbable).attrs({ - flex: 1, - pb: 2, - alignItems: 'center', - justifyContent: 'center', - fontSize: 3, -})` - border-bottom: 2px solid transparent; - border-bottom-color: ${p => (p.isActive ? p.theme.colors.wallet : '')}; - color: ${p => - p.isActive - ? p.theme.colors.wallet - : p.isDisabled - ? p.theme.colors.grey - : p.theme.colors.graphite}; - margin-bottom: -1px; - outline: none; - cursor: ${p => (p.isActive ? 'default' : p.isDisabled ? 'not-allowed' : 'pointer')}; - max-width: 200px; -` - -type Item = { - key: string | number, - isDisabled?: boolean, - title: string | Element, - render: () => Element, -} - -type Props = { - items: Array, - index: number, - onTabClick: number => void, -} - -const Tabs = ({ items, index, onTabClick }: Props) => ( - - - {items.map((item, i) => ( - onTabClick(i)} - > - {item.title} - - ))} - - {items[index] && items[index].render()} - -) - -export default Tabs diff --git a/src/components/base/Tabs/stories.js b/src/components/base/Tabs/stories.js deleted file mode 100644 index bb89efcc..00000000 --- a/src/components/base/Tabs/stories.js +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react' - -import { number } from '@storybook/addon-knobs' -import { action } from '@storybook/addon-actions' -import { storiesOf } from '@storybook/react' - -import Tabs from 'components/base/Tabs' - -const stories = storiesOf('Components/base', module) - -stories.add('Tabs', () => ( -
{'first tab content'}
, - }, - { - key: 'second', - title: 'second tab', - render: () =>
{'second tab content'}
, - }, - ]} - /> -))