Skip to content

Commit

Permalink
fix: compat ie10-11 for antd3 (#985)
Browse files Browse the repository at this point in the history
* feat: compat ie10-11 for antd3

* feat: update test snapshot
  • Loading branch information
JohnIsOnTheRoad authored Aug 3, 2020
1 parent 010e149 commit 74fa86c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 11 deletions.
25 changes: 20 additions & 5 deletions packages/antd/src/__tests__/__snapshots__/layout.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ exports[`inline style gutter item 1`] = `
vertical-align: top;
}
.c0 > .ant-form-item-control-wrapper,
.c0 > .ant-form-item-control {
display: inline-block;
}
.c0.mega-layout-item > .ant-form-item-control-wrapper {
display: inline-block;
}
.c0.ant-form-item.ant-row {
display: inline-block;
vertical-align: top;
Expand Down Expand Up @@ -72,11 +75,14 @@ exports[`inline style item 1`] = `
vertical-align: top;
}
.c0 > .ant-form-item-control-wrapper,
.c0 > .ant-form-item-control {
display: inline-block;
}
.c0.mega-layout-item > .ant-form-item-control-wrapper {
display: inline-block;
}
.c0.ant-form-item.ant-row {
display: inline-block;
vertical-align: top;
Expand Down Expand Up @@ -107,11 +113,14 @@ exports[`inline style labelAlign:top item 1`] = `
vertical-align: top;
}
.c0 > .ant-form-item-control-wrapper,
.c0 > .ant-form-item-control {
display: block;
}
.c0.mega-layout-item > .ant-form-item-control-wrapper {
display: block;
}
.c0.ant-form-item.ant-row {
display: inline-block;
vertical-align: top;
Expand Down Expand Up @@ -142,11 +151,14 @@ exports[`inline style labelAlign:top layout 1`] = `
vertical-align: top;
}
.c0 > .ant-form-item-control-wrapper,
.c0 > .ant-form-item-control {
display: block;
}
.c0.mega-layout-item > .ant-form-item-control-wrapper {
display: block;
}
<div
className="c0"
/>
Expand All @@ -163,11 +175,14 @@ exports[`inline style layout 1`] = `
vertical-align: top;
}
.c0 > .ant-form-item-control-wrapper,
.c0 > .ant-form-item-control {
display: inline-block;
}
.c0.mega-layout-item > .ant-form-item-control-wrapper {
display: inline-block;
}
<div
className="c0"
/>
Expand Down
30 changes: 30 additions & 0 deletions packages/antd/src/components/FormMegaLayout/ie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const getIEGridContainerStyle = (opts) => {
display: flex;
${autoRow ? 'flex-flow: row wrap;' : ''}
margin: -${halfGutter}px -${halfGutter}px;
grid-column-gap: 0;
grid-row-gap: 0;
.button-group {
padding-left: ${halfGutter}px;
Expand All @@ -21,6 +23,33 @@ const getIEGridContainerStyle = (opts) => {
return ''
}

const getIEContainerAntd3Style = (opts) => {
if (isIECompat) {
return `
.ant-form-item-control-wrapper {
display: flex;
flex-direction: column;
> .ant-form-item-control {
> .ant-form-item-children {
display: flex;
flex-direction: column;
min-height: 32px;
}
}
}
> .ant-form-item-control-wrapper {
flex: 1;
}
`
}

return ''
}

const getValidSpan = (span, cols) => span > cols ? cols : span
const getIEGridItemStyle = (opts) => {
if (isIECompat) {
Expand Down Expand Up @@ -69,6 +98,7 @@ const getIEGridItemStyle = (opts) => {
}

export {
getIEContainerAntd3Style,
getIEGridContainerStyle,
getIEGridItemStyle,
}
2 changes: 1 addition & 1 deletion packages/antd/src/components/FormMegaLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const MegaLayoutItem = (props) => {
componentProps.style = {
...(componentProps.style || {}),
width: '100%',
flex: 1,
flex: '1 1 0%',
}
}

Expand Down
13 changes: 10 additions & 3 deletions packages/antd/src/components/FormMegaLayout/style.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from 'styled-components'
import insetStyle from './inset'
import { getIEGridContainerStyle, getIEGridItemStyle } from './ie'
import { getIEContainerAntd3Style, getIEGridContainerStyle, getIEGridItemStyle } from './ie'

const formatPx = num => (typeof num === 'string' ? num.replace('px', '') : num)
export const computeAntdStyleBase = (props, debug?: boolean) => {
Expand Down Expand Up @@ -53,6 +53,7 @@ export const computeAntdStyleBase = (props, debug?: boolean) => {
flex: 1 1 0;
}
}
${getIEContainerAntd3Style()}
`

// 嵌套不需要执行响应
Expand Down Expand Up @@ -187,11 +188,17 @@ export const computeAntdStyleBase = (props, debug?: boolean) => {
display: inline-block;
vertical-align: top;
}
> .ant-form-item-control-wrapper,
> .ant-form-item-control {
display: ${labelAlign !== 'top' ? 'inline-block' : 'block'};
}
}
}
&.mega-layout-item {
> .ant-form-item-control-wrapper {
display: ${labelAlign !== 'top' ? 'inline-block' : 'block'};
}
}
`

if (!isLayout) {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/components/FormMegaLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const MegaLayoutItem = (props) => {
componentProps.style = {
...(componentProps.style || {}),
width: '100%',
flex: 1,
flex: '1 1 0%',
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react-schema-renderer/src/shared/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const connect = <ExtendsComponentKey extends string = ''>(
componentProps.style = {
...(componentProps.style || {}),
width: '100%',
flex: 1,
flex: '1 1 0%',
}
}

Expand Down

0 comments on commit 74fa86c

Please sign in to comment.