Skip to content

Commit

Permalink
fix: Some input style issue (#21316)
Browse files Browse the repository at this point in the history
* fix firefox flex bug

* fix input wrapper style

* fix clear text style

* update snapshot
  • Loading branch information
zombieJ committed Feb 10, 2020
1 parent 06de637 commit 4192c1f
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 47 deletions.
35 changes: 33 additions & 2 deletions components/input/__tests__/__snapshots__/demo.test.js.snap
Expand Up @@ -14,7 +14,7 @@ exports[`renders ./components/input/demo/addon.md correctly 1`] = `
<span
class="ant-input-group-addon"
>
Http://
http://
</span>
<input
class="ant-input"
Expand Down Expand Up @@ -68,7 +68,7 @@ exports[`renders ./components/input/demo/addon.md correctly 1`] = `
<span
class="ant-select-selection-item"
>
Http://
http://
</span>
</div>
<span
Expand Down Expand Up @@ -211,6 +211,37 @@ exports[`renders ./components/input/demo/addon.md correctly 1`] = `
</span>
</span>
</div>
<div
style="margin-bottom:16px"
>
<span
class="ant-input-group-wrapper"
>
<span
class="ant-input-wrapper ant-input-group"
>
<span
class="ant-input-group-addon"
>
http://
</span>
<span
class="ant-input-affix-wrapper"
>
<input
class="ant-input"
type="text"
value="mysite"
/>
<span
class="ant-input-suffix"
>
.com
</span>
</span>
</span>
</span>
</div>
</div>
`;

Expand Down
11 changes: 7 additions & 4 deletions components/input/demo/addon.md
Expand Up @@ -20,9 +20,9 @@ import { SettingOutlined } from '@ant-design/icons';
const { Option } = Select;

const selectBefore = (
<Select defaultValue="Http://" style={{ width: 90 }}>
<Option value="Http://">Http://</Option>
<Option value="Https://">Https://</Option>
<Select defaultValue="http://" style={{ width: 90 }}>
<Option value="http://">http://</Option>
<Option value="https://">https://</Option>
</Select>
);
const selectAfter = (
Expand All @@ -37,14 +37,17 @@ const selectAfter = (
ReactDOM.render(
<div>
<div style={{ marginBottom: 16 }}>
<Input addonBefore="Http://" addonAfter=".com" defaultValue="mysite" />
<Input addonBefore="http://" addonAfter=".com" defaultValue="mysite" />
</div>
<div style={{ marginBottom: 16 }}>
<Input addonBefore={selectBefore} addonAfter={selectAfter} defaultValue="mysite" />
</div>
<div style={{ marginBottom: 16 }}>
<Input addonAfter={<SettingOutlined />} defaultValue="mysite" />
</div>
<div style={{ marginBottom: 16 }}>
<Input addonBefore="http://" suffix=".com" defaultValue="mysite" />
</div>
</div>,
mountNode,
);
Expand Down
7 changes: 1 addition & 6 deletions components/input/style/affix.less
Expand Up @@ -8,7 +8,7 @@
.input();
display: inline-flex;

> .@{ant-prefix}-input {
> input.@{ant-prefix}-input {
padding: 0;
border: none;
outline: none;
Expand All @@ -17,11 +17,6 @@
box-shadow: none;
}
}

.@{ant-prefix}-input-clear-icon {
margin: 0 @input-affix-margin;
vertical-align: -1px;
}
}

&-prefix,
Expand Down
47 changes: 47 additions & 0 deletions components/input/style/allow-clear.less
@@ -0,0 +1,47 @@
@import './index';

.clear-icon() {
color: @disabled-color;
font-size: @font-size-sm;
// https://github.com/ant-design/ant-design/pull/18151
// https://codesandbox.io/s/wizardly-sun-u10br
cursor: pointer;
transition: color 0.3s;

&:hover {
color: @text-color-secondary;
}

&:active {
color: @text-color;
}

+ i {
margin-left: 6px;
}
}

// ========================= Input =========================
.@{ant-prefix}-input-clear-icon {
.clear-icon;
margin: 0 @input-affix-margin;
vertical-align: -1px;

&:last-child {
margin-right: 0;
}
}

// ======================= TextArea ========================
.@{ant-prefix}-input-affix-wrapper-textarea-with-clear-btn {
padding: 0;
border: 0;
}

.@{ant-prefix}-input-textarea-clear-icon {
.clear-icon;
position: absolute;
top: 0;
right: 0;
margin: 8px 8px 0 0;
}
14 changes: 1 addition & 13 deletions components/input/style/index.less
Expand Up @@ -2,6 +2,7 @@
@import '../../style/mixins/index';
@import './mixin';
@import './affix';
@import './allow-clear';

// Input styles
.@{ant-prefix}-input {
Expand Down Expand Up @@ -37,17 +38,4 @@
}
}

.@{ant-prefix}-input-clear-icon {
.clear-icon;
vertical-align: 0;
}

.@{ant-prefix}-input-textarea-clear-icon {
.clear-icon;
position: absolute;
top: 0;
right: 0;
margin: 8px 8px 0 0;
}

@import './search-input';
32 changes: 10 additions & 22 deletions components/input/style/mixin.less
Expand Up @@ -61,6 +61,7 @@
position: relative;
display: inline-block;
width: 100%;
min-width: 0;
padding: @input-padding-vertical-base @input-padding-horizontal-base;
color: @input-color;
font-size: @font-size-base;
Expand Down Expand Up @@ -306,7 +307,15 @@
}

.@{inputClass}-affix-wrapper {
border-radius: 0;
&:not(:first-child) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}

&:not(:last-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
}

&&-compact {
Expand Down Expand Up @@ -417,24 +426,3 @@
}
}
}

.clear-icon() {
color: @disabled-color;
font-size: @font-size-sm;
// https://github.com/ant-design/ant-design/pull/18151
// https://codesandbox.io/s/wizardly-sun-u10br
cursor: pointer;
transition: color 0.3s;

&:hover {
color: @text-color-secondary;
}

&:active {
color: @text-color;
}

+ i {
margin-left: 6px;
}
}

0 comments on commit 4192c1f

Please sign in to comment.