Skip to content

Commit 98e046c

Browse files
committed
Add Animate component
1 parent 33cd7ac commit 98e046c

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { AnimatePresentVertical, AnimatePresentVerticalProps } from './components';
2+
3+
export type AnimateProps = {
4+
type: 'present-vertical';
5+
} & AnimatePresentVerticalProps;
6+
7+
export const Animate = ({ type, ...props }: AnimateProps) => {
8+
switch (type) {
9+
case 'present-vertical':
10+
return <AnimatePresentVertical {...props} />;
11+
default:
12+
return null;
13+
}
14+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
4+
export interface AnimatePresentVerticalProps extends React.HTMLAttributes<HTMLDivElement> {
5+
present?: boolean;
6+
children?: React.ReactNode;
7+
}
8+
9+
const StyledDiv = styled.div`
10+
--display-start: none;
11+
--height-start: 0;
12+
--display-end: block;
13+
--height-end: min-content;
14+
15+
overflow: clip;
16+
transition-property: display, height;
17+
transition-duration: 0.25s;
18+
transition-timing-function: ease;
19+
interpolate-size: allow-keywords;
20+
transition-behavior: allow-discrete;
21+
display: var(--display-start);
22+
height: var(--height-start);
23+
&&[data-present='true'] {
24+
display: var(--display-end);
25+
height: var(--height-end);
26+
@starting-style {
27+
height: var(--height-start);
28+
}
29+
}
30+
`;
31+
32+
export const AnimatePresentVertical = ({ present, ...props }: AnimatePresentVerticalProps) => {
33+
return <StyledDiv data-present={present} {...props} />;
34+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './AnimatePresentVertical';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Animate';

0 commit comments

Comments
 (0)