Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/tabs' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fnhipster committed Dec 13, 2019
2 parents 5053781 + 252f019 commit fbf3616
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 8 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pmet-public/luma-ui",
"version": "1.0.0-beta.21",
"version": "1.0.0-beta.22",
"description": "Luma React UI LIbrary",
"repository": "https://github.com/PMET-public/luma-ui.git",
"author": "Carlos A. Cabrera @fnhhipster",
Expand Down Expand Up @@ -47,6 +47,7 @@
"@types/prismjs": "^1.16.0",
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"@types/react-tabs": "^2.3.1",
"@types/styled-components": "^4.1.18",
"babel-loader": "^8.0.5",
"babel-plugin-inline-react-svg": "^1.1.0",
Expand Down Expand Up @@ -79,5 +80,7 @@
"typescript": "^3.7.3",
"webpack": "^4.34.0"
},
"dependencies": {}
"dependencies": {
"react-tabs": "^3.1.0"
}
}
2 changes: 1 addition & 1 deletion src/components/Accordion/Accordion.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Button = styled.button`

export const ButtonLabel = styled.span`
font-family: ${props => props.theme.typography.heading.family};
font-weight: ${props => props.theme.typography.heading.weight.normal};
font-weight: ${props => props.theme.typography.heading.weight.semi};
flex-grow: 1;
`

Expand Down
5 changes: 3 additions & 2 deletions src/components/Carousel/Carousel.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const Scroller = styled.div<{
-webkit-overflow-scrolling: touch;
display: grid;
grid-auto-columns: calc(100% / var(--show) - var(--padding));
grid-auto-columns: ${props =>
props.$show === 'auto' ? 'max-content' : 'calc(100% / var(--show) - var(--padding))'};
grid-auto-flow: column;
grid-gap: var(--gap);
overflow-x: scroll;
Expand All @@ -35,7 +36,7 @@ export const Scroller = styled.div<{
${props =>
props.$hideScrollBar
? `
padding: 1rem 0 1rem;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
Expand Down
31 changes: 31 additions & 0 deletions src/components/Tabs/Tabs.story.tsx
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>
))
86 changes: 86 additions & 0 deletions src/components/Tabs/Tabs.styled.tsx
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;
}
`
40 changes: 40 additions & 0 deletions src/components/Tabs/Tabs.tsx
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 }
2 changes: 2 additions & 0 deletions src/components/Tabs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './Tabs'
export { Tabs as default } from './Tabs'
2 changes: 1 addition & 1 deletion src/templates/Home/Home.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from 'styled-components'
export const Root = styled.div``

export const Stories = styled.div`
padding: 1rem 0 2rem;
padding: 2rem 0;
@media ${props => props.theme.breakpoints.medium} {
display: none;
Expand Down
19 changes: 17 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,13 @@
dependencies:
"@types/react" "*"

"@types/react-tabs@^2.3.1":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@types/react-tabs/-/react-tabs-2.3.1.tgz#62d3322667ac228c4d0f9f36ac9f86988c0b3971"
integrity sha512-4SZXSF8ibQAtHUqqfoYLO+8Rn4F7Hj/IX3CJf1712dWeFvRxYY1HjjwSoN4MgUB0SB0dY4GrdlZwNhhIKuRoNQ==
dependencies:
"@types/react" "*"

"@types/react-textarea-autosize@^4.3.3":
version "4.3.5"
resolved "https://registry.yarnpkg.com/@types/react-textarea-autosize/-/react-textarea-autosize-4.3.5.tgz#6c4d2753fa1864c98c0b2b517f67bb1f6e4c46de"
Expand Down Expand Up @@ -3433,7 +3440,7 @@ class-utils@^0.3.5:
isobject "^3.0.0"
static-extend "^0.1.1"

classnames@^2.2.5:
classnames@^2.2.0, classnames@^2.2.5:
version "2.2.6"
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==
Expand Down Expand Up @@ -8319,7 +8326,7 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.3"

prop-types@^15.0.0-0, prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
prop-types@^15.0.0-0, prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -8755,6 +8762,14 @@ react-syntax-highlighter@^8.0.1:
prismjs "^1.8.4"
refractor "^2.4.1"

react-tabs@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/react-tabs/-/react-tabs-3.1.0.tgz#ecc50f034c1d6da2606fab9293055bbc861b382e"
integrity sha512-9RKc77HCPsjQDVPyZEw37g3JPtg26oSQ9o4mtaVXjJuLedDX5+TQcE+MRNKR+4aO3GMAY4YslCePGG1//MQ3Jg==
dependencies:
classnames "^2.2.0"
prop-types "^15.5.0"

react-textarea-autosize@^7.1.0:
version "7.1.2"
resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-7.1.2.tgz#70fdb333ef86bcca72717e25e623e90c336e2cda"
Expand Down

0 comments on commit fbf3616

Please sign in to comment.