mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
Add fileinput, popover
This commit is contained in:
@@ -5,6 +5,8 @@ import {
|
|||||||
TextInputProps as MantineTextInputProps,
|
TextInputProps as MantineTextInputProps,
|
||||||
PasswordInput as MantinePasswordInput,
|
PasswordInput as MantinePasswordInput,
|
||||||
PasswordInputProps as MantinePasswordInputProps,
|
PasswordInputProps as MantinePasswordInputProps,
|
||||||
|
FileInput as MantineFileInput,
|
||||||
|
FileInputProps as MantineFileInputProps,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
|
|
||||||
interface TextInputProps extends MantineTextInputProps {
|
interface TextInputProps extends MantineTextInputProps {
|
||||||
@@ -15,6 +17,10 @@ interface PasswordInputProps extends MantinePasswordInputProps {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FileInputProps extends MantineFileInputProps {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
const StyledTextInput = styled(MantineTextInput)<TextInputProps>`
|
const StyledTextInput = styled(MantineTextInput)<TextInputProps>`
|
||||||
&:focus,
|
&:focus,
|
||||||
&:focus-within {
|
&:focus-within {
|
||||||
@@ -69,6 +75,23 @@ const StyledPasswordInput = styled(MantinePasswordInput)<PasswordInputProps>`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const StyledFileInput = styled(MantineFileInput)<FileInputProps>`
|
||||||
|
& .mantine-FileInput-input {
|
||||||
|
&:focus,
|
||||||
|
&:focus-within {
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-FileInput-required {
|
||||||
|
color: var(--secondary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-FileInput-label {
|
||||||
|
font-family: var(--label-font-faimly);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
|
export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(
|
||||||
({ children, ...props }: TextInputProps, ref) => {
|
({ children, ...props }: TextInputProps, ref) => {
|
||||||
return (
|
return (
|
||||||
@@ -89,6 +112,16 @@ export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const FileInput = forwardRef<HTMLButtonElement, FileInputProps>(
|
||||||
|
({ children, ...props }: FileInputProps, ref) => {
|
||||||
|
return (
|
||||||
|
<StyledFileInput ref={ref} spellCheck={false} {...props}>
|
||||||
|
{children}
|
||||||
|
</StyledFileInput>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
TextInput.defaultProps = {
|
TextInput.defaultProps = {
|
||||||
children: null,
|
children: null,
|
||||||
};
|
};
|
||||||
@@ -96,3 +129,7 @@ TextInput.defaultProps = {
|
|||||||
PasswordInput.defaultProps = {
|
PasswordInput.defaultProps = {
|
||||||
children: null,
|
children: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FileInput.defaultProps = {
|
||||||
|
children: null,
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import styled from '@emotion/styled';
|
||||||
|
import {
|
||||||
|
Popover as MantinePopover,
|
||||||
|
PopoverProps as MantinePopoverProps,
|
||||||
|
PopoverDropdownProps as MantinePopoverDropdownProps,
|
||||||
|
} from '@mantine/core';
|
||||||
|
|
||||||
|
type PopoverProps = MantinePopoverProps;
|
||||||
|
type PopoverDropdownProps = MantinePopoverDropdownProps;
|
||||||
|
|
||||||
|
const StyledPopover = styled(MantinePopover)``;
|
||||||
|
|
||||||
|
const StyledDropdown = styled(MantinePopover.Dropdown)<PopoverDropdownProps>`
|
||||||
|
padding: 0.5rem;
|
||||||
|
font-size: 0.9em;
|
||||||
|
font-family: var(--label-font-family);
|
||||||
|
background-color: var(--dropdown-menu-bg);
|
||||||
|
|
||||||
|
& .mantine-Menu-itemIcon {
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Popover = ({ children, ...props }: PopoverProps) => {
|
||||||
|
return <StyledPopover {...props}>{children}</StyledPopover>;
|
||||||
|
};
|
||||||
|
|
||||||
|
Popover.Target = MantinePopover.Target;
|
||||||
|
Popover.Dropdown = StyledDropdown;
|
||||||
Reference in New Issue
Block a user