Skip to content

Commit

Permalink
fix(side-sheet): add shouldAnimate as allowed attribute
Browse files Browse the repository at this point in the history
Ref equinor/fusion#464
Ref AB#58933
  • Loading branch information
asbjornhaland committed Dec 11, 2024
1 parent bfefbf3 commit 5740e1b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-taxis-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@equinor/fusion-react-side-sheet': patch
---

Add `shouldAnimate` as allowed attribute.
14 changes: 9 additions & 5 deletions packages/side-sheet/src/components/SideSheetBase.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Scrim } from '@equinor/eds-core-react';
import { Resizable } from 're-resizable';
import { PropsWithChildren, useMemo, useState } from 'react';
import { PropsWithChildren, useState } from 'react';
import styled from 'styled-components';

const StyledScrim = styled(Scrim)<{ shouldAnimate: boolean }>`
const StyledScrim = styled(Scrim).withConfig({
shouldForwardProp: (prop) => prop !== 'shouldAnimate',
})<{ shouldAnimate: boolean }>`
animation: ${({ shouldAnimate }) => (shouldAnimate ? 'ScrimAnimation ease 0.3s' : 'none')};
animation-iteration-count: 1;
animation-fill-mode: forwards;
Expand All @@ -19,7 +21,9 @@ const StyledScrim = styled(Scrim)<{ shouldAnimate: boolean }>`
}
`;

const StyledSideSheet = styled.div<{ shouldAnimate: boolean }>`
const StyledSideSheet = styled.div.withConfig({
shouldForwardProp: (prop) => prop !== 'shouldAnimate',
})<{ shouldAnimate: boolean }>`
--side-sheet-height: calc(100vh - var(--header-height, 0));
height: var(--custom-side-sheet-height, var(--side-sheet-height, 100%));
position: fixed;
Expand Down Expand Up @@ -57,8 +61,8 @@ export const SideSheetBase = (props: PropsWithChildren<SideSheetProps>) => {
const { isOpen, onClose, isDismissable, minWidth, children, animate } = props;
const [width, setWidth] = useState(minWidth ?? MIN_WIDTH);

const shouldAnimate = useMemo(() => (animate === undefined ? true : animate), [animate]);
const shouldAnimate = animate === undefined ? true : animate;

return (
<StyledScrim open={isOpen} onClose={onClose} isDismissable={isDismissable} shouldAnimate={shouldAnimate}>
<StyledSideSheet shouldAnimate={shouldAnimate}>
Expand Down

0 comments on commit 5740e1b

Please sign in to comment.