mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 05:36:00 +02:00
Add Textarea and JsonInput components
This commit is contained in:
@@ -8,6 +8,10 @@ import {
|
|||||||
PasswordInputProps as MantinePasswordInputProps,
|
PasswordInputProps as MantinePasswordInputProps,
|
||||||
FileInput as MantineFileInput,
|
FileInput as MantineFileInput,
|
||||||
FileInputProps as MantineFileInputProps,
|
FileInputProps as MantineFileInputProps,
|
||||||
|
JsonInput as MantineJsonInput,
|
||||||
|
JsonInputProps as MantineJsonInputProps,
|
||||||
|
Textarea as MantineTextarea,
|
||||||
|
TextareaProps as MantineTextareaProps,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
@@ -35,6 +39,18 @@ interface FileInputProps extends MantineFileInputProps {
|
|||||||
width?: number | string;
|
width?: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface JsonInputProps extends MantineJsonInputProps {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
maxWidth?: number | string;
|
||||||
|
width?: number | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TextareaProps extends MantineTextareaProps {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
maxWidth?: number | string;
|
||||||
|
width?: number | string;
|
||||||
|
}
|
||||||
|
|
||||||
const StyledTextInput = styled(MantineTextInput)<TextInputProps>`
|
const StyledTextInput = styled(MantineTextInput)<TextInputProps>`
|
||||||
& .mantine-TextInput-wrapper {
|
& .mantine-TextInput-wrapper {
|
||||||
border-color: var(--primary-color);
|
border-color: var(--primary-color);
|
||||||
@@ -163,6 +179,60 @@ const StyledFileInput = styled(MantineFileInput)<FileInputProps>`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const StyledJsonInput = styled(MantineJsonInput)<JsonInputProps>`
|
||||||
|
& .mantine-JsonInput-input {
|
||||||
|
color: var(--input-fg);
|
||||||
|
background: var(--input-bg);
|
||||||
|
|
||||||
|
&::placeholder {
|
||||||
|
color: var(--input-placeholder-fg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-JsonInput-icon {
|
||||||
|
color: var(--input-placeholder-fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-JsonInput-required {
|
||||||
|
color: var(--secondary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-JsonInput-label {
|
||||||
|
font-family: var(--label-font-faimly);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-JsonInput-disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledTextarea = styled(MantineTextarea)<TextareaProps>`
|
||||||
|
& .mantine-Textarea-input {
|
||||||
|
color: var(--input-fg);
|
||||||
|
background: var(--input-bg);
|
||||||
|
|
||||||
|
&::placeholder {
|
||||||
|
color: var(--input-placeholder-fg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-Textarea-icon {
|
||||||
|
color: var(--input-placeholder-fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-Textarea-required {
|
||||||
|
color: var(--secondary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-Textarea-label {
|
||||||
|
font-family: var(--label-font-faimly);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-Textarea-disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
|
export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
|
||||||
({ children, width, maxWidth, ...props }: TextInputProps, ref) => {
|
({ children, width, maxWidth, ...props }: TextInputProps, ref) => {
|
||||||
return (
|
return (
|
||||||
@@ -207,13 +277,42 @@ export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
|
|||||||
export const FileInput = forwardRef<HTMLButtonElement, FileInputProps>(
|
export const FileInput = forwardRef<HTMLButtonElement, FileInputProps>(
|
||||||
({ children, width, maxWidth, ...props }: FileInputProps, ref) => {
|
({ children, width, maxWidth, ...props }: FileInputProps, ref) => {
|
||||||
return (
|
return (
|
||||||
<StyledFileInput ref={ref} {...props} sx={{ maxWidth, width }}>
|
<StyledFileInput
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
styles={{
|
||||||
|
placeholder: {
|
||||||
|
color: 'var(--input-placeholder-fg)',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
sx={{ maxWidth, width }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</StyledFileInput>
|
</StyledFileInput>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const JsonInput = forwardRef<HTMLTextAreaElement, JsonInputProps>(
|
||||||
|
({ children, width, maxWidth, ...props }: JsonInputProps, ref) => {
|
||||||
|
return (
|
||||||
|
<StyledJsonInput ref={ref} {...props} sx={{ maxWidth, width }}>
|
||||||
|
{children}
|
||||||
|
</StyledJsonInput>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
||||||
|
({ children, width, maxWidth, ...props }: TextareaProps, ref) => {
|
||||||
|
return (
|
||||||
|
<StyledTextarea ref={ref} {...props} sx={{ maxWidth, width }}>
|
||||||
|
{children}
|
||||||
|
</StyledTextarea>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
TextInput.defaultProps = {
|
TextInput.defaultProps = {
|
||||||
children: undefined,
|
children: undefined,
|
||||||
maxWidth: undefined,
|
maxWidth: undefined,
|
||||||
@@ -237,3 +336,15 @@ FileInput.defaultProps = {
|
|||||||
maxWidth: undefined,
|
maxWidth: undefined,
|
||||||
width: undefined,
|
width: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JsonInput.defaultProps = {
|
||||||
|
children: undefined,
|
||||||
|
maxWidth: undefined,
|
||||||
|
width: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
Textarea.defaultProps = {
|
||||||
|
children: undefined,
|
||||||
|
maxWidth: undefined,
|
||||||
|
width: undefined,
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user