Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Layout): add prop zeroWidthTriggerStyle #19079

Merged
merged 5 commits into from Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions components/layout/Sider.tsx
Expand Up @@ -52,6 +52,7 @@ export interface SiderProps extends React.HTMLAttributes<HTMLDivElement> {
defaultCollapsed?: boolean;
reverseArrow?: boolean;
onCollapse?: (collapsed: boolean, type: CollapseType) => void;
specialTriggerStyle?: React.CSSProperties;
trigger?: React.ReactNode;
width?: number | string;
collapsedWidth?: number | string;
Expand Down Expand Up @@ -186,6 +187,7 @@ class InternalSider extends React.Component<InternalSideProps, SiderState> {
style,
width,
collapsedWidth,
specialTriggerStyle,
...others
} = this.props;
const prefixCls = getPrefixCls('layout-sider', customizePrefixCls);
Expand All @@ -196,6 +198,7 @@ class InternalSider extends React.Component<InternalSideProps, SiderState> {
'breakpoint',
'onBreakpoint',
'siderHook',
'specialTriggerStyle',
]);
const rawWidth = this.state.collapsed ? collapsedWidth : width;
// use "px" as fallback unit for width
Expand All @@ -208,6 +211,7 @@ class InternalSider extends React.Component<InternalSideProps, SiderState> {
className={`${prefixCls}-zero-width-trigger ${prefixCls}-zero-width-trigger-${
reverseArrow ? 'right' : 'left'
}`}
style={specialTriggerStyle}
>
<Icon type="bars" />
</span>
Expand Down
16 changes: 16 additions & 0 deletions components/layout/__tests__/index.test.js
Expand Up @@ -185,4 +185,20 @@ describe('Sider', () => {
'Warning: [antd: Menu] `inlineCollapsed` not control Menu under Sider. Should set `collapsed` on Sider instead.',
);
});

it('specialTriggerStyle should work', () => {
const wrapper = mount(
<Sider collapsedWidth={0} collapsible specialTriggerStyle={{ background: '#F96' }}>
<Menu theme="dark" mode="inline" defaultSelectedKeys={['1']}>
<Menu.Item key="1">
<Icon type="user" />
<span>nav 1</span>
</Menu.Item>
</Menu>
</Sider>,
);
expect(wrapper.find('.ant-layout-sider-zero-width-trigger').props().style).toEqual({
background: '#F96',
});
});
});