From 224fe4ce250ddb060606967d25b49185f0dad01c Mon Sep 17 00:00:00 2001 From: Cafe137 <77121044+Cafe137@users.noreply.github.com> Date: Tue, 5 Apr 2022 22:54:16 +0200 Subject: [PATCH] refactor: add missing props to generic components (#325) * refactor: add missing props to generic components * fix: remove undefined from variant Co-authored-by: Vojtech Simetka Co-authored-by: Vojtech Simetka --- src/components/SwarmButton.tsx | 4 +++- src/components/SwarmTextInput.tsx | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/SwarmButton.tsx b/src/components/SwarmButton.tsx index ee8c0c3..065fb18 100644 --- a/src/components/SwarmButton.tsx +++ b/src/components/SwarmButton.tsx @@ -10,6 +10,7 @@ interface Props { disabled?: boolean loading?: boolean cancel?: boolean + variant?: 'text' | 'contained' | 'outlined' } const useStyles = makeStyles(() => @@ -49,6 +50,7 @@ export function SwarmButton({ disabled, loading, cancel, + variant = 'contained', }: Props): ReactElement { const classes = useStyles() @@ -76,7 +78,7 @@ export function SwarmButton({ onClick() event.currentTarget.blur() }} - variant="contained" + variant={variant} startIcon={icon} disabled={disabled} > diff --git a/src/components/SwarmTextInput.tsx b/src/components/SwarmTextInput.tsx index 659aa3d..e321df4 100644 --- a/src/components/SwarmTextInput.tsx +++ b/src/components/SwarmTextInput.tsx @@ -9,6 +9,7 @@ interface Props { password?: boolean formik?: boolean optional?: boolean + defaultValue?: string onChange?: (event: ChangeEvent) => void } @@ -32,7 +33,15 @@ const useStyles = makeStyles((theme: Theme) => }), ) -export function SwarmTextInput({ name, label, password, optional, formik, onChange }: Props): ReactElement { +export function SwarmTextInput({ + name, + label, + password, + optional, + formik, + onChange, + defaultValue, +}: Props): ReactElement { const classes = useStyles() if (formik) { @@ -46,7 +55,7 @@ export function SwarmTextInput({ name, label, password, optional, formik, onChan fullWidth variant="filled" className={classes.field} - defaultValue="" + defaultValue={defaultValue || ''} InputProps={{ disableUnderline: true }} /> ) @@ -60,7 +69,7 @@ export function SwarmTextInput({ name, label, password, optional, formik, onChan fullWidth variant="filled" className={classes.field} - defaultValue="" + defaultValue={defaultValue || ''} onChange={onChange} InputProps={{ disableUnderline: true }} />