From 99f9e67500a1ef98f82c3ac60068e58ec6af817e Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sun, 20 Nov 2022 04:45:10 -0800 Subject: [PATCH] Add Textarea and JsonInput components --- src/renderer/components/input/index.tsx | 113 +++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/input/index.tsx b/src/renderer/components/input/index.tsx index 6051951d8..4be50924e 100644 --- a/src/renderer/components/input/index.tsx +++ b/src/renderer/components/input/index.tsx @@ -8,6 +8,10 @@ import { PasswordInputProps as MantinePasswordInputProps, FileInput as MantineFileInput, FileInputProps as MantineFileInputProps, + JsonInput as MantineJsonInput, + JsonInputProps as MantineJsonInputProps, + Textarea as MantineTextarea, + TextareaProps as MantineTextareaProps, } from '@mantine/core'; import styled from 'styled-components'; @@ -35,6 +39,18 @@ interface FileInputProps extends MantineFileInputProps { 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)` & .mantine-TextInput-wrapper { border-color: var(--primary-color); @@ -163,6 +179,60 @@ const StyledFileInput = styled(MantineFileInput)` } `; +const StyledJsonInput = styled(MantineJsonInput)` + & .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)` + & .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( ({ children, width, maxWidth, ...props }: TextInputProps, ref) => { return ( @@ -207,13 +277,42 @@ export const PasswordInput = forwardRef( export const FileInput = forwardRef( ({ children, width, maxWidth, ...props }: FileInputProps, ref) => { return ( - + {children} ); } ); +export const JsonInput = forwardRef( + ({ children, width, maxWidth, ...props }: JsonInputProps, ref) => { + return ( + + {children} + + ); + } +); + +export const Textarea = forwardRef( + ({ children, width, maxWidth, ...props }: TextareaProps, ref) => { + return ( + + {children} + + ); + } +); + TextInput.defaultProps = { children: undefined, maxWidth: undefined, @@ -237,3 +336,15 @@ FileInput.defaultProps = { maxWidth: undefined, width: undefined, }; + +JsonInput.defaultProps = { + children: undefined, + maxWidth: undefined, + width: undefined, +}; + +Textarea.defaultProps = { + children: undefined, + maxWidth: undefined, + width: undefined, +};