Skip to content

Commit 34ee4de

Browse files
committed
add new varaint to Tabs
1 parent ddd42ae commit 34ee4de

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { ComponentStyleConfig } from "@chakra-ui/theme"
2+
3+
export const Tabs: ComponentStyleConfig = {
4+
variants: {
5+
primary: {
6+
tab: {
7+
borderTopRadius: "0.3rem",
8+
borderBottom: "1px solid",
9+
borderBottomColor: "primary",
10+
px: 4,
11+
py: "0.3rem",
12+
_selected: {
13+
color: "background",
14+
bg: "primary",
15+
},
16+
},
17+
tabpanels: {
18+
mt: 4,
19+
},
20+
tabpanel: {
21+
p: 6,
22+
bg: "ednBackground",
23+
border: "1px solid",
24+
borderColor: "lightBorder",
25+
borderRadius: "lg",
26+
},
27+
},
28+
},
29+
defaultProps: {
30+
variant: "primary",
31+
},
32+
}

src/@chakra-ui/gatsby-plugin/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { Link } from "./Link"
33
import { Tag } from "./Tag"
44
import { Modal } from "./Modal"
55
import { Checkbox } from "./Checkbox"
6+
import { Tabs } from "./Tabs"
67

78
export default {
89
Button,
910
Link,
1011
Tag,
1112
Modal,
1213
Checkbox,
14+
Tabs,
1315
}

src/components/Tabs.tsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,17 @@ const Tabs: React.FC<IProps> = ({ tabs, onTabClick }) => {
2525
}
2626

2727
return (
28-
<ChakraTabs as="nav" variant="unstyled">
28+
<ChakraTabs as="nav">
2929
<TabList>
3030
{tabs.map((tab, index) => (
31-
<Tab
32-
key={index}
33-
px={4}
34-
py="0.3rem"
35-
borderBottom="1px solid"
36-
borderColor="primary"
37-
borderTopRadius="0.3rem"
38-
_selected={{ color: "background", bg: "primary" }}
39-
onClick={() => handleTabClick(index)}
40-
>
31+
<Tab key={index} onClick={() => handleTabClick(index)}>
4132
{tab.title}
4233
</Tab>
4334
))}
4435
</TabList>
45-
<TabPanels as="main" mt={4}>
36+
<TabPanels as="main">
4637
{tabs.map((tab, index) => (
47-
<TabPanel
48-
key={index}
49-
p={6}
50-
bg="ednBackground"
51-
border="1px solid"
52-
borderColor="lightBorder"
53-
borderRadius="lg"
54-
>
55-
{tab.content}
56-
</TabPanel>
38+
<TabPanel key={index}>{tab.content}</TabPanel>
5739
))}
5840
</TabPanels>
5941
</ChakraTabs>

0 commit comments

Comments
 (0)