偏右
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
11 additions and
32 deletions
-
components/layout/Sider.tsx
-
components/layout/__tests__/index.test.js
-
components/typography/Typography.tsx
|
|
@ -50,7 +50,6 @@ type InternalSideProps = SiderProps & LayoutContextProps; |
|
|
|
export interface SiderState { |
|
|
|
collapsed?: boolean; |
|
|
|
below: boolean; |
|
|
|
belowShow?: boolean; |
|
|
|
} |
|
|
|
|
|
|
|
const generateId = (() => { |
|
|
@ -124,6 +123,7 @@ class InternalSider extends React.Component<InternalSideProps, SiderState> { |
|
|
|
} |
|
|
|
|
|
|
|
if (this.props.siderHook) { |
|
|
|
console.log('removeSider'); |
|
|
|
this.props.siderHook.removeSider(this.uniqueId); |
|
|
|
} |
|
|
|
} |
|
|
@ -156,10 +156,6 @@ class InternalSider extends React.Component<InternalSideProps, SiderState> { |
|
|
|
this.setCollapsed(collapsed, 'clickTrigger'); |
|
|
|
}; |
|
|
|
|
|
|
|
belowShowChange = () => { |
|
|
|
this.setState(({ belowShow }) => ({ belowShow: !belowShow })); |
|
|
|
}; |
|
|
|
|
|
|
|
renderSider = ({ getPrefixCls }: ConfigConsumerProps) => { |
|
|
|
const { |
|
|
|
prefixCls: customizePrefixCls, |
|
|
|
|
|
@ -12,6 +12,12 @@ describe('Layout', () => { |
|
|
|
mountTest(Layout); |
|
|
|
mountTest(Content); |
|
|
|
mountTest(Sider); |
|
|
|
mountTest(() => ( |
|
|
|
<Layout> |
|
|
|
<Sider /> |
|
|
|
<Content /> |
|
|
|
</Layout> |
|
|
|
)); |
|
|
|
|
|
|
|
rtlTest(Layout); |
|
|
|
rtlTest(Content); |
|
|
@ -60,18 +66,8 @@ describe('Layout', () => { |
|
|
|
<Content>Content</Content> |
|
|
|
</Layout>, |
|
|
|
); |
|
|
|
expect( |
|
|
|
wrapper |
|
|
|
.find('.ant-layout-sider') |
|
|
|
.at(0) |
|
|
|
.prop('style').width, |
|
|
|
).toBe('50%'); |
|
|
|
expect( |
|
|
|
wrapper |
|
|
|
.find('.ant-layout-sider') |
|
|
|
.at(0) |
|
|
|
.prop('style').flex, |
|
|
|
).toBe('0 0 50%'); |
|
|
|
expect(wrapper.find('.ant-layout-sider').at(0).prop('style').width).toBe('50%'); |
|
|
|
expect(wrapper.find('.ant-layout-sider').at(0).prop('style').flex).toBe('0 0 50%'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('detect ant-layout-sider-zero-width class in sider when its width is 0%', async () => { |
|
|
|
|
|
@ -61,22 +61,9 @@ const Typography: React.RefForwardingComponent<{}, InternalTypographyProps> = ( |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
let RefTypography; |
|
|
|
const RefTypography = React.forwardRef(Typography); |
|
|
|
|
|
|
|
if (React.forwardRef) { |
|
|
|
RefTypography = React.forwardRef(Typography); |
|
|
|
RefTypography.displayName = 'Typography'; |
|
|
|
} else { |
|
|
|
class TypographyWrapper extends React.Component<TypographyProps, {}> { |
|
|
|
state = {}; |
|
|
|
|
|
|
|
render() { |
|
|
|
return <Typography {...this.props} />; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RefTypography = TypographyWrapper; |
|
|
|
} |
|
|
|
RefTypography.displayName = 'Typography'; |
|
|
|
|
|
|
|
// es default export should use const instead of let
|
|
|
|
const ExportTypography = (RefTypography as unknown) as React.FC<TypographyProps>; |
|
|
|