0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

fix(ac): fix ac text input (#1023)

fix ac text input
This commit is contained in:
simeng-li 2022-06-02 10:23:53 +08:00 committed by GitHub
parent a5fa636d9a
commit 498b3708ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 36 deletions

View file

@ -8,6 +8,7 @@
transition-timing-function: ease-in-out; transition-timing-function: ease-in-out;
transition-duration: 0.2s; transition-duration: 0.2s;
padding: _.unit(2) _.unit(3); padding: _.unit(2) _.unit(3);
background: var(--color-layer-1);
font: var(--font-body-medium); font: var(--font-body-medium);
&.withIcon { &.withIcon {
@ -29,9 +30,9 @@
input { input {
width: 100%; width: 100%;
appearance: none; appearance: none;
background: var(--color-layer-1);
color: var(--color-text); color: var(--color-text);
font: var(--font-body-medium); font: var(--font-body-medium);
background: transparent;
padding: 0; padding: 0;
&::placeholder { &::placeholder {
@ -40,7 +41,7 @@
// Overwrite webkit auto-fill style // Overwrite webkit auto-fill style
&:-webkit-autofill { &:-webkit-autofill {
box-shadow: 0 0 0 30px var(--color-control-background) inset; box-shadow: 0 0 0 30px transparent inset;
transition: background-color 5000s ease-in-out 0s; transition: background-color 5000s ease-in-out 0s;
-webkit-text-fill-color: var(--color-text); -webkit-text-fill-color: var(--color-text);
} }
@ -50,10 +51,6 @@
background: var(--color-inverse-on-surface); background: var(--color-inverse-on-surface);
color: var(--color-caption); color: var(--color-caption);
border-color: var(--color-border); border-color: var(--color-border);
input {
background: none;
}
} }
&.readOnly { &.readOnly {
@ -61,11 +58,6 @@
color: var(--color-text); color: var(--color-text);
border-color: var(--color-border); border-color: var(--color-border);
input {
background: none;
}
&:focus-within { &:focus-within {
border-color: var(--color-border); border-color: var(--color-border);
outline-color: transparent; outline-color: transparent;

View file

@ -1,35 +1,32 @@
import classNames from 'classnames'; import classNames from 'classnames';
import React, { forwardRef, HTMLProps, ReactNode } from 'react'; import React, { forwardRef, HTMLProps, ReactNode, ForwardedRef } from 'react';
import * as styles from './index.module.scss'; import * as styles from './index.module.scss';
// https://github.com/yannickcr/eslint-plugin-react/issues/2856
/* eslint-disable react/require-default-props */
type Props = HTMLProps<HTMLInputElement> & { type Props = HTMLProps<HTMLInputElement> & {
hasError?: boolean; hasError?: boolean;
icon?: ReactNode; icon?: ReactNode;
disabled?: boolean;
readOnly?: boolean;
}; };
/* eslint-enable react/require-default-props */
const TextInput = forwardRef<HTMLInputElement, Props>( const TextInput = (
({ hasError = false, icon, disabled, readOnly, ...rest }, reference) => { { hasError = false, icon, disabled, className, readOnly, ...rest }: Props,
return ( reference: ForwardedRef<HTMLInputElement>
<div ) => {
className={classNames( return (
styles.container, <div
hasError && styles.error, className={classNames(
icon && styles.withIcon, styles.container,
disabled && styles.disabled, hasError && styles.error,
readOnly && styles.readOnly icon && styles.withIcon,
)} disabled && styles.disabled,
> readOnly && styles.readOnly,
{icon && <span className={styles.icon}>{icon}</span>} className
<input type="text" {...rest} ref={reference} disabled={disabled} readOnly={readOnly} /> )}
</div> >
); {icon && <span className={styles.icon}>{icon}</span>}
} <input type="text" {...rest} ref={reference} disabled={disabled} readOnly={readOnly} />
); </div>
);
};
export default TextInput; export default forwardRef(TextInput);