Skip to content

Commit

Permalink
fix: improve test coverage for menu and tab components
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-cratebind committed Nov 2, 2020
1 parent 1e1324a commit 67e1a0f
Show file tree
Hide file tree
Showing 7 changed files with 897 additions and 30 deletions.
1 change: 1 addition & 0 deletions docs/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import Document from 'next/document';
import { ServerStyleSheet } from 'styled-components';

Expand Down
4 changes: 2 additions & 2 deletions docs/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module 'react' {
interface DOMAttributes<T> {
css?: InterpolationWithTheme<any>
css?: InterpolationWithTheme<any>;
}
}
}
48 changes: 31 additions & 17 deletions src/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,43 @@ import {
} from '@reach/tabs';

import { MinervaProps, Box, Flex } from '../layout';
import { useTheme } from '../theme';
import { useComponentStyles } from '../theme';
import PseudoBox, { PseudoBoxProps } from '../PseudoBox';

// export interface TabsProps extends MinervaProps, PseudoBoxProps, ReachTabsProps { }

export type TabsProps = MinervaProps & ReachTabsProps & PseudoBoxProps;

export const Tabs = ({ children, ...rest }: TabsProps) => {
const theme = useTheme();
export const Tabs = ({ children, ...props }: TabsProps) => {
const componentStyles = useComponentStyles('Tabs');
return (
<Box as={ReachTabs} {...rest} {...theme.Tabs}>
<Box as={ReachTabs} {...props} {...componentStyles}>
{children}
</Box>
);
};

export const TabList = ({ children, ...rest }: TabsProps) => (
<Flex bg="#fff" alignItems="center" as={ReachTabList} {...rest}>
{children}
</Flex>
);
export const TabList = ({ children, ...props }: TabsProps) => {
const componentStyles = useComponentStyles('TabList');

return (
<Flex
bg="#fff"
alignItems="center"
as={ReachTabList}
{...componentStyles}
{...props}
>
{children}
</Flex>
);
};

export const Tab = forwardRef(function Tab(
{ children, ...rest }: TabsProps,
{ children, ...props }: TabsProps,
ref
) {
const componentStyles = useComponentStyles('Tab');
return (
<PseudoBox
as={ReachTab}
Expand Down Expand Up @@ -65,19 +76,22 @@ export const Tab = forwardRef(function Tab(
borderWidth: '2px',
borderBottom: '2px solid currentColor',
}}
{...rest}
{...componentStyles}
{...props}
>
{children}
</PseudoBox>
);
});

export const TabPanels = (props: TabsProps) => (
<Box as={ReachTabPanels} {...props} />
);
export const TabPanels = (props: TabsProps) => {
const componentStyles = useComponentStyles('TabPanels');
return <Box as={ReachTabPanels} {...componentStyles} {...props} />;
};

export const TabPanel = (props: TabsProps) => (
<Box as={ReachTabPanel} {...props} />
);
export const TabPanel = (props: TabsProps) => {
const componentStyles = useComponentStyles('TabPanel');
return <Box as={ReachTabPanel} {...componentStyles} {...props} />;
};

export { useTabsContext };
Loading

0 comments on commit 67e1a0f

Please sign in to comment.