1
1
import * as React from 'react' ;
2
2
import { ReactElement } from 'react' ;
3
- import AppBar from '@material-ui/core/AppBar ' ;
4
- import Tabs , { TabsProps } from '@material-ui/core/Tabs ' ;
3
+ import { AppBar , Tabs , TabsProps } from '@material-ui/core' ;
4
+ import { makeStyles } from '@material-ui/core/styles ' ;
5
5
import { useTranslatableContext } from 'ra-core' ;
6
6
import { TranslatableInputsTab } from './TranslatableInputsTab' ;
7
7
import { AppBarProps } from '../layout' ;
@@ -10,19 +10,26 @@ import { AppBarProps } from '../layout';
10
10
* Default locale selector for the TranslatableInputs component. Generates a tab for each specified locale.
11
11
* @see TranslatableInputs
12
12
*/
13
- export const TranslatableInputsTabs = ( {
14
- groupKey ,
15
- TabsProps : tabsProps ,
16
- } : TranslatableInputsTabsProps & AppBarProps ) : ReactElement => {
13
+ export const TranslatableInputsTabs = (
14
+ props : TranslatableInputsTabsProps & AppBarProps
15
+ ) : ReactElement => {
16
+ const { groupKey , TabsProps : tabsProps } = props ;
17
17
const { locales, selectLocale, selectedLocale } = useTranslatableContext ( ) ;
18
+ const classes = useStyles ( props ) ;
18
19
19
20
const handleChange = ( event , newLocale ) : void => {
20
21
selectLocale ( newLocale ) ;
21
22
} ;
22
23
23
24
return (
24
- < AppBar position = "static" >
25
- < Tabs value = { selectedLocale } onChange = { handleChange } { ...tabsProps } >
25
+ < AppBar color = "default" position = "static" className = { classes . root } >
26
+ < Tabs
27
+ value = { selectedLocale }
28
+ onChange = { handleChange }
29
+ indicatorColor = "primary"
30
+ textColor = "primary"
31
+ { ...tabsProps }
32
+ >
26
33
{ locales . map ( locale => (
27
34
< TranslatableInputsTab
28
35
key = { locale }
@@ -40,3 +47,16 @@ export interface TranslatableInputsTabsProps {
40
47
groupKey ?: string ;
41
48
TabsProps ?: TabsProps ;
42
49
}
50
+
51
+ const useStyles = makeStyles (
52
+ theme => ( {
53
+ root : {
54
+ boxShadow : 'none' ,
55
+ borderRadius : 0 ,
56
+ borderTopLeftRadius : theme . shape . borderRadius ,
57
+ borderTopRightRadius : theme . shape . borderRadius ,
58
+ border : `1px solid ${ theme . palette . divider } ` ,
59
+ } ,
60
+ } ) ,
61
+ { name : 'RaTranslatableInputsTabs' }
62
+ ) ;
0 commit comments