This repository was archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/tabs' into develop
- Loading branch information
Showing
9 changed files
with
186 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
import Tabs, { TabList, Tab, TabPanel } from './' | ||
import { storiesOf } from '@storybook/react' | ||
|
||
storiesOf('📦 Components/Tabs', module).add('Default', () => ( | ||
<Tabs style={{ width: '70rem', maxWidth: '100%' }}> | ||
<TabList> | ||
<Tab>I'm a tab</Tab> | ||
<Tab>and I'm also a tab</Tab> | ||
<Tab>Guess who?</Tab> | ||
<Tab>Tab!</Tab> | ||
<Tab>yet another Tab 🙃</Tab> | ||
</TabList> | ||
|
||
<TabPanel> | ||
<h2>Any content 1</h2> | ||
</TabPanel> | ||
<TabPanel> | ||
<h2>Any content 2</h2> | ||
</TabPanel> | ||
<TabPanel> | ||
<h2>Any content 3</h2> | ||
</TabPanel> | ||
<TabPanel> | ||
<h2>Any content 4</h2> | ||
</TabPanel> | ||
<TabPanel> | ||
<h2>Any content 5</h2> | ||
</TabPanel> | ||
</Tabs> | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import styled from 'styled-components' | ||
import { | ||
Tabs as TabsComponent, | ||
TabList as TabListComponent, | ||
Tab as TabComponent, | ||
TabPanel as TabPanelComponent, | ||
} from 'react-tabs' | ||
|
||
export const Tabs = styled(TabsComponent)` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
` | ||
|
||
export const TabListWrapper = styled.div<{ $align?: 'left' | 'center' | 'right' }>` | ||
text-align: ${({ $align = 'left' }) => $align}; | ||
overflow-x: auto; | ||
scrollbar-width: none; | ||
-webkit-overflow-scrolling: touch; | ||
&::-webkit-scrollbar { | ||
display: none; | ||
} | ||
` | ||
|
||
export const TabList = styled(TabListComponent)` | ||
display: inline-grid; | ||
grid-auto-flow: column; | ||
grid-auto-columns: max-content; | ||
grid-auto-rows: max-content; | ||
overflow-x: auto; | ||
align-items: flex-end; | ||
list-style-type: none; | ||
background-color: ${props => props.theme.colors.surface}; | ||
position: relative; | ||
z-index: 1; | ||
` | ||
|
||
export const Tab = styled(TabComponent)` | ||
cursor: pointer; | ||
font-family: ${props => props.theme.typography.heading.family}; | ||
font-weight: ${props => props.theme.typography.heading.weight.semi}; | ||
padding: 1.6rem 2rem; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: ${props => props.theme.colors.onSurface5}; | ||
height: 85%; | ||
transition: all 150ms ease-in; | ||
border-width: 0.1rem 0.1rem 0; | ||
border-style: solid; | ||
border-top-color: ${props => props.theme.colors.onSurface10}; | ||
border-left-color: ${props => props.theme.colors.onSurface10}; | ||
border-right-color: transparent; | ||
border-bottom-color: transparent; | ||
&:last-child { | ||
border-right-color: ${props => props.theme.colors.onSurface10}; | ||
} | ||
&.react-tabs__tab--selected { | ||
cursor: initial; | ||
height: 100%; | ||
border-radius: 0.25rem 0.25rem 0 0; | ||
border-color: ${props => props.theme.colors.onSurface10}; | ||
background-color: ${props => props.theme.colors.surface}; | ||
} | ||
&:hover:not(.react-tabs__tab--selected) { | ||
background-color: ${props => props.theme.colors.onSurface10}; | ||
} | ||
` | ||
|
||
export const TabPanel = styled(TabPanelComponent)` | ||
margin-top: -0.1rem; | ||
display: none; | ||
background-color: ${props => props.theme.colors.surface}; | ||
border-width: 0.1rem 0 0.1rem; | ||
border-style: solid; | ||
border-color: ${props => props.theme.colors.onSurface10}; | ||
&.react-tabs__tab-panel--selected { | ||
display: block; | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Built with https://github.com/reactjs/react-tabs | ||
*/ | ||
|
||
import React, { FunctionComponent } from 'react' | ||
import { Tab as _Tab, Tabs as _Tabs, TabListWrapper, TabList as _TabList, TabPanel as _TabPanel } from './Tabs.styled' | ||
|
||
import { | ||
TabsProps as _TabsProps, | ||
TabListProps as _TabListProps, | ||
TabProps as _TabProps, | ||
TabPanelProps as _TabPanelProps, | ||
} from 'react-tabs' | ||
|
||
export type TabsProps = _TabsProps | ||
export type TabListProps = _TabListProps | ||
export type TabProps = _TabProps | ||
export type TabPanelProps = _TabPanelProps | ||
|
||
const Tabs = _Tabs | ||
|
||
const TabList: FunctionComponent<TabListProps & { align?: 'left' | 'center' | 'right' }> = ({ | ||
align = 'left', | ||
...props | ||
}) => { | ||
return ( | ||
<TabListWrapper $align={align}> | ||
<_TabList {...(props as any)} /> | ||
</TabListWrapper> | ||
) | ||
} | ||
TabList.tabsRole = 'TabList' | ||
|
||
const Tab = _Tab | ||
Tab.tabsRole = 'Tab' | ||
|
||
const TabPanel = _TabPanel | ||
TabPanel.tabsRole = 'TabPanel' | ||
|
||
export { Tabs, TabList, Tab, TabPanel } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './Tabs' | ||
export { Tabs as default } from './Tabs' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters