Loëck Vézien
7 years ago
committed by
GitHub
8 changed files with 199 additions and 15 deletions
@ -0,0 +1,76 @@ |
|||
// @flow
|
|||
|
|||
import React, { PureComponent } from 'react' |
|||
|
|||
import Box from 'components/base/Box' |
|||
import Text from 'components/base/Text' |
|||
import Tabs from 'components/base/Tabs' |
|||
|
|||
import TabProfile from './Profile' |
|||
|
|||
type Props = {} |
|||
|
|||
type State = { |
|||
tab: number, |
|||
} |
|||
|
|||
class SettingsPage extends PureComponent<Props, State> { |
|||
state = { |
|||
tab: 6, |
|||
} |
|||
|
|||
handleChangeTab = (tab: number) => this.setState({ tab }) |
|||
|
|||
render() { |
|||
const { tab } = this.state |
|||
|
|||
return ( |
|||
<Box p={3} flow={4}> |
|||
<Text fontSize={5}>{'Settings'}</Text> |
|||
<Tabs |
|||
index={tab} |
|||
onTabClick={this.handleChangeTab} |
|||
items={[ |
|||
{ |
|||
key: 'display', |
|||
title: 'Affichage', |
|||
render: () => <div>{'Affichage'}</div>, |
|||
}, |
|||
{ |
|||
key: 'money', |
|||
title: 'Monnaie', |
|||
render: () => <div>{'Monnaie'}</div>, |
|||
}, |
|||
{ |
|||
key: 'material', |
|||
title: 'Matériel', |
|||
render: () => <div>{'Matériel'}</div>, |
|||
}, |
|||
{ |
|||
key: 'app', |
|||
title: 'App (beta)', |
|||
render: () => <div>{'App (beta)'}</div>, |
|||
}, |
|||
{ |
|||
key: 'tools', |
|||
title: 'Outils', |
|||
render: () => <div>{'Outils'}</div>, |
|||
}, |
|||
{ |
|||
key: 'blockchain', |
|||
title: 'Blockchain', |
|||
render: () => <div>{'Blockchain'}</div>, |
|||
}, |
|||
{ |
|||
key: 'profile', |
|||
title: 'Profil', |
|||
render: () => <TabProfile />, |
|||
}, |
|||
]} |
|||
/> |
|||
</Box> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default SettingsPage |
@ -0,0 +1,51 @@ |
|||
// @flow
|
|||
|
|||
import React, { Fragment } from 'react' |
|||
import styled from 'styled-components' |
|||
|
|||
import type { Element } from 'react' |
|||
|
|||
import Box, { Tabbable } from 'components/base/Box' |
|||
|
|||
const Tab = styled(Tabbable).attrs({ |
|||
flex: 1, |
|||
pb: 1, |
|||
align: 'center', |
|||
justify: 'center', |
|||
fontSize: 1, |
|||
})` |
|||
border-bottom: 2px solid transparent; |
|||
border-bottom-color: ${p => (p.isActive ? p.theme.colors.blue : '')}; |
|||
color: ${p => (p.isActive ? p.theme.colors.blue : p.theme.colors.steel)}; |
|||
font-weight: ${p => (p.isActive ? 'bold' : '')}; |
|||
margin-bottom: -1px; |
|||
outline: none; |
|||
cursor: ${p => (p.isActive ? 'default' : 'pointer')}; |
|||
` |
|||
|
|||
type Item = { |
|||
key: string | number, |
|||
title: string | Element<any>, |
|||
render: () => Element<any>, |
|||
} |
|||
|
|||
type Props = { |
|||
items: Array<Item>, |
|||
index: number, |
|||
onTabClick: number => void, |
|||
} |
|||
|
|||
const Tabs = ({ items, index, onTabClick }: Props) => ( |
|||
<Fragment> |
|||
<Box horizontal borderBottom borderWidth={1} borderColor="argile"> |
|||
{items.map((item, i) => ( |
|||
<Tab key={item.key} isActive={index === i} onClick={() => onTabClick(i)}> |
|||
{item.title} |
|||
</Tab> |
|||
))} |
|||
</Box> |
|||
{items[index] && items[index].render()} |
|||
</Fragment> |
|||
) |
|||
|
|||
export default Tabs |
@ -0,0 +1,28 @@ |
|||
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('Tabs', module) |
|||
|
|||
stories.add('basic', () => ( |
|||
<Tabs |
|||
index={number('index', 0)} |
|||
onTabClick={action('onTabClick')} |
|||
items={[ |
|||
{ |
|||
key: 'first', |
|||
title: 'first tab', |
|||
render: () => <div>{'first tab content'}</div>, |
|||
}, |
|||
{ |
|||
key: 'second', |
|||
title: 'second tab', |
|||
render: () => <div>{'second tab content'}</div>, |
|||
}, |
|||
]} |
|||
/> |
|||
)) |
Loading…
Reference in new issue