1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 07:41:26 +00:00

Fix search input UI (#5769)

* fix code warnings

* change search UI
This commit is contained in:
Michael An
2023-11-15 15:39:47 +08:00
committed by GitHub
parent c5e9bb9d8f
commit 4e5c6fa98a
5 changed files with 57 additions and 26 deletions

View File

@@ -5,8 +5,7 @@ import classnames from 'classnames';
import '../../../css/switch.css';
function Switch(props) {
const { onChange, checked, placeholder, disabled, className, size } = props;
const { onChange, checked, placeholder, disabled, className, size, textPosition } = props;
return(
<div className={classnames('seahub-switch position-relative', className, size)}>
<label className="custom-switch">
@@ -18,8 +17,13 @@ function Switch(props) {
name="custom-switch-checkbox"
disabled={disabled}
/>
<span className="custom-switch-description text-truncate">{placeholder}</span>
<span className="custom-switch-indicator"></span>
{textPosition === 'left' &&
<span className="custom-switch-description text-truncate">{placeholder}</span>
}
<span className={classnames('custom-switch-indicator', {'disabled': disabled})}></span>
{textPosition === 'right' &&
<span className="custom-switch-description text-truncate">{placeholder}</span>
}
</label>
</div>
);
@@ -31,7 +35,12 @@ Switch.propTypes = {
placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
className: PropTypes.string,
size: PropTypes.oneOf(['large', 'small', undefined]),
onChange: PropTypes.func.isRequired,
textPosition: PropTypes.oneOf(['left', 'right', undefined]),
onChange: PropTypes.func,
};
Switch.defaultProps = {
textPosition: 'left',
};
export default Switch;