-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f9b518
commit 6489024
Showing
8 changed files
with
155 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,15 @@ | ||
import { forwardRef, CSSProperties } from 'react' | ||
import styled from 'styled-components' | ||
import { outlineTemplate, Tokens } from '@utils' | ||
import { Tab as CTab, TabProps as CTabProps } from '@chakra-ui/react' | ||
import { forwardRef } from 'react'; | ||
import * as RadixTabs from '@radix-ui/react-tabs'; | ||
|
||
const { outline } = Tokens | ||
export type TabProps = RadixTabs.TabsTriggerProps; | ||
|
||
const StyledTab = styled(CTab)` | ||
color: var(--font-color); | ||
background: transparent; | ||
border: none; | ||
padding: var(--space-xSmall) 0; | ||
/* Not sure about this one, but some spaces for tab components that wrap multiple lines */ | ||
margin-bottom: var(--space-small); | ||
:not(:last-child) { | ||
margin-right: var(--space-medium); | ||
} | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
color: var(--color-on-background); | ||
&:active { | ||
background: transparent; | ||
} | ||
&:focus-visible { | ||
outline: none; | ||
${outlineTemplate(outline)} | ||
outline-color: var(--mist-blue-100); | ||
} | ||
&[data-selected] { | ||
border-bottom: 2px solid; | ||
} | ||
` | ||
|
||
export type TabProps = CTabProps & { | ||
variant?: string | ||
} | ||
|
||
export const Tab = forwardRef<HTMLButtonElement, TabProps>(function CTab({ children, variant = 'line', ...rest }, ref) { | ||
export const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab( | ||
{ children, ...rest }, | ||
ref | ||
) { | ||
return ( | ||
<StyledTab | ||
ref={ref} | ||
_selected={{ | ||
'--font-color': 'var(--color-on-background)', | ||
borderColor: 'var(--color-on-background)', | ||
borderBottom: '2px solid', | ||
}} | ||
variant={variant} | ||
{...rest} | ||
style={ | ||
{ | ||
'--font-color': 'var(--color-on-background)', | ||
} as CSSProperties | ||
} | ||
> | ||
<RadixTabs.Trigger ref={ref} {...rest}> | ||
{children} | ||
</StyledTab> | ||
) | ||
}) | ||
</RadixTabs.Trigger> | ||
); | ||
}); |
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { forwardRef } from 'react' | ||
import { TabList as CTabList, TabListProps as CTabListProps } from '@chakra-ui/react' | ||
import { forwardRef } from 'react'; | ||
import * as RadixTabs from '@radix-ui/react-tabs'; | ||
|
||
export type TabListProps = CTabListProps | ||
export type TabListProps = RadixTabs.TabsListProps; | ||
|
||
export const TabList = forwardRef<HTMLDivElement, TabListProps>(function TabList({ children, ...rest }, ref) { | ||
export const TabList = forwardRef<HTMLDivElement, TabListProps>(function TabList( | ||
{ children, ...rest }, | ||
ref | ||
) { | ||
return ( | ||
<CTabList ref={ref} {...rest} style={{ border: 'none', flexWrap: 'wrap' }}> | ||
<RadixTabs.List ref={ref} {...rest}> | ||
{children} | ||
</CTabList> | ||
) | ||
}) | ||
</RadixTabs.List> | ||
); | ||
}); |
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { forwardRef } from 'react' | ||
import { TabPanel as CTabPanel, TabPanelProps as CTabPanelProps } from '@chakra-ui/react' | ||
import { forwardRef } from 'react'; | ||
import * as RadixTabs from '@radix-ui/react-tabs'; | ||
|
||
export type TabPanelProps = CTabPanelProps | ||
export type TabPanelProps = RadixTabs.TabsContentProps; | ||
|
||
export const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(function TabPanel({ children, ...rest }, ref) { | ||
export const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(function TabPanel( | ||
{ children, ...rest }, | ||
ref | ||
) { | ||
return ( | ||
<CTabPanel ref={ref} {...rest}> | ||
<RadixTabs.Content ref={ref} {...rest}> | ||
{children} | ||
</CTabPanel> | ||
) | ||
}) | ||
</RadixTabs.Content> | ||
); | ||
}); |
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { forwardRef } from 'react' | ||
import { TabPanels as CTabPanels, TabPanelsProps as CTabPanelsProps } from '@chakra-ui/react' | ||
import { forwardRef } from 'react'; | ||
import * as RadixTabs from '@radix-ui/react-tabs'; | ||
|
||
export type TabPanelsProps = CTabPanelsProps | ||
export type TabPanelsProps = { children: React.ReactNode }; | ||
|
||
export const TabPanels = forwardRef<HTMLDivElement, TabPanelsProps>(function TabPanels({ children, ...rest }, ref) { | ||
export const TabPanels = forwardRef<HTMLDivElement, TabPanelsProps>(function TabPanels( | ||
{ children, ...rest }, | ||
ref | ||
) { | ||
return ( | ||
<CTabPanels ref={ref} {...rest}> | ||
<div ref={ref} {...rest}> | ||
{children} | ||
</CTabPanels> | ||
) | ||
}) | ||
</div> | ||
); | ||
}); |
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { forwardRef } from 'react' | ||
import { Tabs as CTabs, TabsProps as CTabsProps } from '@chakra-ui/react' | ||
import { forwardRef } from 'react'; | ||
import * as RadixTabs from '@radix-ui/react-tabs'; | ||
|
||
export type TabsProps = CTabsProps | ||
export type TabsProps = RadixTabs.TabsProps; | ||
|
||
export const Tabs = forwardRef<HTMLDivElement, TabsProps>(function Tabs({ children, ...rest }, ref) { | ||
export const Tabs = forwardRef<HTMLDivElement, TabsProps>(function Tabs( | ||
{ children, ...rest }, | ||
ref | ||
) { | ||
return ( | ||
<CTabs ref={ref} {...rest}> | ||
<RadixTabs.Root ref={ref} {...rest}> | ||
{children} | ||
</CTabs> | ||
) | ||
}) | ||
</RadixTabs.Root> | ||
); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.