Skip to content

Commit

Permalink
Merge pull request #6484 from marmelab/concise-translatable-input
Browse files Browse the repository at this point in the history
Reduce TranslatableInputs margin
  • Loading branch information
djhi authored Aug 2, 2021
2 parents 19dc5b9 + 4519b74 commit 98babf8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/ra-ui-materialui/src/input/TranslatableInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TranslatableContextProvider,
useTranslatable,
UseTranslatableOptions,
InputProps,
} from 'ra-core';
import { TranslatableInputsTabs } from './TranslatableInputsTabs';
import { TranslatableInputsTabContent } from './TranslatableInputsTabContent';
Expand Down Expand Up @@ -69,6 +70,8 @@ export const TranslatableInputs = (props: TranslatableProps): ReactElement => {
groupKey = '',
selector = <TranslatableInputsTabs groupKey={groupKey} />,
children,
variant,
margin,
} = props;
const context = useTranslatable({ defaultLocale, locales });
const classes = useStyles(props);
Expand All @@ -82,6 +85,8 @@ export const TranslatableInputs = (props: TranslatableProps): ReactElement => {
key={locale}
locale={locale}
groupKey={groupKey}
variant={variant}
margin={margin}
>
{children}
</TranslatableInputsTabContent>
Expand All @@ -91,7 +96,7 @@ export const TranslatableInputs = (props: TranslatableProps): ReactElement => {
);
};

export interface TranslatableProps extends UseTranslatableOptions {
export interface TranslatableProps extends UseTranslatableOptions, InputProps {
selector?: ReactElement;
children: ReactNode;
groupKey?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ export const TranslatableInputsTab = (
label={translate(`ra.locales.${locale}`, {
_: capitalize(locale),
})}
className={invalid && touched ? classes.error : undefined}
className={`${classes.root} ${
invalid && touched ? classes.error : ''
}`}
{...rest}
/>
);
};

const useStyles = makeStyles(
theme => ({
root: {
fontSize: '0.8em',
minHeight: theme.spacing(3),
minWidth: theme.spacing(6),
},
error: { color: theme.palette.error.main },
}),
{ name: 'RaTranslatableInputsTab' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ const useStyles = makeStyles(
theme => ({
root: {
flexGrow: 1,
padding: theme.spacing(2),
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
paddingTop: theme.spacing(1),
paddingBottom: theme.spacing(1),
borderRadius: 0,
borderBottomLeftRadius: theme.shape.borderRadius,
borderBottomRightRadius: theme.shape.borderRadius,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const TranslatableInputsTabs = (
onChange={handleChange}
indicatorColor="primary"
textColor="primary"
className={classes.tabs}
{...tabsProps}
>
{locales.map(locale => (
Expand Down Expand Up @@ -57,6 +58,9 @@ const useStyles = makeStyles(
borderTopRightRadius: theme.shape.borderRadius,
border: `1px solid ${theme.palette.divider}`,
},
tabs: {
minHeight: theme.spacing(3),
},
}),
{ name: 'RaTranslatableInputsTabs' }
);

0 comments on commit 98babf8

Please sign in to comment.