Skip to content

Commit

Permalink
refactor(AnimateHeight): ♻️ Move styling to utils.css
Browse files Browse the repository at this point in the history
  • Loading branch information
mimarz committed May 7, 2024
1 parent efd0582 commit 10d52e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
16 changes: 16 additions & 0 deletions packages/css/utils.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@
box-shadow: 0 0 0 var(--fds-focus-border-width) var(--fds-semantic-border-focus-boxshadow);
}
}

@layer fds.utils.animate-height {
.fds-animate-height--openingOrClosing,
.fds-animate-height--closed {
overflow: hidden;
}

.fds-animate-height--open .fds-animate-height__content {
height: auto;
}

.fds-animate-height--closed .fds-animate-height__content {
height: 0;
display: none;
}
}

This file was deleted.

6 changes: 2 additions & 4 deletions packages/react/src/utilities/AnimateHeight/AnimateHeight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import cl from 'clsx';

import { useMediaQuery, usePrevious } from '../../hooks';

import classes from './AnimateHeight.module.css';

export type AnimateHeightProps = {
open: boolean;
} & React.HTMLAttributes<HTMLDivElement>;
Expand Down Expand Up @@ -59,12 +57,12 @@ export const AnimateHeight = ({
return (
<div
{...rest}
className={cl(classes.root, classes[state], className)}
className={cl(`fds-animate-height--${state}`, className)}
style={{ height, transition, ...style }}
>
<div
ref={contentRef}
className={classes.content}
className='fds-animate-height__content'
>
{children}
</div>
Expand Down

0 comments on commit 10d52e9

Please sign in to comment.