Skip to content

Commit

Permalink
feat: customizable collapse transition
Browse files Browse the repository at this point in the history
  • Loading branch information
mic-web authored and spawnia committed Mar 18, 2024
1 parent 5556a03 commit 5ddc372
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Collapse/Collapse.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Collapse as AntdCollapse } from 'antd';
import { CollapseProps as AntdCollapseProps } from 'antd/lib/collapse/Collapse';
import { CollapsePanelProps as AntdCollapsePanelProps } from 'antd/lib/collapse/CollapsePanel';
import styled from 'styled-components';
import styled, { css } from 'styled-components';

import { fontSizeFromTheme } from '../styled-utils';

Expand All @@ -18,6 +18,14 @@ const StyledCollapse: typeof AntdCollapse = styled(
.mll-ant-collapse-item > .mll-ant-collapse-header {
align-items: center;
}
.ant-motion-collapse {
${(props) =>
props.theme.collapseTransition &&
css`
transition: ${props.theme.collapseTransition} !important;
`}
}
`;

export const Collapse: typeof AntdCollapse = StyledCollapse;
Expand Down
2 changes: 2 additions & 0 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type Theme = {
backgroundColor: string;
borderColor: string;
collapseBackgroundColor: string;
collapseTransition?: string;
containerBorderColor: string;
dividerColor: string;
focusedRowColor: string;
Expand Down Expand Up @@ -66,6 +67,7 @@ export const THEME: Theme = {
backgroundColor: PALETTE.blueTintedGray,
borderColor: PALETTE.blue,
collapseBackgroundColor: PALETTE.lightBlue,
collapseTransition: '0.05s',
containerBorderColor: PALETTE.gray4,
dividerColor: PALETTE.gray4,
focusedRowColor: PALETTE.lightBlue,
Expand Down

0 comments on commit 5ddc372

Please sign in to comment.