Skip to content

Commit

Permalink
add new varaint to Tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-ksh committed Nov 25, 2022
1 parent ddd42ae commit 34ee4de
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
32 changes: 32 additions & 0 deletions src/@chakra-ui/gatsby-plugin/components/Tabs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { ComponentStyleConfig } from "@chakra-ui/theme"

export const Tabs: ComponentStyleConfig = {
variants: {
primary: {
tab: {
borderTopRadius: "0.3rem",
borderBottom: "1px solid",
borderBottomColor: "primary",
px: 4,
py: "0.3rem",
_selected: {
color: "background",
bg: "primary",
},
},
tabpanels: {
mt: 4,
},
tabpanel: {
p: 6,
bg: "ednBackground",
border: "1px solid",
borderColor: "lightBorder",
borderRadius: "lg",
},
},
},
defaultProps: {
variant: "primary",
},
}
2 changes: 2 additions & 0 deletions src/@chakra-ui/gatsby-plugin/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { Link } from "./Link"
import { Tag } from "./Tag"
import { Modal } from "./Modal"
import { Checkbox } from "./Checkbox"
import { Tabs } from "./Tabs"

export default {
Button,
Link,
Tag,
Modal,
Checkbox,
Tabs,
}
26 changes: 4 additions & 22 deletions src/components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,17 @@ const Tabs: React.FC<IProps> = ({ tabs, onTabClick }) => {
}

return (
<ChakraTabs as="nav" variant="unstyled">
<ChakraTabs as="nav">
<TabList>
{tabs.map((tab, index) => (
<Tab
key={index}
px={4}
py="0.3rem"
borderBottom="1px solid"
borderColor="primary"
borderTopRadius="0.3rem"
_selected={{ color: "background", bg: "primary" }}
onClick={() => handleTabClick(index)}
>
<Tab key={index} onClick={() => handleTabClick(index)}>
{tab.title}
</Tab>
))}
</TabList>
<TabPanels as="main" mt={4}>
<TabPanels as="main">
{tabs.map((tab, index) => (
<TabPanel
key={index}
p={6}
bg="ednBackground"
border="1px solid"
borderColor="lightBorder"
borderRadius="lg"
>
{tab.content}
</TabPanel>
<TabPanel key={index}>{tab.content}</TabPanel>
))}
</TabPanels>
</ChakraTabs>
Expand Down

0 comments on commit 34ee4de

Please sign in to comment.