Files
flipper/desktop/plugins/navigation/components/IconButton.tsx
Pascal Hartig fc9ed65762 prettier 2
Summary:
Quick notes:

- This looks worse than it is. It adds mandatory parentheses to single argument lambdas. Lots of outrage on Twitter about it, personally I'm {emoji:1f937_200d_2642} about it.
- Space before function, e.g. `a = function ()` is now enforced. I like this because both were fine before.
- I added `eslint-config-prettier` to the config because otherwise a ton of rules conflict with eslint itself.

Close https://github.com/facebook/flipper/pull/915

Reviewed By: jknoxville

Differential Revision: D20594929

fbshipit-source-id: ca1c65376b90e009550dd6d1f4e0831d32cbff03
2020-03-24 09:38:11 -07:00

66 lines
1.4 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {Glyph, styled, keyframes, IconSize} from 'flipper';
import React from 'react';
const shrinkAnimation = keyframes({
'0%': {
transform: 'scale(1);',
},
'100%': {
transform: 'scale(.9)',
},
});
type Props = {
icon: string;
outline?: boolean;
onClick?: () => void;
color?: string;
size: IconSize;
};
const RippleEffect = styled.div({
padding: 5,
borderRadius: 100,
backgroundPosition: 'center',
transition: 'background 0.5s',
':hover': {
background:
'rgba(155, 155, 155, 0.2) radial-gradient(circle, transparent 1%, rgba(155, 155, 155, 0.2) 1%) center/15000%',
},
':active': {
backgroundColor: 'rgba(201, 200, 200, 0.5)',
backgroundSize: '100%',
transition: 'background 0s',
},
});
const IconButton = styled.div({
':active': {
animation: `${shrinkAnimation} .25s ease forwards`,
},
});
export default function (props: Props) {
return (
<RippleEffect>
<IconButton className="icon-button" onClick={props.onClick}>
<Glyph
name={props.icon}
size={props.size}
color={props.color}
variant={props.outline ? 'outline' : 'filled'}
/>
</IconButton>
</RippleEffect>
);
}