1
- import { ReactNode } from "react" ;
1
+ import { type FC , type PropsWithChildren } from "react" ;
2
2
import { NavLink , NavLinkProps } from "react-router-dom" ;
3
3
import { combineClasses } from "utils/combineClasses" ;
4
4
import { Margins } from "components/Margins/Margins" ;
5
- import { css } from "@emotion/css" ;
6
- import { useTheme } from "@emotion/react" ;
5
+ import { type ClassName , useClassName } from "hooks/useClassName" ;
7
6
8
- export const Tabs = ( { children } : { children : ReactNode } ) => {
7
+ export const Tabs : FC < PropsWithChildren > = ( { children } ) => {
9
8
return (
10
9
< div
11
10
css = { ( theme ) => ( {
@@ -26,10 +25,34 @@ export const Tabs = ({ children }: { children: ReactNode }) => {
26
25
) ;
27
26
} ;
28
27
29
- export const TabLink = ( props : NavLinkProps ) => {
30
- const theme = useTheme ( ) ;
28
+ interface TabLinkProps extends NavLinkProps {
29
+ className ?: string ;
30
+ }
31
31
32
- const baseTabLink = css `
32
+ export const TabLink : FC < TabLinkProps > = ( {
33
+ className,
34
+ children,
35
+ ...linkProps
36
+ } ) => {
37
+ const tabLink = useClassName ( classNames . tabLink , [ ] ) ;
38
+ const activeTabLink = useClassName ( classNames . tabLink , [ ] ) ;
39
+
40
+ return (
41
+ < NavLink
42
+ className = { ( { isActive } ) =>
43
+ combineClasses ( [
44
+ tabLink ,
45
+ isActive ? activeTabLink : undefined ,
46
+ className ,
47
+ ] )
48
+ }
49
+ { ...linkProps }
50
+ />
51
+ ) ;
52
+ } ;
53
+
54
+ const classNames = {
55
+ tabLink : ( css , theme ) => css `
33
56
text-decoration : none;
34
57
color : ${ theme . palette . text . secondary } ;
35
58
font-size : 14px ;
@@ -39,9 +62,8 @@ export const TabLink = (props: NavLinkProps) => {
39
62
& : hover {
40
63
color : ${ theme . palette . text . primary } ;
41
64
}
42
- ` ;
43
-
44
- const activeTabLink = css `
65
+ ` ,
66
+ activeTabLink : ( css , theme ) => css `
45
67
color : ${ theme . palette . text . primary } ;
46
68
position : relative;
47
69
@@ -54,18 +76,5 @@ export const TabLink = (props: NavLinkProps) => {
54
76
background : ${ theme . palette . primary . main } ;
55
77
position : absolute;
56
78
}
57
- ` ;
58
-
59
- return (
60
- < NavLink
61
- className = { ( { isActive } ) =>
62
- combineClasses ( [
63
- baseTabLink ,
64
- isActive ? activeTabLink : undefined ,
65
- props . className as string ,
66
- ] )
67
- }
68
- { ...props }
69
- />
70
- ) ;
71
- } ;
79
+ ` ,
80
+ } satisfies Record < string , ClassName > ;
0 commit comments