File tree Expand file tree Collapse file tree 2 files changed +62
-7
lines changed
Expand file tree Collapse file tree 2 files changed +62
-7
lines changed Original file line number Diff line number Diff line change 2626
2727import React , { Children , cloneElement , FC } from 'react'
2828import styled from 'styled-components'
29- import { SpaceProps , space , reset } from '@looker/design-tokens'
29+ import {
30+ FlexboxProps ,
31+ LayoutProps ,
32+ SpaceProps ,
33+ flexbox ,
34+ layout ,
35+ space ,
36+ reset ,
37+ } from '@looker/design-tokens'
3038import omit from 'lodash/omit'
3139
32- export interface TabPanelsProps extends SpaceProps {
40+ export interface TabPanelsProps extends FlexboxProps , LayoutProps , SpaceProps {
3341 children : JSX . Element [ ]
42+ className ?: string
3443 selectedIndex ?: number
3544 onSelectTab ?: ( index : number ) => void
3645}
3746
38- export const TabPanels : FC < TabPanelsProps > = ( {
47+ const Layout : FC < TabPanelsProps > = ( {
3948 children,
49+ className,
4050 selectedIndex,
4151 ...props
4252} ) => {
43- const spaceProps = omit ( props , 'onSelectTab' )
53+ const tabPanelsLayoutProps = omit ( props , 'onSelectTab' )
4454
4555 const clonedChildren = Children . map (
4656 children ,
@@ -51,12 +61,18 @@ export const TabPanels: FC<TabPanelsProps> = ({
5161 }
5262 )
5363
54- return < Layout { ...spaceProps } > { clonedChildren } </ Layout >
64+ return (
65+ < div className = { className } { ...tabPanelsLayoutProps } >
66+ { clonedChildren }
67+ </ div >
68+ )
5569}
5670
57- const Layout = styled . div < SpaceProps > `
71+ export const TabPanels = styled ( Layout ) `
5872 ${ reset }
73+ ${ flexbox }
74+ ${ layout }
5975 ${ space }
6076`
6177
62- Layout . defaultProps = { pt : 'large' }
78+ TabPanels . defaultProps = { pt : 'large' }
Original file line number Diff line number Diff line change 1+ import React , { FC } from 'react'
2+ import {
3+ Tab ,
4+ Tabs ,
5+ TabList ,
6+ TabPanel ,
7+ TabPanels ,
8+ Box ,
9+ } from '@looker/components'
10+
11+ export const TabsDemo : FC = ( ) => (
12+ < Box height = { 400 } display = "flex" flexDirection = "column" >
13+ < Tabs >
14+ < TabList >
15+ < Tab > height: 100%</ Tab >
16+ < Tab > height: 200px</ Tab >
17+ </ TabList >
18+ < TabPanels flex = { 1 } >
19+ < TabPanel >
20+ < div
21+ style = { {
22+ backgroundColor : 'lightblue' ,
23+ height : '100%' ,
24+ } }
25+ > </ div >
26+ </ TabPanel >
27+ < TabPanel >
28+ < div
29+ style = { {
30+ backgroundColor : 'coral' ,
31+ height : '200px' ,
32+ width : '100%' ,
33+ } }
34+ > </ div >
35+ </ TabPanel >
36+ </ TabPanels >
37+ </ Tabs >
38+ </ Box >
39+ )
You can’t perform that action at this time.
0 commit comments