Front: Pretty and Lint (#225)
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
import { Button, Text } from "native-base"
|
||||
import Translate from "./Translate";
|
||||
import { Button, Text } from 'native-base';
|
||||
import Translate from './Translate';
|
||||
import { RequireExactlyOne } from 'type-fest';
|
||||
|
||||
type TextButtonProps = Parameters<typeof Button>[0] & RequireExactlyOne<{
|
||||
label: string;
|
||||
translate: Parameters<typeof Translate>[0];
|
||||
}>
|
||||
type TextButtonProps = Parameters<typeof Button>[0] &
|
||||
RequireExactlyOne<{
|
||||
label: string;
|
||||
translate: Parameters<typeof Translate>[0];
|
||||
}>;
|
||||
|
||||
const TextButton = (props: TextButtonProps) => {
|
||||
// accepts undefined variant, as it is the default variant
|
||||
const textColor = !props.variant || props.variant == 'solid'
|
||||
? 'light.50'
|
||||
: undefined;
|
||||
const textColor = !props.variant || props.variant == 'solid' ? 'light.50' : undefined;
|
||||
|
||||
return <Button {...props}>
|
||||
{ props.label !== undefined
|
||||
? <Text color={textColor}>{props.label}</Text>
|
||||
: <Translate color={textColor} {...props.translate} />
|
||||
}
|
||||
</Button>
|
||||
}
|
||||
return (
|
||||
<Button {...props}>
|
||||
{props.label !== undefined ? (
|
||||
<Text color={textColor}>{props.label}</Text>
|
||||
) : (
|
||||
<Translate color={textColor} {...props.translate} />
|
||||
)}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default TextButton
|
||||
export default TextButton;
|
||||
|
||||
Reference in New Issue
Block a user