Issue #6976 @FelixMalfait I could not do ``` import { Banner } from 'twenty-ui'; const StyledBanner = styled(Banner) display: flex; align-items: center; padding: ${({ theme }) => theme.spacing(8)}; position: absolute; border-radius: 8px; &:hover { background-color: ${({ theme }) => theme.accent.primary}; } ; ``` The styles wont get overridden for Banner, so for now I styled a new banner in `UnmatchColumnBanner` which is inconsistent. I couldnt figure out why css properties are not being overridden, need help! @Bonapara Question - Should the click work on entire banner or just cheveron? For now it just on cheveron click. https://github.com/user-attachments/assets/0f409e78-a341-4f26-af74-117e4b2775a9 --------- Co-authored-by: Charles Bochet <charles@twenty.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import styled from '@emotion/styled';
|
|
import { isDefined } from '@ui/utilities';
|
|
import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
|
|
const StyledTransitionContainer = styled.div<{
|
|
isExpanded: boolean;
|
|
height: number;
|
|
}>`
|
|
max-height: ${({ isExpanded, height }) => (isExpanded ? `${height}px` : '0')};
|
|
overflow: hidden;
|
|
position: relative;
|
|
transition: max-height
|
|
${({ theme, isExpanded }) =>
|
|
`${theme.animation.duration.normal}s ${isExpanded ? 'ease-in' : 'ease-out'}`};
|
|
`;
|
|
|
|
type ExpandableContainerProps = {
|
|
isExpanded: boolean;
|
|
children: React.ReactNode;
|
|
};
|
|
|
|
export const ExpandableContainer = ({
|
|
isExpanded,
|
|
children,
|
|
}: ExpandableContainerProps) => {
|
|
const [contentHeight, setContentHeight] = useState(0);
|
|
const contentRef = useRef<HTMLDivElement>(null);
|
|
|
|
useLayoutEffect(() => {
|
|
if (isDefined(contentRef.current)) {
|
|
setContentHeight(contentRef.current.scrollHeight);
|
|
}
|
|
}, [isExpanded]);
|
|
|
|
return (
|
|
<StyledTransitionContainer isExpanded={isExpanded} height={contentHeight}>
|
|
<div ref={contentRef}>{children}</div>
|
|
</StyledTransitionContainer>
|
|
);
|
|
};
|
|
|
|
export default ExpandableContainer;
|