listpage-next 0.0.215 → 0.0.217
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface TabProps {
|
|
3
|
+
items: {
|
|
4
|
+
icon?: ReactNode;
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}[];
|
|
9
|
+
value?: string;
|
|
10
|
+
onChange?: (tab: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const Tabs: (props: TabProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useControllableValue } from "ahooks";
|
|
3
|
+
import { styled } from "styled-components";
|
|
4
|
+
const Tabs = (props)=>{
|
|
5
|
+
const { items } = props;
|
|
6
|
+
const [activeTab, setActiveTab] = useControllableValue(props);
|
|
7
|
+
return /*#__PURE__*/ jsxs(TabContainer, {
|
|
8
|
+
children: [
|
|
9
|
+
/*#__PURE__*/ jsx(TabHeader, {
|
|
10
|
+
children: items.map((tab)=>/*#__PURE__*/ jsxs(TabItem, {
|
|
11
|
+
$active: tab.value === activeTab,
|
|
12
|
+
onClick: ()=>setActiveTab(tab.value),
|
|
13
|
+
children: [
|
|
14
|
+
tab.icon && /*#__PURE__*/ jsx(IconContainer, {
|
|
15
|
+
children: tab.icon
|
|
16
|
+
}),
|
|
17
|
+
tab.label
|
|
18
|
+
]
|
|
19
|
+
}, tab.value))
|
|
20
|
+
}),
|
|
21
|
+
/*#__PURE__*/ jsx(TabContent, {
|
|
22
|
+
children: items.find((t)=>t.value === activeTab)?.children
|
|
23
|
+
})
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const TabContainer = styled.div`
|
|
28
|
+
flex: 1;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
background-color: #f9fafb;
|
|
33
|
+
`;
|
|
34
|
+
const TabHeader = styled.div`
|
|
35
|
+
display: flex;
|
|
36
|
+
border-bottom: 1px solid #e5e7eb;
|
|
37
|
+
background-color: #ffffff;
|
|
38
|
+
`;
|
|
39
|
+
const TabItem = styled.button`
|
|
40
|
+
padding: 12px 24px;
|
|
41
|
+
font-size: 14px;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
line-height: 20px;
|
|
44
|
+
height: 46px;
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
gap: 8px;
|
|
48
|
+
border: none;
|
|
49
|
+
border-bottom: 2px solid transparent;
|
|
50
|
+
background: transparent;
|
|
51
|
+
color: #6b7280;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
transition:
|
|
54
|
+
color 0.2s ease,
|
|
55
|
+
background-color 0.2s ease,
|
|
56
|
+
border-color 0.2s ease;
|
|
57
|
+
|
|
58
|
+
&:hover {
|
|
59
|
+
color: #374151;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
${({ $active })=>$active && `
|
|
63
|
+
border-bottom-color: var(--ant-color-primary);
|
|
64
|
+
color: var(--ant-color-primary);
|
|
65
|
+
background-color: var(--ant-color-primary-bg);
|
|
66
|
+
`}
|
|
67
|
+
`;
|
|
68
|
+
const TabContent = styled.div`
|
|
69
|
+
flex: 1;
|
|
70
|
+
overflow: auto;
|
|
71
|
+
padding: 0;
|
|
72
|
+
position: relative;
|
|
73
|
+
`;
|
|
74
|
+
const IconContainer = styled.span`
|
|
75
|
+
margin-right: 4px;
|
|
76
|
+
`;
|
|
77
|
+
export { Tabs };
|
package/dist/components/index.js
CHANGED