fix: Fix magic input css

fix magic input css

Change-Id: Ifcbedbb46102fa217794c573bb6d4eba2956aaa2
This commit is contained in:
zhuyue 2021-09-03 11:23:20 +08:00
parent 73300c38d8
commit 40a7831e79
2 changed files with 71 additions and 34 deletions

View File

@ -14,7 +14,7 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Input, Tag, Menu, Divider, Button, Checkbox } from 'antd'; import { Input, Tag, Menu, Divider, Button, Checkbox, Row, Col } from 'antd';
import { CloseOutlined, SearchOutlined } from '@ant-design/icons'; import { CloseOutlined, SearchOutlined } from '@ant-design/icons';
import classnames from 'classnames'; import classnames from 'classnames';
import { isEmpty, isBoolean } from 'lodash'; import { isEmpty, isBoolean } from 'lodash';
@ -283,7 +283,7 @@ class MagicInput extends PureComponent {
</Tag> </Tag>
); );
}); });
return <div className={styles.tags}>{tagItems}</div>; return tagItems;
} }
renderOptions() { renderOptions() {
@ -368,12 +368,14 @@ class MagicInput extends PureComponent {
return null; return null;
} }
return ( return (
<Button <Col className={styles['close-btn-col']}>
className={styles['close-btn']} <Button
type="link" className={styles['close-btn']}
icon={<CloseOutlined />} type="link"
onClick={this.clearAll} icon={<CloseOutlined />}
/> onClick={this.clearAll}
/>
</Col>
); );
} }
@ -531,16 +533,16 @@ class MagicInput extends PureComponent {
'magic-input-outer-wrapper' 'magic-input-outer-wrapper'
)} )}
> >
<div <Row
className={classnames( className={classnames(
'magic-input-wrapper', 'magic-input-wrapper',
styles['magic-input-wrapper'], styles['magic-input-wrapper'],
isFocus ? styles['magic-input-wrapper-active'] : '' isFocus ? styles['magic-input-wrapper-active'] : ''
)} )}
> >
{this.renderTags()} <Col>{this.renderTags()}</Col>
{this.renderKey()} <Col>{this.renderKey()}</Col>
<div className={styles['input-wrapper']}> <Col className={styles['input-wrapper']}>
<Input <Input
className={styles.input} className={styles.input}
ref={this.inputRef} ref={this.inputRef}
@ -553,12 +555,12 @@ class MagicInput extends PureComponent {
onKeyUp={this.handleKeyUp} onKeyUp={this.handleKeyUp}
/> />
{this.renderMenu()} {this.renderMenu()}
</div> </Col>
<div className={styles['search-icon']}> <Col className={styles['search-icon']}>
<SearchOutlined /> <SearchOutlined />
</div> </Col>
{this.renderClose()} {this.renderClose()}
</div> </Row>
{this.renderChecks()} {this.renderChecks()}
</div> </div>
); );

View File

@ -1,15 +1,16 @@
@import "~styles/variables"; @import '~styles/variables';
.magic-input-outer-wrapper { .magic-input-outer-wrapper {
display: flex; display: flex;
} }
.magic-input-wrapper { .magic-input-wrapper {
flex: 1; align-items: center;
height: 32px; width: 100%;
min-width: 200px;
border: 1px solid rgb(217, 217, 217); border: 1px solid rgb(217, 217, 217);
border-radius: @border-radius; border-radius: @border-radius;
padding: 3px 0 3px 8px; padding: 3px 0 3px 8px;
display: flex;
background-color: #fff; background-color: #fff;
position: relative; position: relative;
@ -29,43 +30,51 @@
margin-left: 16px; margin-left: 16px;
} }
} }
.ant-btn { .ant-btn {
margin-top: -3px; margin-top: -3px;
margin-right: 0; margin-right: 0;
} }
.ant-btn-icon-only { .ant-btn-icon-only {
background-color: #fff; background-color: #fff;
height: 30px;
} }
} }
} }
.magic-input-wrapper-active { .magic-input-wrapper-active {
border-color: @primary-color; border-color: @primary-color;
box-shadow: 0 0 0 2px rgba(0, 104, 255, 0.2); box-shadow: 0 0 0 2px rgba(0, 104, 255, 0.2);
} }
.input-wrapper { .input-wrapper {
margin-top: -4px;
height: 32px;
position: relative; position: relative;
flex-grow: 1; flex-grow: 1;
height: 24px;
line-height: 24px;
:global { :global {
.ant-input { .ant-input {
border: none; border: none;
box-shadow: none; box-shadow: none;
padding-left: 0; padding: 0;
background: none; background: none;
} }
.ant-input:focus { .ant-input:focus {
border: none; border: none;
box-shadow: none; box-shadow: none;
} }
input::placeholder { input::placeholder {
font-size: 10px; font-size: 10px;
} }
.ant-menu-vertical > .ant-menu-item { .ant-menu-vertical > .ant-menu-item {
height: 26px; height: 26px;
line-height: 26px; line-height: 26px;
} }
.ant-menu-vertical .ant-menu-item { .ant-menu-vertical .ant-menu-item {
font-size: 10px; font-size: 10px;
margin-top: 0px; margin-top: 0px;
@ -73,17 +82,20 @@
} }
} }
} }
.tags {
height: 24px; .tagItem {
overflow: hidden; margin-bottom: 5px;
flex: 0 0 auto;
} }
.input { .input {
} }
.menu { .menu {
box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.09) !important; box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.09) !important;
} }
.menu, .option-menu {
.menu,
.option-menu {
position: absolute; position: absolute;
z-index: 100; z-index: 100;
top: 34px; top: 34px;
@ -92,9 +104,11 @@
overflow-x: hidden; overflow-x: hidden;
max-height: 310px; max-height: 310px;
} }
.key { .key {
font-size: 10px; font-size: 10px;
line-height: 24px; line-height: 24px;
:global { :global {
.ant-divider, .ant-divider,
.ant-divider-vertical { .ant-divider-vertical {
@ -103,15 +117,26 @@
} }
} }
} }
:global { :global {
.ant-form-item-has-error .magic-input-wrapper .ant-input, .ant-form-item-has-error .magic-input-wrapper .ant-input,
.ant-form-item-has-error .magic-input-wrapper .ant-input:focus, .ant-form-item-has-error .magic-input-wrapper .ant-input:focus,
.ant-form-item-has-error .magic-input-wrapper .ant-input:not([disabled]):hover { .ant-form-item-has-error
.magic-input-wrapper
.ant-input:not([disabled]):hover {
background: none; background: none;
border: none; border: none;
box-shadow: none; box-shadow: none;
} }
.magic-input-wrapper .ant-tag {
display: inline-block;
height: 24px;
line-height: 24px;
margin: 0 5px 0 0;
}
} }
.search-icon { .search-icon {
position: absolute; position: absolute;
right: 8px; right: 8px;
@ -120,14 +145,24 @@
font-size: 12px; font-size: 12px;
line-height: 32px; line-height: 32px;
} }
.close-btn {
height: 28px !important; .close-btn-col {
height: 24px;
line-height: 24px;
.close-btn {
border: none;
height: 24px !important;
padding: 0;
}
} }
.close-option-btn { .close-option-btn {
height: 28px !important; height: 24px !important;
top: 3px; top: 3px;
} }
.magic-input-checks { .magic-input-checks {
line-height: 32px; line-height: 32px;
margin-left: 8px; margin-left: 8px;
} }