Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 SQFormDatePicker styles #923

Open
wants to merge 1 commit into
base: epic/SSR-248
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/components/fields/SQFormDatePicker/SQFormDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function SQFormDatePicker({
size = 'auto',
isDisabled = false,
displayHelperText = true,
placeholder = '',
placeholder = 'MM / DD / YYYY',
onBlur,
onChange,
setDisabledDate,
Expand Down Expand Up @@ -109,28 +109,23 @@ function SQFormDatePicker({
variant="standard"
error={isFieldError}
fullWidth={true}
inputProps={{...inputProps.inputProps, ...muiTextInputProps}}
inputProps={{
...inputProps.inputProps,
placeholder,
...muiTextInputProps,
}}
InputLabelProps={{shrink: true}}
FormHelperTextProps={{error: isFieldError}}
helperText={
!isDisabled && displayHelperText && HelperTextComponent
}
placeholder={placeholder}
onBlur={handleBlur}
required={isFieldRequired}
onClick={
isCalendarOnly && !isDisabled
? toggleCalendar
: handleClickAway
}
sx={{
'& .MuiInputBase-root.Mui-focused, & .MuiInputBase-root:hover:not(.Mui-disabled)':
{
'& .MuiIconButton-root': {
color: 'var(--color-teal)',
},
},
}}
/>
);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function SQFormDatePickerWithCalendarInputOnly({
label,
size = 'auto',
isDisabled = false,
placeholder = '',
placeholder,
onBlur,
onChange,
setDisabledDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function SQFormDatePickerWithDateFNS({
label,
size = 'auto',
isDisabled = false,
placeholder = '',
placeholder = 'MM / DD / YYYY',
onBlur,
onChange,
setDisabledDate,
Expand Down Expand Up @@ -79,26 +79,21 @@ function SQFormDatePickerWithDateFNS({
variant="standard"
error={isFieldError}
fullWidth={true}
inputProps={{...inputProps.inputProps, ...muiTextInputProps}}
inputProps={{
...inputProps.inputProps,
placeholder,
...muiTextInputProps,
}}
InputLabelProps={{shrink: true}}
FormHelperTextProps={{error: isFieldError}}
helperText={!isDisabled && HelperTextComponent}
placeholder={placeholder}
onBlur={handleBlur}
required={isFieldRequired}
onClick={
isCalendarOnly && !isDisabled
? toggleCalendar
: handleClickAway
}
sx={{
'& .MuiInputBase-root.Mui-focused, & .MuiInputBase-root:hover:not(.Mui-disabled)':
{
'& .MuiIconButton-root': {
color: 'var(--color-teal)',
},
},
}}
/>
);
}}
Expand Down
12 changes: 10 additions & 2 deletions src/components/fields/SQFormDatePicker/SQFormDateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {DateTimePicker} from '@mui/x-date-pickers';
import {useForm} from '../../../hooks/useForm';
import type {MarkOptional} from 'ts-essentials';
import type {Moment} from 'moment';
import type {InputBaseComponentProps} from '@mui/material';
import type {BaseDateTimePickerProps} from '@mui/x-date-pickers/DateTimePicker/shared';
import type {BaseFieldProps} from '../../../types';

Expand All @@ -21,17 +22,20 @@ export type SQFormDateTimePickerProps = BaseFieldProps & {
BaseDateTimePickerProps<Moment, Moment>,
'onChange' | 'value' | 'renderInput'
>;
/** Any valid prop for MUI input field - https://material-ui.com/api/text-field/ & https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes */
muiTextInputProps?: InputBaseComponentProps;
};

function SQFormDateTimePicker({
name,
label,
size = 'auto',
isDisabled = false,
placeholder = '',
placeholder = 'MM / DD / YYYY HH:MM (A|P)M',
onBlur,
onChange,
muiFieldProps = {},
muiTextInputProps = {},
}: SQFormDateTimePickerProps): JSX.Element {
const {
formikField: {field, helpers},
Expand Down Expand Up @@ -80,10 +84,14 @@ function SQFormDateTimePicker({
disabled={isDisabled}
error={isFieldError}
fullWidth={true}
inputProps={{
...inputProps.inputProps,
placeholder,
...muiTextInputProps,
}}
InputLabelProps={{shrink: true}}
FormHelperTextProps={{error: isFieldError}}
helperText={!isDisabled && HelperTextComponent}
placeholder={placeholder}
onBlur={handleBlur}
onClick={handleClickAway}
required={isFieldRequired}
Expand Down
Loading