Skip to content

Instantly share code, notes, and snippets.

@RyanCCollins
Last active April 5, 2017 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanCCollins/2a450da6b4038edace28b143ac31d173 to your computer and use it in GitHub Desktop.
Save RyanCCollins/2a450da6b4038edace28b143ac31d173 to your computer and use it in GitHub Desktop.
import styled, { css } from 'styled-components';
import { StateProps } from './types';
import { Heading } from 'ui';
function styles({ isVisible }: StateProps) {
const opacity = isVisible
? 1.0
: 0.0;
const translate = isVisible
? 0
: 100;
return css`
transform: translateY(${translate}%);
opacity: ${opacity};
`;
}
function transition(props: StateProps) {
const duration = 600;
return css`
transition: transform ${duration}ms ease, opacity ${duration}ms ease;
`;
}
export default styled(Heading)`
${(props: StateProps) => styles(props)}
${(props: StateProps) => transition(props)}
will-change: transform, opacity;
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment