Update base components

This commit is contained in:
jeffvli
2022-11-02 22:05:16 -07:00
parent 94b40178aa
commit a888007bfa
4 changed files with 121 additions and 10 deletions
@@ -0,0 +1,19 @@
import styled from '@emotion/styled';
import {
DatePicker as MantineDatePicker,
DatePickerProps as MantineDatePickerProps,
} from '@mantine/dates';
interface DatePickerProps extends MantineDatePickerProps {
width?: number | string;
}
const StyledDatePicker = styled(MantineDatePicker)<DatePickerProps>``;
export const DatePicker = ({ width, ...props }: DatePickerProps) => {
return <StyledDatePicker {...props} sx={{ width }} />;
};
DatePicker.defaultProps = {
width: undefined,
};
+3
View File
@@ -9,3 +9,6 @@ export * from './segmented-control';
export * from './dropdown-menu'; export * from './dropdown-menu';
export * from './toast'; export * from './toast';
export * from './switch'; export * from './switch';
export * from './popover';
export * from './select';
export * from './date-picker';
+80 -10
View File
@@ -3,6 +3,8 @@ import styled from '@emotion/styled';
import { import {
TextInput as MantineTextInput, TextInput as MantineTextInput,
TextInputProps as MantineTextInputProps, TextInputProps as MantineTextInputProps,
NumberInput as MantineNumberInput,
NumberInputProps as MantineNumberInputProps,
PasswordInput as MantinePasswordInput, PasswordInput as MantinePasswordInput,
PasswordInputProps as MantinePasswordInputProps, PasswordInputProps as MantinePasswordInputProps,
FileInput as MantineFileInput, FileInput as MantineFileInput,
@@ -11,14 +13,22 @@ import {
interface TextInputProps extends MantineTextInputProps { interface TextInputProps extends MantineTextInputProps {
children?: React.ReactNode; children?: React.ReactNode;
width?: number | string;
}
interface NumberInputProps extends MantineNumberInputProps {
children?: React.ReactNode;
width?: number | string;
} }
interface PasswordInputProps extends MantinePasswordInputProps { interface PasswordInputProps extends MantinePasswordInputProps {
children?: React.ReactNode; children?: React.ReactNode;
width?: number | string;
} }
interface FileInputProps extends MantineFileInputProps { interface FileInputProps extends MantineFileInputProps {
children?: React.ReactNode; children?: React.ReactNode;
width?: number | string;
} }
const StyledTextInput = styled(MantineTextInput)<TextInputProps>` const StyledTextInput = styled(MantineTextInput)<TextInputProps>`
@@ -58,6 +68,43 @@ const StyledTextInput = styled(MantineTextInput)<TextInputProps>`
} }
`; `;
const StyledNumberInput = styled(MantineNumberInput)<NumberInputProps>`
&:focus,
&:focus-within {
border-color: var(--primary-color);
}
& .mantine-NumberInput-wrapper {
border-color: var(--primary-color);
}
& .mantine-NumberInput-input {
&:focus,
&:focus-within {
border-color: var(--primary-color);
}
color: var(--input-fg);
background: var(--input-bg);
&::placeholder {
color: var(--input-placeholder-fg);
}
}
& .mantine-Input-icon {
color: var(--input-placeholder-fg);
}
& .mantine-NumberInput-required {
color: var(--secondary-color);
}
& .mantine-NumberInput-label {
font-family: var(--label-font-faimly);
}
`;
const StyledPasswordInput = styled(MantinePasswordInput)<PasswordInputProps>` const StyledPasswordInput = styled(MantinePasswordInput)<PasswordInputProps>`
& .mantine-PasswordInput-input { & .mantine-PasswordInput-input {
&:focus, &:focus,
@@ -93,19 +140,34 @@ const StyledFileInput = styled(MantineFileInput)<FileInputProps>`
`; `;
export const TextInput = forwardRef<HTMLInputElement, TextInputProps>( export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
({ children, ...props }: TextInputProps, ref) => { ({ children, width, ...props }: TextInputProps, ref) => {
return ( return (
<StyledTextInput ref={ref} spellCheck={false} {...props}> <StyledTextInput ref={ref} spellCheck={false} {...props} sx={{ width }}>
{children} {children}
</StyledTextInput> </StyledTextInput>
); );
} }
); );
export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>( export const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
({ children, ...props }: PasswordInputProps, ref) => { ({ children, width, ...props }: NumberInputProps, ref) => {
return ( return (
<StyledPasswordInput ref={ref} spellCheck={false} {...props}> <StyledNumberInput ref={ref} spellCheck={false} {...props} sx={{ width }}>
{children}
</StyledNumberInput>
);
}
);
export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
({ children, width, ...props }: PasswordInputProps, ref) => {
return (
<StyledPasswordInput
ref={ref}
spellCheck={false}
{...props}
sx={{ width }}
>
{children} {children}
</StyledPasswordInput> </StyledPasswordInput>
); );
@@ -113,9 +175,9 @@ export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
); );
export const FileInput = forwardRef<HTMLButtonElement, FileInputProps>( export const FileInput = forwardRef<HTMLButtonElement, FileInputProps>(
({ children, ...props }: FileInputProps, ref) => { ({ children, width, ...props }: FileInputProps, ref) => {
return ( return (
<StyledFileInput ref={ref} spellCheck={false} {...props}> <StyledFileInput ref={ref} spellCheck={false} {...props} sx={{ width }}>
{children} {children}
</StyledFileInput> </StyledFileInput>
); );
@@ -123,13 +185,21 @@ export const FileInput = forwardRef<HTMLButtonElement, FileInputProps>(
); );
TextInput.defaultProps = { TextInput.defaultProps = {
children: null, children: undefined,
width: undefined,
};
NumberInput.defaultProps = {
children: undefined,
width: undefined,
}; };
PasswordInput.defaultProps = { PasswordInput.defaultProps = {
children: null, children: undefined,
width: undefined,
}; };
FileInput.defaultProps = { FileInput.defaultProps = {
children: null, children: undefined,
width: undefined,
}; };
+19
View File
@@ -0,0 +1,19 @@
import styled from '@emotion/styled';
import {
Select as MantineSelect,
SelectProps as MantineSelectProps,
} from '@mantine/core';
interface SelectProps extends MantineSelectProps {
width?: number | string;
}
const StyledSelect = styled(MantineSelect)``;
export const Select = ({ width, ...props }: SelectProps) => {
return <StyledSelect {...props} sx={{ width }} />;
};
Select.defaultProps = {
width: undefined,
};